File python-numpy.spec of Package python-numpy.26461

#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define with_atlas 0

%define modname numpy
Name:           python-%{modname}
Version:        1.8.0
Release:        0
URL:            http://sourceforge.net/projects/numpy
Summary:        NumPy array processing for numbers, strings, records and objects
License:        BSD-3-Clause
Group:          Development/Libraries/Python
Source:         http://sourceforge.net/projects/numpy/files/NumPy/%{version}/%{modname}-%{version}.tar.gz
Patch0:         numpy-buildfix.patch
Patch1:         numpy-double-double-le.patch
# PATCH-FIX-OPENSUSE CVE-2019-6446_allow_pickle_False.patch bnc#1122208 ; mcepl@suse.com
# add allow_pickle option to manage insecure operation gh#numpy/numpy#12759
Patch2:         CVE-2019-6446_allow_pickle_False.patch
# PATCH-FIX-UPSTREAM CVE-2021-41496-bufovrflw-fortranobject-DoS.patch bsc#1193907 mcepl@suse.com
# https://github.com/numpy/numpy/pull/20630
Patch3:         CVE-2021-41496-bufovrflw-fortranobject-DoS.patch
# PATCH-FIX-UPSTREAM CVE-2021-33430-bufovrflw-ctors-DoS.patch bsc#1193913 mcepl@suse.com
# https://github.com/numpy/numpy/pull/18989
Patch4:         CVE-2021-33430-bufovrflw-ctors-DoS.patch
# PATCH-FIX-UPSTREAM CVE-2021-41495-retval-PyArray_DescrNew.patch bsc#1193911 mcepl@suse.com
# review return values for PyArray_DescrNew
Patch5:         CVE-2021-41495-retval-PyArray_DescrNew.patch
# PATCH-FIX-UPSTREAM CVE-2017-12852-pad-empty-array-infinite-loop.patch bsc#1053963
# Raise exception when attempting to pad an empty array
Patch6:         CVE-2017-12852-pad-empty-array-infinite-loop.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  blas-devel
BuildRequires:  lapack-devel
BuildRequires:  python-devel >= 2.6
Requires:       python >= %{py_ver}
Provides:       numpy = %{version}
%if %{with_atlas} == 1
BuildRequires:  libatlas3-devel
%endif
%if 0%{?suse_version}
BuildRequires:  fdupes
BuildRequires:  gcc-fortran
%if 0%{?suse_version} <= 1110
%{!?python_sitearch: %global python_sitearch %(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%else
%py_requires
%endif
%else
BuildRequires:  gcc-gfortran
%if ! 0%{?fedora_version}
Provides:       python-numeric = %{version}
Obsoletes:      python-numeric < %{version}
%endif
%endif
Requires(post): update-alternatives
Requires(postun):update-alternatives

%description
NumPy is a general-purpose array-processing package designed to
efficiently manipulate large multi-dimensional arrays of arbitrary
records without sacrificing too much speed for small multi-dimensional
arrays.  NumPy is built on the Numeric code base and adds features
introduced by numarray as well as an extended C-API and the ability to
create arrays of arbitrary type which also makes NumPy suitable for
interfacing with general-purpose data-base applications.

There are also basic facilities for discrete fourier transform,
basic linear algebra and random number generation.

%package devel
Summary:        Development files for %{modname} applications
Group:          Development/Libraries/Python
Requires:       %{name} = %{version}
Requires:       blas-devel
Requires:       lapack-devel
Requires:       python-devel >= %{py_ver}
%if 0%{?suse_version}
Requires:       gcc-fortran
%py_requires -d
%else
Requires:       gcc-gfortran
%endif
%if %{with_atlas} == 1
Requires:       libatlas3-devel
%endif

%description devel
This package contains files for developing applications using %{modname}.

%prep
%setup -q -n %{modname}-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1

# Fix non-executable scripts
sed -i "1d" numpy/{compat/setup,distutils/{conv_template,cpuinfo,exec_command,from_template,setup,system_info},f2py/{auxfuncs,capi_maps,cb_rules,cfuncs,common_rules,crackfortran,diagnose,docs/usersguide/setup_example,f2py2e,f90mod_rules,func2subr,__init__,rules,setup,use_rules},ma/setup,matrixlib/setup,setup,testing/{print_coercion_tables,setup}}.py

%build
CFLAGS="%{optflags} -fno-strict-aliasing" python setup.py build

%install
python setup.py install --root="%{buildroot}" --prefix="%{_prefix}"
rm -rf %{buildroot}%{python_sitearch}/%{modname}/{,core,distutils,f2py,fft,ma,matrixlib,oldnumeric,polynomial,random,testing}/tests # Don't package testsuite

cp %{buildroot}%{_bindir}/f2py %{buildroot}%{_bindir}/f2py-2.7
rm -r %{buildroot}%{_bindir}/f2py

mkdir -p %{buildroot}%{_sysconfdir}/alternatives
touch %{buildroot}%{_sysconfdir}/alternatives/f2py
ln -s -f %{_sysconfdir}/alternatives/f2py %{buildroot}%{_bindir}/f2py

%if 0%{?suse_version}
%fdupes -s %{buildroot}%{_prefix}
%endif

%post
update-alternatives --quiet --install %{_bindir}/f2py f2py %{_bindir}/f2py-2.7 0270

%postun
if [ ! -e "%{_bindir}/f2py-2.7" ]; then
    update-alternatives --quiet --remove f2py %{_bindir}/f2py-2.7
fi

%files
%defattr(-,root,root)
%doc *.txt

%ghost %{_sysconfdir}/alternatives/f2py
%{_bindir}/f2py
%{_bindir}/f2py-2.7

%{python_sitearch}/%{modname}/
%{python_sitearch}/%{modname}-%{version}-py%{py_ver}.egg-info
%exclude %{python_sitearch}/%{modname}/*/*/*.c
%exclude %{python_sitearch}/%{modname}/*/*.h
%exclude %{python_sitearch}/%{modname}/*/*/*.h
%exclude %{python_sitearch}/%{modname}/*/*/*/*.h
%exclude %{python_sitearch}/%{modname}/core/lib/libnpymath.a

%files devel
%defattr(-,root,root)
%{python_sitearch}/%{modname}/*/*/*.c
%{python_sitearch}/%{modname}/*/*.h
%{python_sitearch}/%{modname}/*/*/*.h
%{python_sitearch}/%{modname}/*/*/*/*.h
%{python_sitearch}/%{modname}/core/lib/libnpymath.a

%changelog
openSUSE Build Service is sponsored by