app-editors/kakoune: drop old 0_pre20160620
[gentoo.git] / sci-libs / scikits_learn / scikits_learn-0.17.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 PYTHON_COMPAT=( python2_7 python3_4 )
7
8 inherit distutils-r1 eutils multilib 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 python_prepare_all() {
49         # bug #397605
50         [[ ${CHOST} == *-darwin* ]] \
51                 && append-ldflags -bundle "-undefined dynamic_lookup" \
52                 || append-ldflags -shared
53
54         # scikits-learn now uses the horrible numpy.distutils automagic
55         export SCIPY_FCONFIG="config_fc --noopt --noarch"
56
57         # use system joblib
58         rm -r sklearn/externals/joblib/* || die
59         echo "from joblib import *" > sklearn/externals/joblib/__init__.py
60         sed -i -e '/joblib\/test/d' sklearn/externals/setup.py || die
61         sed -i -e 's/..externals.joblib/joblib/g' \
62                 sklearn/decomposition/tests/test_sparse_pca.py \
63                 sklearn/metrics/pairwise.py || die
64
65         rm sklearn/externals/funcsigs.py || die
66         rm sklearn/externals/odict.py || die
67         sed \
68                 -e 's:from ..externals.funcsigs import signature:from funcsigs import signature:g' \
69                 -i sklearn/utils/fixes.py || die
70
71         # use gentoo cblas infrastructure
72         epatch "${FILESDIR}"/${PN}-0.14.1-system-cblas.patch
73
74         distutils-r1_python_prepare_all
75 }
76
77 python_compile() {
78         distutils-r1_python_compile ${SCIPY_FCONFIG}
79 }
80
81 python_compile_all() {
82         if use doc; then
83                 cd "${S}/doc" || die
84                 local d="${BUILD_DIR}"/lib
85                 ln -s "${S}"/sklearn/datasets/{data,descr,images} \
86                         "${d}"/sklearn/datasets || die
87                 VARTEXFONTS="${T}"/fonts \
88                         MPLCONFIGDIR="${BUILD_DIR}" \
89                         PYTHONPATH="${d}" \
90                         emake html
91                 rm -r "${d}"/sklearn/datasets/{data,descr,images} || die
92         fi
93 }
94
95 python_test() {
96         # doc builds and runs tests
97         use doc && return
98         distutils_install_for_testing ${SCIPY_FCONFIG}
99         esetup.py \
100                 install --root="${T}/test-${EPYTHON}" \
101                 --no-compile ${SCIPY_FCONFIG}
102         pushd "${T}/test-${EPYTHON}/$(python_get_sitedir)" || die > /dev/null
103         nosetests -v sklearn --exe || die
104         popd > /dev/null
105 }
106
107 python_install() {
108         distutils-r1_python_install ${SCIPY_FCONFIG}
109 }
110
111 python_install_all() {
112         find "${S}" -name \*LICENSE.txt -delete
113         use doc && HTML_DOCS=( doc/_build/html/. )
114         use examples && EXAMPLES=( examples/. )
115         distutils-r1_python_install_all
116 }