ba5fe56
Name:           pythran
84a90ba
Version:        0.14.0
9612a24
Release:        %autorelease
ba5fe56
Summary:        Ahead of Time Python compiler for numeric kernels
ba5fe56
c38e2ec
# pythran is BSD
f31e188
# pythran/graph.py has bits of networkx, also BSD
ba5fe56
# pythran/pythonic/patch/complex is MIT or NCSA
ba5fe56
License:        BSD and (MIT or NCSA)
ba5fe56
ba5fe56
# see pythran/pythonic/patch/README.rst
ba5fe56
# The version is probably somewhat around 3
ba5fe56
Provides:       bundled(libcxx) = 3
ba5fe56
f31e188
# see pythran/graph.py
f31e188
# Only bundles one function from networkx
f31e188
Provides:       bundled(python3dist(networkx)) = 2.6.1
f31e188
f31e188
088d720
%py_provides    python3-%{name}
088d720
ba5fe56
URL:            https://github.com/serge-sans-paille/pythran
f31e188
Source0:        %{url}/archive/%{version}/%{name}-%{version}.tar.gz
ba5fe56
feab376
# Get rid of numpy.distutils
feab376
# https://github.com/serge-sans-paille/pythran/pull/2149
feab376
Patch:          %{url}/pull/2149.patch
feab376
ba5fe56
# there is no actual arched content
ba5fe56
# yet we want to test on all architectures
ba5fe56
# and we also might need to skip some
ba5fe56
%global debug_package %{nil}
ba5fe56
ba4c216
BuildRequires: make
ba5fe56
BuildRequires:  boost-devel
6c8a5cf
BuildRequires:  flexiblas-devel
ba5fe56
BuildRequires:  gcc-c++
088d720
BuildRequires:  pyproject-rpm-macros
ba5fe56
BuildRequires:  python3-devel
978edc9
BuildRequires:  xsimd-devel >= 8
088d720
9efb98e
# For docs
9efb98e
# Avoid building the docs by default on RHEL not to drag pandoc into RHEL:
9efb98e
%bcond docs %{undefined rhel}
9efb98e
%if %{with docs}
9efb98e
BuildRequires:  pandoc
9efb98e
%endif
9efb98e
088d720
# For tests
ba5fe56
BuildRequires:  python3-pytest
088d720
BuildRequires:  /usr/bin/python
9ab8d53
BuildRequires:  python3-scipy
ba5fe56
5686317
# these packages are not included in RHEL
5e90622
%if %{undefined rhel}
5686317
# this is used for supporting -n auto in %%pytest
5686317
BuildRequires:  python3-pytest-xdist
5686317
# this is only used to test integration with ipython
5e90622
BuildRequires:  /usr/bin/ipython
5e90622
%endif
5e90622
ba5fe56
# This is a package that compiles code, it runtime requires devel packages
6c8a5cf
Requires:       flexiblas-devel
ba5fe56
Requires:       gcc-c++
ba5fe56
Requires:       python3-devel
ba5fe56
Requires:       boost-devel
978edc9
Requires:       xsimd-devel >= 8
ba5fe56
ba5fe56
%description
ba5fe56
Pythran is an ahead of time compiler for a subset of the Python language, with
ba5fe56
a focus on scientific computing. It takes a Python module annotated with a few
ba5fe56
interface description and turns it into a native Python module with the same
ba5fe56
interface, but (hopefully) faster. It is meant to efficiently compile
ba5fe56
scientific programs, and takes advantage of multi-cores and SIMD
ba5fe56
instruction units.
ba5fe56
088d720
ba5fe56
%prep
f31e188
%autosetup -p1 -n %{name}-%{version}
ba5fe56
find -name '*.hpp' -exec chmod -x {} +
ba5fe56
sed -i '1{/#!/d}' pythran/run.py
ba5fe56
ba5fe56
# Remove bundled header libs and use the ones from system
ba5fe56
rm -r third_party/boost third_party/xsimd
ba5fe56
cat >> setup.cfg << EOF
ba5fe56
[build_py]
ba5fe56
no_boost=True
ba5fe56
no_xsimd=True
ba5fe56
EOF
ba5fe56
6c8a5cf
# Both OpenBLAS and FlexiBLAS are registered as "openblas" in numpy
ba5fe56
sed -i 's|blas=blas|blas=openblas|' pythran/pythran-linux*.cfg
6c8a5cf
sed -i 's|libs=|libs=flexiblas|' pythran/pythran-linux*.cfg
6c8a5cf
sed -i 's|include_dirs=|include_dirs=/usr/include/flexiblas|' pythran/pythran-linux*.cfg
ba5fe56
1486761
# not yet available in Fedora
088d720
sed -i '/guzzle_sphinx_theme/d' docs/conf.py docs/requirements.txt
088d720
f31e188
# The tests have some cflags in them
f31e188
# We need to adapt the flags to play nicely with other Fedora's flags
f31e188
# E.g. fortify source implies at least -O1
f31e188
sed -i -e 's/-O0/-O1/g' -e 's/-Werror/-w/g' pythran/tests/__init__.py
f31e188
088d720
088d720
%generate_buildrequires
9efb98e
%pyproject_buildrequires %{?with_docs:-x doc}
088d720
1486761
ba5fe56
%build
088d720
%pyproject_wheel
088d720
9efb98e
%if %{with docs}
088d720
PYTHONPATH=$PWD make -C docs html
ba5fe56
rm -rf docs/_build/html/.{doctrees,buildinfo}
9efb98e
%endif
ba5fe56
088d720
ba5fe56
%install
088d720
%pyproject_install
088d720
%pyproject_save_files %{name} omp
ba5fe56
ba5fe56
088d720
%check
978edc9
# https://bugzilla.redhat.com/show_bug.cgi?id=1747029#c12
978edc9
k="not test_numpy_negative_binomial"
5b9e3de
%if 0%{?__isa_bits} == 32
5b9e3de
# These tests cause memory (address space) exhaustion; see discussion in
5b9e3de
# https://src.fedoraproject.org/rpms/pythran/pull-request/28.
5b9e3de
for t in test_fftn_{8,17,20,22} \
5b9e3de
    test_{h,ih,ir}fft_{8,14} \
