46e365c58b22badc18bb796dae65a6a30b89272f
[gentoo.git] / dev-python / rdflib / rdflib-4.2.2-r1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 PYTHON_COMPAT=( python{2_7,3_{6,7}} )
7 PYTHON_REQ_USE="sqlite?,threads(+)"
8
9 # The usual required for tests
10 DISTUTILS_IN_SOURCE_BUILD=1
11
12 inherit distutils-r1
13
14 DESCRIPTION="RDF library containing a triple store and parser/serializer"
15 HOMEPAGE="https://github.com/RDFLib/rdflib https://pypi.org/project/rdflib/"
16 SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
17
18 LICENSE="BSD"
19 SLOT="0"
20 KEYWORDS="~alpha ~amd64 ~arm ~arm64 hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86 ~amd64-linux ~x86-linux"
21 IUSE="doc berkdb examples mysql redland sqlite test"
22 RESTRICT="!test? ( test )"
23
24 RDEPEND="
25         dev-python/isodate[${PYTHON_USEDEP}]
26         dev-python/html5lib[${PYTHON_USEDEP}]
27         dev-python/pyparsing[${PYTHON_USEDEP}]
28         berkdb? ( dev-python/bsddb3[${PYTHON_USEDEP}] )
29         mysql? ( dev-python/mysql-python[$(python_gen_usedep 'python2*')] )
30         redland? ( dev-libs/redland-bindings[python,$(python_gen_usedep 'python2*')] )"
31 DEPEND="${RDEPEND}
32         dev-python/setuptools[${PYTHON_USEDEP}]
33         doc? ( dev-python/sphinx[${PYTHON_USEDEP}] )
34         test? (
35                 dev-python/sparql-wrapper[${PYTHON_USEDEP}]
36                 >=dev-python/nose-1.3.1-r1[${PYTHON_USEDEP}]
37         )"
38
39 PATCHES=(
40         # Python 3.7 StopIteration bug
41         "${FILESDIR}"/${PN}-4.2.2-python3.7-StopIteration.patch
42 )
43
44 python_prepare_all() {
45         # Upstream manufactured .pyc files which promptly break distutils' src_test
46         find -name "*.py[oc~]" -delete || die
47
48         # Bug 358189; take out tests that attempt to connect to the network
49         sed -e "/'--with-doctest',/d" -e "/'--doctest-extension=.doctest',/d" \
50                 -e "/'--doctest-tests',/d" -i run_tests.py || die
51
52         sed -e "s: 'sphinx.ext.intersphinx',::" -i docs/conf.py || die
53
54         # doc build requires examples folder at the upper level of docs
55         if use doc; then
56                 cd docs || die
57                 ln -sf ../examples . || die
58                 cd ../ || die
59         fi
60
61         distutils-r1_python_prepare_all
62 }
63
64 python_compile_all() {
65         # https://github.com/RDFLib/rdflib/issues/510
66         if use doc; then
67                 einfo ""
68                 einfo "Several warnings and Errors present in the build"
69                 einfo "For a complete build, it is required to install"
70                 einfo "github.com/gjhiggins/n3_pygments_lexer and"
71                 einfo "github.com/gjhiggins/sparql_pygments_lexer"
72                 einfo "outside portage via pip or by cloning. These have not been"
73                 einfo "given a tagged release by the author and are not in portage"
74                 einfo ""
75
76                 emake -C docs html
77                 HTML_DOCS=( docs/_build/html/. )
78         fi
79 }
80
81 python_test() {
82         # the default; nose with: --where=./ does not work for python3
83         if python_is_python3; then
84                 pushd "${BUILD_DIR}/src/" >/dev/null || die
85                 "${EPYTHON}" ./run_tests.py || die "Tests failed under ${EPYTHON}"
86                 popd >/dev/null || die
87         else
88                 "${EPYTHON}" ./run_tests.py || die "Tests failed under ${EPYTHON}"
89         fi
90 }
91
92 python_install_all() {
93         distutils-r1_python_install_all
94
95         if use examples; then
96                 dodoc -r examples
97                 docompress -x /usr/share/doc/${PF}/examples
98         fi
99 }