327beed811d36c71da8d16e38cc0d6426a8ce23e
[gentoo.git] / dev-python / nose / nose-1.3.7-r1.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python2_7 python3_{5,6} pypy pypy3 )
7 PYTHON_REQ_USE="threads(+)"
8
9 inherit distutils-r1
10
11 DESCRIPTION="Unittest extension with automatic test suite discovery and easy test authoring"
12 HOMEPAGE="
13         https://pypi.org/project/nose/
14         https://nose.readthedocs.io/en/latest/
15         https://bitbucket.org/jpellerin/nose"
16 SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
17
18 LICENSE="LGPL-2.1"
19 SLOT="0"
20 KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
21 IUSE="doc examples test"
22
23 REQUIRED_USE="
24         doc? ( || ( $(python_gen_useflags 'python2*') ) )"
25
26 RDEPEND="
27         dev-python/coverage[${PYTHON_USEDEP}]
28         dev-python/setuptools[${PYTHON_USEDEP}]"
29 DEPEND="${RDEPEND}
30         doc? ( >=dev-python/sphinx-0.6[${PYTHON_USEDEP}] )
31         test? ( $(python_gen_cond_dep 'dev-python/twisted-core[${PYTHON_USEDEP}]' python2_7) )"
32
33 PATCHES=( "${FILESDIR}"/${P}-python-3.5-backport.patch )
34
35 pkg_setup() {
36         use doc && DISTUTILS_ALL_SUBPHASE_IMPLS=( 'python2*' )
37 }
38
39 python_prepare_all() {
40         # Tests need to be converted, and they don't respect BUILD_DIR.
41         use test && DISTUTILS_IN_SOURCE_BUILD=1
42
43         # Disable tests requiring network connection.
44         sed \
45                 -e "s/test_resolve/_&/g" \
46                 -e "s/test_raises_bad_return/_&/g" \
47                 -e "s/test_raises_twisted_error/_&/g" \
48                 -i unit_tests/test_twisted.py || die "sed failed"
49         # Disable versioning of nosetests script to avoid collision with
50         # versioning performed by the eclass.
51         sed -e "/'nosetests%s = nose:run_exit' % py_vers_tag,/d" \
52                 -i setup.py || die "sed2 failed"
53
54         # Prevent un-needed d'loading during doc build
55         sed -e "s/, 'sphinx.ext.intersphinx'//" -i doc/conf.py || die
56
57         distutils-r1_python_prepare_all
58 }
59
60 python_compile() {
61         local add_targets=()
62
63         if use test; then
64                 add_targets+=( egg_info )
65                 python_is_python3 && add_targets+=( build_tests )
66         fi
67
68         distutils-r1_python_compile ${add_targets[@]}
69 }
70
71 python_compile_all() {
72         use doc && emake -C doc html
73 }
74
75 python_test() {
76         "${PYTHON}" selftest.py -v || die "Tests fail with ${EPYTHON}"
77 }
78
79 python_install() {
80         distutils-r1_python_install --install-data "${EPREFIX}/usr/share"
81 }
82
83 python_install_all() {
84         use examples && dodoc -r examples
85         use doc && HTML_DOCS=( doc/.build/html/. )
86         distutils-r1_python_install_all
87 }