1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
8 inherit distutils-r1 flag-o-matic
10 MYPN="${PN/scikits_/scikit-}"
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"
19 KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
20 IUSE="doc examples test"
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}]
31 virtual/python-funcsigs[${PYTHON_USEDEP}]
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}]
41 dev-python/joblib[${PYTHON_USEDEP}]
42 dev-python/matplotlib[${PYTHON_USEDEP}]
43 dev-python/sphinx[${PYTHON_USEDEP}]
48 PATCHES=( "${FILESDIR}/${PN}-0.18.1-system-cblas.patch" )
50 python_prepare_all() {
52 [[ ${CHOST} == *-darwin* ]] \
53 && append-ldflags -bundle "-undefined dynamic_lookup" \
54 || append-ldflags -shared
56 # scikits-learn now uses the horrible numpy.distutils automagic
57 export SCIPY_FCONFIG="config_fc --noopt --noarch"
59 # remove bundled cblas
60 rm -r sklearn/src || die
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
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
76 distutils-r1_python_prepare_all
80 distutils-r1_python_compile ${SCIPY_FCONFIG}
83 python_compile_all() {
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}" \
93 rm -r "${d}"/sklearn/datasets/{data,descr,images} || die
98 # doc builds and runs tests
100 distutils_install_for_testing ${SCIPY_FCONFIG}
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
110 distutils-r1_python_install ${SCIPY_FCONFIG}
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