*/*: Clean PYTHON_COMPAT of obsolete impls
[gentoo.git] / dev-python / cython / cython-0.29.4.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=( python2_7 python3_{6,7} )
7 PYTHON_REQ_USE="threads(+)"
8
9 inherit distutils-r1 toolchain-funcs elisp-common
10
11 MY_PN="Cython"
12 MY_P="${MY_PN}-${PV/_/}"
13
14 DESCRIPTION="A Python to C compiler"
15 HOMEPAGE="https://cython.org https://pypi.org/project/Cython/"
16 SRC_URI="mirror://pypi/${MY_PN:0:1}/${MY_PN}/${MY_P}.tar.gz"
17
18 LICENSE="Apache-2.0"
19 SLOT="0"
20 KEYWORDS="alpha amd64 arm arm64 hppa ia64 ~mips ppc ppc64 s390 ~sh sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris"
21
22 IUSE="doc emacs test"
23 RESTRICT="!test? ( test )"
24
25 RDEPEND="
26         emacs? ( >=app-editors/emacs-23.1:* )
27 "
28 DEPEND="${RDEPEND}
29         dev-python/setuptools[${PYTHON_USEDEP}]
30         doc? ( dev-python/sphinx[${PYTHON_USEDEP}] )
31         test? ( dev-python/numpy[${PYTHON_USEDEP}] )"
32
33 SITEFILE=50cython-gentoo.el
34 S="${WORKDIR}/${MY_PN}-${PV%_*}"
35
36 python_prepare_all() {
37         # tests behavior that is illegal in Python 3.7+
38         # https://github.com/cython/cython/issues/2454
39         sed -i -e '/with_outer_raising/,/return/d' tests/run/generators_py.py || die
40
41         distutils-r1_python_prepare_all
42 }
43
44 python_compile() {
45         if ! python_is_python3; then
46                 local CFLAGS="${CFLAGS} -fno-strict-aliasing"
47                 local CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing"
48         fi
49
50         # Python gets confused when it is in sys.path before build.
51         local -x PYTHONPATH=
52
53         distutils-r1_python_compile
54 }
55
56 python_compile_all() {
57         use emacs && elisp-compile Tools/cython-mode.el
58
59         use doc && emake -C docs html
60 }
61
62 python_test() {
63         tc-export CC
64         # https://github.com/cython/cython/issues/1911
65         local -x CFLAGS="${CFLAGS} -fno-strict-overflow"
66         "${PYTHON}" runtests.py -vv --work-dir "${BUILD_DIR}"/tests \
67                 || die "Tests fail with ${EPYTHON}"
68 }
69
70 python_install_all() {
71         local DOCS=( CHANGES.rst README.rst ToDo.txt USAGE.txt )
72         use doc && local HTML_DOCS=( docs/build/html/. )
73         distutils-r1_python_install_all
74
75         if use emacs; then
76                 elisp-install ${PN} Tools/cython-mode.*
77                 elisp-site-file-install "${FILESDIR}/${SITEFILE}"
78         fi
79 }
80
81 pkg_postinst() {
82         use emacs && elisp-site-regen
83 }
84
85 pkg_postrm() {
86         use emacs && elisp-site-regen
87 }