5b9e3de
    test_{,i}fft_3d{,_axis,f64_axis,int64_axis} \
5b9e3de
    test_numpy_random_bytes1
5b9e3de
do
5b9e3de
  k="$k and not ${t}"
5b9e3de
done
5b9e3de
%endif
da00026
%ifarch aarch64
da00026
# the test is so flaky it makes the build fail almost all the time
da00026
k="$k and not test_interp_8"
da00026
%endif
978edc9
%ifarch %{power64}
978edc9
# https://github.com/serge-sans-paille/pythran/pull/1946#issuecomment-992460026
978edc9
k="$k and not test_setup_bdist_install3"
978edc9
%endif
5e90622
%if %{defined rhel}
5e90622
# this test needs ipython
5e90622
k="$k and not test_loadext_and_run"
5e90622
%endif
5b9e3de
8b3688c
# Don’t run tests in parallel on 32-bit architecutres. RRunning tests in serial
8b3688c
# makes memory errors, which occur in some tests on 32-bit architectures, more
8b3688c
# reproducible, and makes the output when they occur less confusing: we tend to
8b3688c
# get individual test failures rather than a pytest INTERNALERROR.
8b3688c
%if %{undefined rhel} && 0%{?__isa_bits} != 32
8b3688c
%global use_pytest_xdist 1
8b3688c
%endif
8b3688c
5b9e3de
%pytest %{?use_pytest_xdist:-n auto} -k "$k"
088d720
ba5fe56
088d720
%files -f %{pyproject_files}
ba5fe56
%license LICENSE
ba5fe56
%doc README.rst
9efb98e
%if %{with docs}
ba5fe56
%doc docs/_build/html
9efb98e
%endif
ba5fe56
%{_bindir}/%{name}
ba5fe56
%{_bindir}/%{name}-config
088d720
ba5fe56
ba5fe56
%changelog
9612a24
%autochangelog