app-editors/kakoune: drop old 0_pre20160620
[gentoo.git] / sci-libs / scikits_learn / scikits_learn-0.18.1.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python2_7 python3_{4,5} )
7
8 inherit distutils-r1 flag-o-matic
9
10 MYPN="${PN/scikits_/scikit-}"
11 MYP="${MYPN}-${PV}"
12
13 DESCRIPTION="Python modules for machine learning and data mining"
14 HOMEPAGE="http://scikit-learn.org"
15 SRC_URI="mirror://pypi/${MYPN:0:1}/${MYPN}/${MYP}.tar.gz"
16
17 LICENSE="BSD"
18 SLOT="0"
19 KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
20 IUSE="doc examples test"
21
22 RDEPEND="
23         dev-python/joblib[${PYTHON_USEDEP}]
24         dev-python/matplotlib[${PYTHON_USEDEP}]
25         dev-python/nose[${PYTHON_USEDEP}]
26         >=dev-python/numpy-1.6.1[lapack,${PYTHON_USEDEP}]
27         sci-libs/scikits[${PYTHON_USEDEP}]
28         >=sci-libs/scipy-0.9[${PYTHON_USEDEP}]
29         virtual/blas
30         virtual/cblas
31         virtual/python-funcsigs[${PYTHON_USEDEP}]
32         "
33 DEPEND="
34         dev-python/cython[${PYTHON_USEDEP}]
35         dev-python/numpy[lapack,${PYTHON_USEDEP}]
36         dev-python/setuptools[${PYTHON_USEDEP}]
37         sci-libs/scipy[${PYTHON_USEDEP}]
38         virtual/blas
39         virtual/cblas
40         doc? (
41                 dev-python/joblib[${PYTHON_USEDEP}]
42                 dev-python/matplotlib[${PYTHON_USEDEP}]
43                 dev-python/sphinx[${PYTHON_USEDEP}]
44                 )"
45
46 S="${WORKDIR}/${MYP}"
47
48 PATCHES=( "${FILESDIR}/${P}-system-cblas.patch" )
49
50 python_prepare_all() {
51         # bug #397605
52         [[ ${CHOST} == *-darwin* ]] \
53                 && append-ldflags -bundle "-undefined dynamic_lookup" \
54                 || append-ldflags -shared
55
56         # scikits-learn now uses the horrible numpy.distutils automagic
57         export SCIPY_FCONFIG="config_fc --noopt --noarch"
58
59         # remove bundled cblas
60         rm -r sklearn/src || die
61
62         # use system joblib
63         rm -r sklearn/externals/joblib || die
64         sed -i -e '/joblib/d' sklearn/externals/setup.py || die
65         for f in sklearn/{*/,}*.py; do
66                 sed -r -e '/^from/s/(sklearn|\.|)\.externals\.joblib/joblib/' \
67                         -e 's/from (sklearn|\.|)\.externals import/import/' -i $f || die
68         done
69
70         rm sklearn/externals/funcsigs.py || die
71         rm sklearn/externals/odict.py || die
72         for f in sklearn/{utils/fixes.py,gaussian_process/{tests/test_,}kernels.py}; do
73                 sed -r -e 's/from (sklearn|\.|)\.externals\.funcsigs/from funcsigs/' -i $f || die
74         done
75
76         distutils-r1_python_prepare_all
77 }
78
79 python_compile() {
80         distutils-r1_python_compile ${SCIPY_FCONFIG}
81 }
82
83 python_compile_all() {
84         if use doc; then
85                 cd "${S}/doc" || die
86                 local d="${BUILD_DIR}"/lib
87                 ln -s "${S}"/sklearn/datasets/{data,descr,images} \
88                         "${d}"/sklearn/datasets || die
89                 VARTEXFONTS="${T}"/fonts \
90                         MPLCONFIGDIR="${BUILD_DIR}" \
91                         PYTHONPATH="${d}" \
92                         emake html
93                 rm -r "${d}"/sklearn/datasets/{data,descr,images} || die
94         fi
95 }
96
97 python_test() {
98         # doc builds and runs tests
99         use doc && return
100         distutils_install_for_testing ${SCIPY_FCONFIG}
101         esetup.py \
102                 install --root="${T}/test-${EPYTHON}" \
103                 --no-compile ${SCIPY_FCONFIG}
104         pushd "${T}/test-${EPYTHON}/$(python_get_sitedir)" || die > /dev/null
105         nosetests -v sklearn --exe || die
106         popd > /dev/null
107 }
108
109 python_install() {
110         distutils-r1_python_install ${SCIPY_FCONFIG}
111 }
112
113 python_install_all() {
114         find "${S}" -name \*LICENSE.txt -delete
115         insinto /usr/share/doc/${PF}
116         use doc && doins -r doc/_build/html
117         use examples && doins -r examples
118         distutils-r1_python_install_all
119 }