Blob Blame History Raw
%global __python3 /usr/bin/python3.11
%global python3_pkgversion 3.11

# Pythran is an optional build dependency.
# When used, it makes some modules faster,
# but it is usually not available soon enough for new major Python versions.
%bcond_with pythran

# Set to pre-release version suffix if building pre-release, else %%{nil}
%global rcver %{nil}

%if 0%{?fedora} >= 33 || 0%{?rhel} >= 9
%global blaslib flexiblas
%global blasvar %{nil}
%else
%global blaslib openblas
%global blasvar p
%endif

%global modname scipy

Summary:    Scientific Tools for Python
Name:       python%{python3_pkgversion}-scipy
Version:    1.10.0
Release:    1%{?dist}

# BSD -- whole package except:
# Boost -- scipy/special/cephes/scipy_iv.c
# Public Domain -- scipy/odr/__odrpack.c
License:    BSD and Boost and Public Domain
Url:        http://www.scipy.org/scipylib/index.html
Source0:    https://github.com/scipy/scipy/releases/download/v%{version}/scipy-%{version}.tar.gz

# Fix some test failures on 32 bits
# https://github.com/scipy/scipy/pull/17859
# https://github.com/scipy/scipy/pull/17931
Patch0:     fix-32bit-test-failures.patch

BuildRequires: fftw-devel, suitesparse-devel
BuildRequires: %{blaslib}-devel
BuildRequires: gcc-gfortran, swig, gcc-c++
BuildRequires: qhull-devel

BuildRequires:  python%{python3_pkgversion}-pybind11-devel
BuildRequires:  python%{python3_pkgversion}-pybind11 >= 2.4.0
BuildRequires:  python%{python3_pkgversion}-numpy, python%{python3_pkgversion}-devel, python%{python3_pkgversion}-numpy-f2py
BuildRequires:  python%{python3_pkgversion}-rpm-macros
BuildRequires:  python%{python3_pkgversion}-setuptools
BuildRequires:  python%{python3_pkgversion}-Cython
BuildRequires:  python%{python3_pkgversion}-pytest

%if %{with pythran}
BuildRequires:  pythran
%endif

Requires:   python%{python3_pkgversion}-numpy, python%{python3_pkgversion}-f2py

%global _description %{expand:
Scipy is open-source software for mathematics, science, and
engineering. The core library is NumPy which provides convenient and
fast N-dimensional array manipulation. The SciPy library is built to
work with NumPy arrays, and provides many user-friendly and efficient
numerical routines such as routines for numerical integration and
optimization. Together, they run on all popular operating systems, are
quick to install, and are free of charge. NumPy and SciPy are easy to
use, but powerful enough to be depended upon by some of the world's
leading scientists and engineers.}

%description %_description

%prep
%autosetup -p1 -n %{modname}-%{version}%{?rcver}
cat > site.cfg << EOF

[amd]
library_dirs = %{_libdir}
include_dirs = /usr/include/suitesparse
amd_libs = amd

[umfpack]
library_dirs = %{_libdir}
include_dirs = /usr/include/suitesparse
umfpack_libs = umfpack

[openblas]
libraries = %{blaslib}%{blasvar}
library_dirs = %{_libdir}
EOF

rm $(grep -rl '/\* Generated by Cython') PKG-INFO

%build
export SCIPY_USE_PYTHRAN=0%{?with_pythran}

for PY in %{python3_pkgversion}; do
  # Adding -fallow-argument-mismatch workaround for https://github.com/scipy/scipy/issues/11611
  env CFLAGS="$RPM_OPT_FLAGS -lm" \
      FFLAGS="$RPM_OPT_FLAGS -fPIC -cpp" \
      LDFLAGS="$RPM_LD_FLAGS -shared" \
  %if 0%{?rhel} >= 9
  %ifarch x86_64
      # workaround for https://bugzilla.redhat.com/show_bug.cgi?id=2068530
      LDFLAGS="%{__global_ldflags} -Wl,--no-as-needed -lmvec -Wl,--as-needed" \
  %endif
  %endif
    %{_bindir}/python$PY setup.py config_fc \
    --fcompiler=gnu95 --noarch \
    build

done

%install
export SCIPY_USE_PYTHRAN=0%{?with_pythran}

%py3_install
# Some files got ambiguous python shebangs, we fix them after everything else is done
%py3_shebang_fix %{buildroot}%{python3_sitearch}

%check
# check against the reference BLAS/LAPACK
export FLEXIBLAS=netlib


# https://github.com/scipy/scipy/issues/17912
SKIP_ALL_ARCHS="\
not TestDatasets and \
not TestOde and \
not TestComplexOde and \
not TestVODECheckParameterUse and \
not TestZVODECheckParameterUse and \
not test_banded_ode_solvers and \
not test_examples[True-complex64]"

# skip also failing test_sygst for now
SKIP_X86_64="-k '$SKIP_ALL_ARCHS and \
not test_sygst'"

# https://bugzilla.redhat.com/show_bug.cgi?id=1959353
# TestConstructUtils::test_concatenate_int32_overflow is flaky on aarch64
SKIP_AARCH64="-k '$SKIP_ALL_ARCHS and \
not test_solve_discrete_are and \
not test_maxiter_worsening[lgmres] and \
not test_concatenate_int32_overflow'"

