diff options
author | 2023-06-05 23:25:00 -0400 | |
---|---|---|
committer | 2023-06-06 06:34:31 +0100 | |
commit | fff86605fbd568f23e4af7cc6bf3536294fdbafc (patch) | |
tree | 087653b0ea9e8cf57ac294aecde3d35c22b1fe09 /dev-python/lxml | |
parent | dev-ruby/version_gem: add 1.1.3 (diff) | |
download | gentoo-fff86605fbd568f23e4af7cc6bf3536294fdbafc.tar.gz gentoo-fff86605fbd568f23e4af7cc6bf3536294fdbafc.tar.bz2 gentoo-fff86605fbd568f23e4af7cc6bf3536294fdbafc.zip |
dev-python/lxml: Backport py3.12 unicode fix
Signed-off-by: Violet Purcell <vimproved@inventati.org>
Closes: https://github.com/gentoo/gentoo/pull/31327
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'dev-python/lxml')
-rw-r--r-- | dev-python/lxml/files/lxml-4.9.2-py3.12-backport-unicode-fix.patch | 33 | ||||
-rw-r--r-- | dev-python/lxml/lxml-4.9.2-r1.ebuild | 116 |
2 files changed, 149 insertions, 0 deletions
diff --git a/dev-python/lxml/files/lxml-4.9.2-py3.12-backport-unicode-fix.patch b/dev-python/lxml/files/lxml-4.9.2-py3.12-backport-unicode-fix.patch new file mode 100644 index 000000000000..d1ca31d1b909 --- /dev/null +++ b/dev-python/lxml/files/lxml-4.9.2-py3.12-backport-unicode-fix.patch @@ -0,0 +1,33 @@ +Upstream: https://github.com/lxml/lxml/commit/a1f2231dfdd31a37f2c55bc9ae4ac33e92221227 + +From a1f2231dfdd31a37f2c55bc9ae4ac33e92221227 Mon Sep 17 00:00:00 2001 +From: Stefan Behnel <stefan_ml@behnel.de> +Date: Fri, 12 May 2023 09:49:34 +0200 +Subject: [PATCH] Adapt unicode parsing to Py3.12. + +--- + src/lxml/includes/etree_defs.h | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/src/lxml/includes/etree_defs.h b/src/lxml/includes/etree_defs.h +index e671fa85d..d42f2158c 100644 +--- a/src/lxml/includes/etree_defs.h ++++ b/src/lxml/includes/etree_defs.h +@@ -120,6 +120,16 @@ static PyObject* PyBytes_FromFormat(const char* format, ...) { + # define _lx_PySlice_GetIndicesEx(o, l, b, e, s, sl) PySlice_GetIndicesEx(((PySliceObject*)o), l, b, e, s, sl) + #endif + ++#if PY_VERSION_HEX >= 0x030B00A1 ++/* Python 3.12 doesn't have wstr Unicode strings any more. */ ++#undef PyUnicode_GET_DATA_SIZE ++#define PyUnicode_GET_DATA_SIZE(ustr) (0) ++#undef PyUnicode_AS_DATA ++#define PyUnicode_AS_DATA(ustr) (NULL) ++#undef PyUnicode_IS_READY ++#define PyUnicode_IS_READY(ustr) (1) ++#endif ++ + #ifdef WITHOUT_THREADING + # undef PyEval_SaveThread + # define PyEval_SaveThread() (NULL) + diff --git a/dev-python/lxml/lxml-4.9.2-r1.ebuild b/dev-python/lxml/lxml-4.9.2-r1.ebuild new file mode 100644 index 000000000000..9b26e534fcf8 --- /dev/null +++ b/dev-python/lxml/lxml-4.9.2-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 +" +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 ~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.9.12-r2 + >=dev-libs/libxslt-1.1.28 +" +RDEPEND=" + ${DEPEND} +" +BDEPEND=" + virtual/pkgconfig + <dev-python/cython-3[${PYTHON_USEDEP}] + >=dev-python/cython-0.29.29[${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.6.0-tests-pypy.patch + "${FILESDIR}"/${P}-py3.12-drop-deprecated-imp.patch + "${FILESDIR}"/${P}-py3.12-backport-unicode-fix.patch +) + +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 +} |