1+ # Distributed under the terms of the GNU General Public License v2
2+
3+ EAPI=7
4+
5+ PYTHON_COMPAT=( python3+ pypy3 )
6+
7+ inherit distutils-r1 eutils toolchain-funcs
8+
9+ DESCRIPTION=" A Pythonic binding for the libxml2 and libxslt libraries"
10+ HOMEPAGE=" https://lxml.de/ https://pypi.org/project/lxml/ https://github.com/lxml/lxml"
11+ SRC_URI=" https://files.pythonhosted.org/packages/76/3d/14e82fc7c8fb1b7761f7e748fd47e2ec8276d137b6acfe5a4bb73853e08f/lxml-5.4.0.tar.gz -> lxml-5.4.0.tar.gz"
12+
13+ LICENSE=" BSD ElementTree GPL-2 PSF-2"
14+ SLOT=" 0"
15+ KEYWORDS=" *"
16+ IUSE=" doc examples +threads test"
17+ RESTRICT=" !test? ( test )"
18+
19+ # Note: lib{xml2,xslt} are used as C libraries, not Python modules.
20+ RDEPEND="
21+ >=dev-libs/libxml2-2.9.5
22+ >=dev-libs/libxslt-1.1.28"
23+ DEPEND=" ${RDEPEND} "
24+ BDEPEND="
25+ virtual/pkgconfig
26+ dev-python/cython[${PYTHON_USEDEP} ]
27+ dev-python/setuptools[${PYTHON_USEDEP} ]
28+ test? ( dev-python/cssselect[${PYTHON_USEDEP} ] )
29+ "
30+
31+ DISTUTILS_IN_SOURCE_BUILD=1
32+
33+ python_prepare_all () {
34+ # avoid replacing PYTHONPATH in tests.
35+ sed -i -e ' /sys\.path/d' test.py || die
36+
37+ # don't use some random SDK on Darwin
38+ sed -i -e ' /_ldflags =/s/=.*isysroot.*darwin.*None/= None/' \
39+ setupinfo.py || die
40+
41+ distutils-r1_python_prepare_all
42+ }
43+
44+ python_compile () {
45+ if ! python_is_python3; then
46+ local -x CFLAGS=" ${CFLAGS} -fno-strict-aliasing"
47+ fi
48+ tc-export PKG_CONFIG
49+ distutils-r1_python_compile
50+ }
51+
52+ python_test () {
53+ cp -r -l src/lxml/tests " ${BUILD_DIR} " /lib/lxml/ || die
54+ cp -r -l src/lxml/html/tests " ${BUILD_DIR} " /lib/lxml/html/ || die
55+ ln -s " ${S} " /doc " ${BUILD_DIR} " / || die
56+
57+ " ${EPYTHON} " test.py -vv --all-levels -p || die " Test ${test} fails with ${EPYTHON} "
58+ }
59+
60+ python_install_all () {
61+ if use doc; then
62+ local DOCS=( README.rst * .txt doc/* .txt )
63+ local HTML_DOCS=( doc/html/. )
64+ fi
65+ if use examples; then
66+ dodoc -r samples
67+ fi
68+
69+ distutils-r1_python_install_all
70+ }
71+
72+ pkg_postinst () {
73+ optfeature " Support for BeautifulSoup as a parser backend" dev-python/beautifulsoup
74+ optfeature " Translates CSS selectors to XPath 1.0 expressions" dev-python/cssselect
75+ }
0 commit comments