# Those tests fail on koji/brew for ppc64le but pass
# locally for that architecture
SKIP_PPC64LE="-k '$SKIP_ALL_ARCHS and \
not TestFFTConvolve and \
not TestDoubleFFT and \
not TestSingleFFT and \
not TestDoubleIFFT and \
not TestSingleIFFT and \
not test_tpsv and \
not TestLinear and \
not test_various_drivers_standard and \
not test_Mx1_economic and \
not test_hegst and \
not test_tpqrt_tpmqrt and \
not test_pteqr and \
not test_pptrs_pptri_pptrf_ppsv_ppcon and \
not test_against_numpy_convolve and \
not test_convolve_method and \
not test_rank1 and \
not test_splu_smoketest and \
not test_spilu_smoketest and \
not test_threads_parallel and \
not test_hermitian and \
not test_convergence and \
not test_precond_dummy and \
not test_x0_equals_Mb and \
not test_svdp and \
not test_examples'"

# https://bugzilla.redhat.com/show_bug.cgi?id=1959353
SKIP_S390X="-k '$SKIP_ALL_ARCHS and \
not test_solve_discrete_are and \
not test_maxiter_worsening[lgmres] and \
not TestInterop and \
not TestSplder and \
not test_dblint and \
not TestUnivariateSpline and \
not TestLSQBivariateSpline and \
not TestPPoly and \
not TestLevyStable'"

# skip also test_cython_api: https://bugzilla.redhat.com/show_bug.cgi?id=2068496
# https://github.com/scipy/scipy/issues/17213
SKIP_32BIT="-k '$SKIP_ALL_ARCHS and \
not test_sygst and \
not test_cython_api and \
not test_examples and \
not test_shifts and \
not test_mu and \
not test_sum and \
not test_svdp and \
not test_resiliency_all_32 and \
not test_resiliency_random[TestCSC-test_sum_dtype] and \
not test_x0_equals_Mb[bicgstab] and \
not test_gh12218'"

export PYTEST_ADDOPTS="-k '$SKIP_ALL_ARCHS'"
# default test timeout
TIMEOUT=500

%ifarch x86_64
export PYTEST_ADDOPTS=$SKIP_X86_64
%endif

%ifarch aarch64
export PYTEST_ADDOPTS=$SKIP_AARCH64
TIMEOUT=1000
%endif

%ifarch ppc64le
export PYTEST_ADDOPTS=$SKIP_PPC64LE
TIMEOUT=1000
%endif

%ifarch s390x
export PYTEST_ADDOPTS=$SKIP_S390X
TIMEOUT=1000
%endif

%ifarch armv7hl
export PYTEST_ADDOPTS=$SKIP_32BIT
%endif

%ifarch i686
export PYTEST_ADDOPTS=$SKIP_32BIT
%endif

pushd %{buildroot}/%{python3_sitearch}
# Ignoring the datasets tests as we don't have the optional pooch
# dependency on RHEL.
%{pytest} --ignore=scipy/datasets/tests/test_data.py scipy
# Remove test remnants
rm -rf gram{A,B}
popd

%files -n python%{python3_pkgversion}-scipy
%doc LICENSE.txt
%{python3_sitearch}/scipy/
%{python3_sitearch}/*.egg-info

%changelog
* Sun Feb 19 2023 Charalampos Stratakis <cstratak@redhat.com> - 1.10.0-1
- Update to 1.10.0

* Thu Dec 01 2022 Charalampos Stratakis <cstratak@redhat.com> - 1.8.1-1
- Initial package
- Fedora contributions by:
      Antonio Trande <anto.trande@gmail.com>
      Bill Nottingham <notting@fedoraproject.org>
      Björn Esser <me@besser82.io>
      Charalampos Stratakis <cstratak@redhat.com>
      Christian Dersch <lupinix@mailbox.org>
      David Malcolm <dmalcolm@redhat.com>
      Deji Akingunola <deji@fedoraproject.org>
      Dennis Gilmore <dennis@ausil.us>
      Elliott Sales de Andrade <quantum.analyst@gmail.com>
      Ignacio Vazquez-Abrams <ivazquez@fedoraproject.org>
      Igor Gnatenko <ignatenkobrain@fedoraproject.org>
      Iñaki Úcar <iucar@fedoraproject.org>
      Jef Spaleta <jspaleta@fedoraproject.org>
      Jesse Keating <jkeating@fedoraproject.org>
      Jitka Plesnikova <jplesnik@redhat.com>
      Jonathan Wakely <jwakely@redhat.com>
      Jon Ciesla <limb@fedoraproject.org>
      Kalev Lember <klember@redhat.com>
      Kevin Fenzi <kevin@scrye.com>
      Lumir Balhar <lbalhar@redhat.com>
      Mamoru TASAKA <mtasaka@fedoraproject.org>
      Marcel Plch <mplch@redhat.com>
      Miro Hrončok <miro@hroncok.cz>
      Nikola Forró <nforro@redhat.com>
      Nils Philippsen <nils@redhat.com>
      Orion Poplawski <orion@nwra.com>
      Pavel Šimovec <psimovec@redhat.com>
      Peter Robinson <pbrobinson@fedoraproject.org>
      Petr Viktorin <pviktori@redhat.com>
      Robert Kuska <rkuska@redhat.com>
      Than Ngo <than@redhat.com>
      Thomas Spura <thomas.spura@gmail.com>
      Tomas Tomecek <ttomecek@redhat.com>
      Toshio Kuratomi <toshio@fedoraproject.org>
      Troy Dawson <tdawson@fedoraproject.org>
      Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>