*/*: Clean PYTHON_COMPAT of obsolete impls
[gentoo.git] / dev-python / statsmodels / statsmodels-0.9.0.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5 PYTHON_COMPAT=( python2_7 python3_{6,7} )
6
7 inherit distutils-r1 eutils
8
9 DESCRIPTION="Statistical computations and models for use with SciPy"
10 HOMEPAGE="https://www.statsmodels.org/stable/index.html"
11 SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
12
13 LICENSE="BSD"
14 SLOT="0"
15 KEYWORDS="amd64 x86 ~amd64-linux ~x86-linux"
16 IUSE="doc examples test"
17 RESTRICT="!test? ( test )"
18
19 COMMON_DEPEND="
20         dev-python/numpy[${PYTHON_USEDEP}]
21         >=dev-python/pandas-0.23.0[${PYTHON_USEDEP}]
22         dev-python/patsy[${PYTHON_USEDEP}]
23         sci-libs/scipy[${PYTHON_USEDEP}]
24 "
25 RDEPEND="${COMMON_DEPEND}"
26 DEPEND="${COMMON_DEPEND}
27         dev-python/cython[${PYTHON_USEDEP}]
28         dev-python/setuptools[${PYTHON_USEDEP}]
29         doc? (
30                 dev-python/ipykernel[${PYTHON_USEDEP}]
31                 dev-python/jupyter_client[${PYTHON_USEDEP}]
32                 dev-python/matplotlib[${PYTHON_USEDEP}]
33                 dev-python/nbconvert[${PYTHON_USEDEP}]
34                 dev-python/nbformat[${PYTHON_USEDEP}]
35                 dev-python/numpydoc[${PYTHON_USEDEP}]
36                 dev-python/sphinx[${PYTHON_USEDEP}]
37         )
38         test? (
39                 dev-python/pytest[${PYTHON_USEDEP}]
40                 dev-python/nose[${PYTHON_USEDEP}]
41                 )
42 "
43
44 python_prepare_all() {
45         # Prevent un-needed d'loading
46         sed -e "/sphinx.ext.intersphinx/d" -i docs/source/conf.py || die
47         export VARTEXFONTS="${T}"/fonts
48         export MPLCONFIGDIR="${T}"
49         echo "backend : Agg" > "${MPLCONFIGDIR}"/matplotlibrc || die
50         if use test; then
51                 # Errors reported upstream: https://github.com/statsmodels/statsmodels/issues/4850
52                 rm statsmodels/tsa/tests/test_tsa_indexes.py || die
53                 sed -i -e \
54                         "/def test_start_params_bug():/i@pytest.mark.xfail(reason='Known to fail on Gentoo')" \
55                         statsmodels/tsa/tests/test_arima.py || die
56                 sed -i -e \
57                         "s/def test_pandas_endog():/def _test_pandas_endog():/g" \
58                         statsmodels/tsa/statespace/tests/test_mlemodel.py || die
59                 sed -i -e \
60                         "/def test_all_datasets():/i@pytest.mark.xfail(reason='Known to fail on Gentoo')" \
61                         statsmodels/datasets/tests/test_data.py || die
62                 sed -i -e \
63                         "/def test_issue_339():/i@pytest.mark.xfail(reason='Known to fail on Gentoo')" \
64                         statsmodels/discrete/tests/test_discrete.py || die
65                 sed -i \
66                         -e "s/def test_hdr_multiple_alpha():/def _test_hdr_multiple_alpha():/g" \
67                         statsmodels/graphics/tests/test_functional.py || die
68                 sed -i \
69                         -e '1s/^/import pytest \n/' \
70                         -e "/def test_single_factor_repeated_measures_anova():/i@pytest.mark.xfail(reason='Known to fail on Gentoo with Python 3')" \
71                         -e "/def test_two_factors_repeated_measures_anova():/i@pytest.mark.xfail(reason='Known to fail on Gentoo with Python 3')" \
72                         -e "/def test_three_factors_repeated_measures_anova():/i@pytest.mark.xfail(reason='Known to fail on Gentoo with Python 3')" \
73                         -e "/def test_repeated_measures_aggregate_compare_with_ezANOVA():/i@pytest.mark.xfail(reason='Known to fail on Gentoo with Python 3')" \
74                         statsmodels/stats/tests/test_anova_rm.py || die
75         fi
76         distutils-r1_python_prepare_all
77 }
78
79 python_compile_all() {
80         use doc && esetup.py build_sphinx -b html --build-dir=docs/build
81 }
82
83 python_test() {
84         cd "${BUILD_DIR}" || die
85         py.test -v || die
86 }
87
88 python_install_all() {
89         find . -name \*LICENSE.txt -delete || die
90         use doc && HTML_DOCS=( docs/build/html/. )
91         if use examples; then
92                 docompress -x /usr/share/doc/${PF}/examples
93                 dodoc -r examples
94         fi
95         distutils-r1_python_install_all
96 }
97
98 pkg_postinst() {
99         optfeature "Plotting functionality" "dev-python/matplotlib"
100 }