commit:     07f48c319ee7a5ebedbe615682f702c6ac99bbc9
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 27 04:24:12 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jul 27 04:24:31 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=07f48c31

dev-python/lxml: backport cython-3 fixes and test fixes for newer libxml2

Closes: https://bugs.gentoo.org/898682
Closes: https://bugs.gentoo.org/905643
Closes: https://bugs.gentoo.org/906088
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-python/lxml/Manifest                           |   1 +
 .../files/lxml-4.9.3-tests-py3.11-cython3.patch    |  10 ++
 dev-python/lxml/lxml-4.9.3-r1.ebuild               | 116 +++++++++++++++++++++
 3 files changed, 127 insertions(+)

diff --git a/dev-python/lxml/Manifest b/dev-python/lxml/Manifest
index 5b7a6edd4e46..3a2715be6ff9 100644
--- a/dev-python/lxml/Manifest
+++ b/dev-python/lxml/Manifest
@@ -1,2 +1,3 @@
 DIST lxml-4.9.2.gh.tar.gz 957365 BLAKE2B 
201b3977da90386e413f1b89a4b7ee1e44d6bbea05e622e92feb1d67c637ce46ebf746f0648f034ed3bccd609233ccf7d8a7ee456f13b8d9ca8587ddf1ebd32a
 SHA512 
816b2fe2eef2a97a0df66cbc39850c6dc3d6470e4033cc73edb40c80c0afbbe6c084d042d7c98b29497926e76f648caa42e1ebe5d83060af08af6972316077b0
+DIST lxml-4.9.3-patches.tar.xz 10544 BLAKE2B 
407938d2f701400e919110c3bfe84e94621f39f8178850c466d41549ee0eff4f23e93cdd8ea684713e8276acfaa05d6f7b7af4d375c859b9fc5b2981d60983a3
 SHA512 
c2d5d2ffb035aed6d846de84885b87142b2be7a09ffe6927e7c032acab343730acfcbefd75e8141cf3b41b308c532869a7878b515f3d4eeefa7526a3d2599398
 DIST lxml-4.9.3.gh.tar.gz 958628 BLAKE2B 
ffdf3fe781a03815f7c026229d313721c93375ebafad9b4a20c5d8a380a631401e546d8701a94d8c49615fb6a71e84940d8ca0299b47a37c1c9596db36659113
 SHA512 
903bd4935c7708b459aee9befcf3f6e3e3aaa9adc122591ea923b6e3d8fd288f07cab3f5f0edb08e3bf9db80414324f0a1a8e5a5089f9cda82f6c50f5df59423

