Blob Blame History Raw
%global upname scikit-learn
%global with_python3 0

Name: python-scikit-learn
Version: 0.14.1
Release: 1%{?dist}
Summary: Machine learning in Python
License: BSD
# No license file
# https://github.com/scikit-learn/scikit-learn/issues/2422
# webpage says: BSD (3 clause)

# part of the files in sklearn/src/cblas: BSD (2 clause)
# part of the files in sklearn/src/cblas: BSD (3 clause)

URL: http://scikit-learn.org/
Source0: https://pypi.python.org/packages/source/s/scikit-learn/%{upname}-%{version}.tar.gz
Patch0: sklearn-unbundle-joblib.patch
BuildRequires: python2-devel 
BuildRequires: numpy scipy python-nose python-matplotlib
BuildRequires: python-six python-joblib
BuildRequires: atlas-devel blas-devel
Requires: numpy scipy python-six python-joblib

# we don't want to provide private python extension libs
%global __provides_exclude_from ^(%{python_sitearch}|%{python3_sitearch})/.*\\.so$

%description
Scikit-learn integrates machine learning algorithms in the tightly-knit 
scientific Python world, building upon numpy, scipy, and matplotlib. 
As a machine-learning module, it provides versatile tools for data mining and 
analysis in any field of science and engineering. It strives to be simple and 
efficient, accessible to everybody, and reusable in various contexts.

%if 0%{?with_python3}
%package -n python3-%{upname}
Summary: Machine learning in Python
BuildRequires: python3-devel python3-nose
BuildRequires: python3-numpy python3-scipy python3-matplotlib
BuildRequires: python3-six
BuildRequires: atlas-devel blas-devel
Requires: python3-numpy python3-scipy

%description -n python3-%{upname}
Scikit-learn integrates machine learning algorithms in the tightly-knit 
scientific Python world, building upon numpy, scipy, and matplotlib. 
As a machine-learning module, it provides versatile tools for data mining and 
analysis in any field of science and engineering. It strives to be simple and 
efficient, accessible to everybody, and reusable in various contexts.
%endif # with_python3

%prep
%setup -n %{upname}-%{version} -q
%patch0 -p1
rm -rf sklearn/externals/joblib

rm -rf *egg-info

chmod -x examples/plot_rbm_logistic_classification.py

# Reported upstream
# https://github.com/scikit-learn/scikit-learn/issues/2423
# Removing bogus shebang
pushd sklearn/datasets
sed -i -e "1d" setup.py
popd

pushd sklearn/gaussian_process/
#sed -i -e "1d" gaussian_process.py regression_models.py __init__.py correlation_models.py
sed -i -e "1d" regression_models.py __init__.py correlation_models.py
sed -i -e "2d" gaussian_process.py 
popd

# Unbundle six

%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python3}|'
%endif # with_python3

find -name '*.py' | xargs sed -i '1s|^#!python|#!%{__python}|'

%build
CFLAGS="%{optflags}" %{__python} setup.py build

%if 0%{?with_python3}
pushd %{py3dir}
CFLAGS="%{optflags}" %{__python3} setup.py build
popd
%endif # with_python3

%install
%if 0%{?with_python3}
pushd %{py3dir}
%{__python3} setup.py install --skip-build --root  %{buildroot}
popd
%endif # with_python3

%{__python} setup.py install --skip-build --root  %{buildroot}

find %{buildroot} -name "*.so" | xargs chmod 755

%check
#%if 0%{?with_python3}
# pushd %{buildroot}/%{python3_sitearch}
# nosetests-3.3 sklearn
# popd
#%endif # with_python3

pushd %{buildroot}/%{python_sitearch}
nosetests sklearn
popd
 
%files
%doc examples/ AUTHORS.rst README.rst
%{python_sitearch}/sklearn
%{python_sitearch}/scikit_learn-*.egg-info

%if 0%{?with_python3}
%files -n python3-%{upname}
%doc examples/ AUTHORS.rst README.rst
%{python3_sitearch}/sklearn
%{python3_sitearch}/scikit_learn-*.egg-info
%endif # with_python3

%changelog
* Wed Aug 28 2013 Sergio Pascual <sergiopr@fedoraproject.org> - 0.14.1-1
- New upstream source (0.14.1)

* Wed Jul 10 2013 Sergio Pascual <sergiopr@fedoraproject.org> - 0.13.1-3
- Reorder buildrequires and requires
- Dropped doc, it does not build

* Tue Jun 25 2013 Sergio Pascual <sergiopr@fedoraproject.org> - 0.13.1-2
- Changed package name
- Tests do not need recompile

* Thu Apr 18 2013 Sergio Pascual <sergiopr@fedoraproject.org> - 0.13.1-1
- Initial spec file