Blob Blame History Raw
%global with_python3 0
# We need python3-pandas
%global upname statsmodels

Name: python-%{upname}
Version: 0.5.0
Release: 9%{?dist}
Summary: Statistics in Python
# Package is licensed under BSD (3 clauses)
# except the following files in Public Domain
# statsmodels/datasets/elnino/data.py
# statsmodels/datasets/randhie/data.py
License: BSD and Public Domain

URL: http://statsmodels.sourceforge.net/
Source0: http://pypi.python.org/packages/source/s/statsmodels/%{upname}-%{version}.tar.gz
# Disable the tests that fail
# https://github.com/statsmodels/statsmodels/issues/1320
# https://github.com/statsmodels/statsmodels/issues/1319
# https://github.com/statsmodels/statsmodels/issues/1316
Patch0: statsmodels-skiptests.patch
# This tests fails in F21 ARM, but no in F20 ARM
Patch1: statsmodels-f21-arm.patch
# This tests fails in F20 i686, but no in F21 i686
Patch2: statsmodels-f20-32.patch

BuildRequires: python2-devel python-nose
BuildRequires: numpy scipy Cython python-patsy python-pandas
BuildRequires: python-sphinx python-ipython-console
BuildRequires: python-matplotlib
# Included due to bug #1030396
BuildRequires: python-matplotlib-qt4
BuildRequires: tex-preview

Requires: numpy scipy python-patsy python-pandas

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

%description
statsmodels is a Python module that provides classes and functions for the 
estimation of many different statistical models, as well as for conducting 
statistical tests, and statistical data exploration. An extensive list of 
result statistics are available for each estimator. The results are tested 
against existing statistical packages to ensure that they are correct.

%package doc
Summary: Documentation for %{name}, includes full API docs
BuildArch: noarch
 
%description doc
This package contains the full API documentation for %{name}.

%if 0%{?with_python3}
%package -n python3-%{upname}
Summary: Statistics in Python
BuildRequires: python3-devel python3-nose
BuildRequires: python3-numpy python3-scipy python3-Cython python3-patsy python3-pandas
BuildRequires: python3-sphinx python3-matplotlib python3-ipython-console
# Due to bug #1030396
BuildRequires: python3-matplotlib-qt4
BuildRequires: tex-preview

Requires: python3-numpy python3-scipy python3-patsy python3-pandas

%description -n python3-%{upname}
statsmodels is a Python module that provides classes and functions for the 
estimation of many different statistical models, as well as for conducting 
statistical tests, and statistical data exploration. An extensive list of 
result statistics are available for each estimator. The results are tested 
against existing statistical packages to ensure that they are correct.

%package -n python3-%{upname}-doc
Summary: Documentation for %{name}, includes full API docs
BuildArch: noarch
 
%description -n python3-%{upname}-doc
This package contains the full API documentation for %{name}.

%endif # with_python3

%prep
%setup -qn %{upname}-%{version}
%patch0 -p1
%ifarch %{arm}
%patch1 -p1
%endif
%ifarch %{ix86}
%patch2 -p1
%endif
# remove shebang
sed -i -e "1d" statsmodels/datasets/engel/data.py
sed -i -e "1d" statsmodels/datasets/fair/data.py
sed -i -e "1d" statsmodels/datasets/statecrime/data.py
sed -i -e "1d" statsmodels/datasets/strikes/data.py
sed -i -e "1d" statsmodels/datasets/template_data.py
sed -i -e "1d" statsmodels/sandbox/examples/example_pca.py
sed -i -e "1d" statsmodels/tools/print_version.py
sed -i -e "1d" statsmodels/regression/quantile_regression.py
sed -i -e "1d" statsmodels/tsa/setup.py
# copy other files names LICENSE.txt
cp -a statsmodels/stats/libqsturng/LICENSE.txt LICENSE.libqsturng.txt
cp -a statsmodels/LICENSE.txt LICENSE.statsmodels.txt
cp -a statsmodels/datasets/README.txt README.datasets.txt
cp -a statsmodels/datasets/COPYING COPYING.datasets