diff --git a/dev-python/lxml/files/lxml-4.9.3-tests-py3.11-cython3.patch 
b/dev-python/lxml/files/lxml-4.9.3-tests-py3.11-cython3.patch
new file mode 100644
index 000000000000..1fb466ab810f
--- /dev/null
+++ b/dev-python/lxml/files/lxml-4.9.3-tests-py3.11-cython3.patch
@@ -0,0 +1,10 @@
+--- a/src/lxml/tests/test_errors.py
++++ b/src/lxml/tests/test_errors.py
+@@ -25,6 +25,7 @@ class ErrorTestCase(HelperTestCase):
+     def test_empty_parse(self):
+         self.assertRaises(etree.XMLSyntaxError, etree.fromstring, '')
+ 
++    @unittest.skipIf(sys.version_info >= (3, 11), "Known GC failure 
(https://bugzilla.redhat.com/show_bug.cgi?id=2051510)")
+     @unittest.skipIf(IS_PYPY, "broken on pypy")
+     def test_element_cyclic_gc_none(self):
+         # test if cyclic reference can crash etree

diff --git a/dev-python/lxml/lxml-4.9.3-r1.ebuild 
b/dev-python/lxml/lxml-4.9.3-r1.ebuild
new file mode 100644
index 000000000000..0ec56e19ad13
--- /dev/null
+++ b/dev-python/lxml/lxml-4.9.3-r1.ebuild
@@ -0,0 +1,116 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_EXT=1
+DISTUTILS_USE_PEP517=setuptools
+PYTHON_COMPAT=( python3_{10..12} pypy3 )
+
+inherit distutils-r1 optfeature toolchain-funcs
+
+DESCRIPTION="A Pythonic binding for the libxml2 and libxslt libraries"
+HOMEPAGE="
+       https://lxml.de/
+       https://pypi.org/project/lxml/
+       https://github.com/lxml/lxml/
+"
+SRC_URI="
+       https://github.com/lxml/lxml/archive/${P}.tar.gz
+               -> ${P}.gh.tar.gz
+       
https://dev.gentoo.org/~sam/distfiles/${CATEGORY}/${PN}/${PN}-4.9.3-patches.tar.xz
+"
+S=${WORKDIR}/lxml-${P}
+
+LICENSE="BSD ElementTree GPL-2 PSF-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 
~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos 
~x64-macos ~x64-solaris"
+IUSE="doc examples +threads test"
+RESTRICT="!test? ( test )"
+
+# Note: lib{xml2,xslt} are used as C libraries, not Python modules.
+DEPEND="
+       >=dev-libs/libxml2-2.10.3
+       >=dev-libs/libxslt-1.1.38
+"
+RDEPEND="
+       ${DEPEND}
+"
+BDEPEND="
+       virtual/pkgconfig
+       >=dev-python/cython-0.29.35[${PYTHON_USEDEP}]
+       doc? (
+               $(python_gen_any_dep '
+                       dev-python/docutils[${PYTHON_USEDEP}]
+                       dev-python/pygments[${PYTHON_USEDEP}]
+                       dev-python/sphinx[${PYTHON_USEDEP}]
+                       dev-python/sphinx-rtd-theme[${PYTHON_USEDEP}]
+               ')
+       )
+       test? (
+               dev-python/cssselect[${PYTHON_USEDEP}]
+       )
+"
+
+PATCHES=(
+       "${FILESDIR}"/${PN}-4.9.3-tests-pypy.patch
+       "${FILESDIR}"/${PN}-4.9.3-tests-py3.11-cython3.patch
+       "${WORKDIR}"/${PN}-4.9.3-patches
+)
+
+python_check_deps() {
+       use doc || return 0
+       python_has_version -b "dev-python/docutils[${PYTHON_USEDEP}]" &&
+       python_has_version -b "dev-python/pygments[${PYTHON_USEDEP}]" &&
+       python_has_version -b "dev-python/sphinx[${PYTHON_USEDEP}]" &&
+       python_has_version -b "dev-python/sphinx-rtd-theme[${PYTHON_USEDEP}]"
+}
+
+python_prepare_all() {
+       # avoid replacing PYTHONPATH in tests.
+       sed -i -e '/sys\.path/d' test.py || die
+
+       # don't use some random SDK on Darwin
+       sed -i -e '/_ldflags =/s/=.*isysroot.*darwin.*None/= None/' \
+               setupinfo.py || die
+
+       distutils-r1_python_prepare_all
+}
+
+python_compile() {
+       tc-export PKG_CONFIG
+       distutils-r1_python_compile
+}
+
+python_compile_all() {
+       use doc && emake html
+}
+
+python_test() {
+       local dir=${BUILD_DIR}/test$(python_get_sitedir)/lxml
+       local -x PATH=${BUILD_DIR}/test/usr/bin:${PATH}
+
+       cp -al "${BUILD_DIR}"/{install,test} || die
+       cp -al src/lxml/tests "${dir}/" || die
+       cp -al src/lxml/html/tests "${dir}/html/" || die
+       ln -rs "${S}"/doc "${dir}"/../../ || die
+
+       "${EPYTHON}" test.py -vv --all-levels -p || die "Test ${test} fails 
with ${EPYTHON}"
+}
+
+python_install_all() {
+       if use doc; then
+               local DOCS=( README.rst *.txt doc/*.txt )
+               local HTML_DOCS=( doc/html/. )
+       fi
+       if use examples; then
+               dodoc -r samples
+       fi
+
+       distutils-r1_python_install_all
+}
+
+pkg_postinst() {
+       optfeature "Support for BeautifulSoup as a parser backend" 
dev-python/beautifulsoup4
+       optfeature "Translates CSS selectors to XPath 1.0 expressions" 
dev-python/cssselect
+}

Reply via email to