%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}" %{__python2} setup.py build 
%{__python2} setup.py build_sphinx
rm -f build/sphinx/html/.buildinfo

%if 0%{?with_python3}
pushd %{py3dir}
CFLAGS="%{optflags}" %{__python3} setup.py build
# Not working
#%{__python3} setup.py build_sphinx
popd
# Copying the python2 docs for the moment
mkdir -p docs/_build3/
cp -a build/sphinx/html build/sphinx3
%endif # with_python3

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

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

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

# Remove files that shouldn't be installed
pushd %{buildroot}/%{python2_sitearch}/%{upname}
rm LICENSE.txt TODO.txt
rm stats/libqsturng/LICENSE.txt
rm sandbox/tools/TODO.txt
rm datasets/README.txt
rm datasets/COPYING

find -name "*.c" -delete 
find -name "*.pyx" -delete
rmdir src
popd

%check
# Fake matplotlibrc
mkdir matplotlib
touch matplotlib/matplotlibrc
export XDG_CONFIG_HOME=`pwd`
pushd %{buildroot}/%{python2_sitearch}
nosetests-%{python2_version} %{upname}
popd
%if 0%{?with_python3}
pushd %{buildroot}/%{python3_sitearch}
nosetests-%{python3_version} %{upname}
popd
%endif # with_python3
 
%files
%doc LICENSE.txt COPYRIGHTS.txt README_l1.txt README.txt LICENSE.libqsturng.txt LICENSE.statsmodels.txt README.datasets.txt COPYING.datasets
%{python2_sitearch}/*

%files doc
%doc LICENSE.txt COPYRIGHTS.txt README_l1.txt README.txt examples build/sphinx/html LICENSE.libqsturng.txt LICENSE.statsmodels.txt README.datasets.txt COPYING.datasets

%if 0%{?with_python3}
%files -n python3-%{upname}
%doc LICENSE.txt COPYRIGHTS.txt README_l1.txt README.txt LICENSE.libqsturng.txt LICENSE.statsmodels.txt README.datasets.txt COPYING.datasets
%{python3_sitearch}/*

%files -n python3-%{upname}-doc
%doc LICENSE.txt COPYRIGHTS.txt README_l1.txt README.txt examples build/sphinx3/html LICENSE.libqsturng.txt LICENSE.statsmodels.txt README.datasets.txt COPYING.datasets

%endif # with_python3

%changelog
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.5.0-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Fri Jan 24 2014 Sergio Pascual <sergiopr@fedoraproject.org> - 0.5.0-8
- Enable tests in arm
- Disable failling test in i686
- Disable failling test in arm

* Tue Jan 21 2014 Sergio Pascual <sergiopr@fedoraproject.org> - 0.5.0-7
- Disable tests in arm

* Mon Jan 20 2014 Sergio Pascual <sergiopr@fedoraproject.org> - 0.5.0-6
- Add README.txt and COPYING from datasets to doc

* Sun Jan 19 2014 Sergio Pascual <sergiopr@fedoraproject.org> - 0.5.0-5
- Added url for bug report of removed tests
- Minor fixes in the spec
- Included other LICENSE.txt in the documentation

* Wed Jan 15 2014 Sergio Pascual <sergiopr@fedoraproject.org> - 0.5.0-4
- Use an empty matplotlibrc for tests

* Wed Jan 15 2014 Sergio Pascual <sergiopr@fedoraproject.org> - 0.5.0-3
- Patch those tests that fail

* Fri Jan 10 2014 Sergio Pascual <sergiopr@fedoraproject.org> - 0.5.0-2
- Add ipython to build documentation

* Fri Jan 10 2014 Sergio Pascual <sergiopr@fedoraproject.org> - 0.5.0-1
- Initial spec