From 8904f985ffd4a075dc0bfce77f4e342e23bd2363 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Feb 02 2024 02:42:54 +0000 Subject: [PATCH 1/4] Use dynamic BuildRequires for python runtime dependencies --- diff --git a/scipy.spec b/scipy.spec index f37cf7c..fb00ff9 100644 --- a/scipy.spec +++ b/scipy.spec @@ -30,7 +30,7 @@ Summary: Scientific Tools for Python Name: scipy Version: 1.11.3 -Release: 6%{?dist} +Release: 7%{?dist} # BSD-3-Clause -- whole package except: # BSD-2-Clause -- scipy/_lib/_pep440.py @@ -67,17 +67,11 @@ Patch: https://github.com/scipy/scipy/pull/19443.patch BuildRequires: %{blaslib}-devel BuildRequires: gcc-gfortran, gcc-c++ +BuildRequires: tomcli BuildRequires: pybind11-devel BuildRequires: python3-devel, python3-numpy-f2py -BuildRequires: python3-pytest -BuildRequires: python3-pytest-timeout -%if ! 0%{?rhel} -BuildRequires: python3-pytest-xdist -%endif -BuildRequires: python3-pooch - %if %{with doc} BuildRequires: python3-sphinx BuildRequires: python3-matplotlib @@ -189,8 +183,22 @@ sed -i '/pybind11/s/2\.11\.1/2.12.0/' pyproject.toml # not a real function. It is a weak alias to __open_memstream. sed -i "s/\('has_openmemstream', \)'0'/\1'1'/" scipy/_lib/meson.build +# meson-python does not implement the prepare_metadata_for_build_wheel hook :(. +# Instead of using -w and compiling the wheel, an expensive process, twice +# (once to extract metadata, one for the final package), we can write the +# static deps from pyproject.toml to a file, and use that with %%pyproject_buildrequires. +# +# See https://github.com/mesonbuild/meson-python/issues/236 for more discussion. +tomcli-get pyproject.toml -F newline-list \ + project.dependencies > _install-requirements.txt + +# Do the same for test dependencies +tomcli-get pyproject.toml -F newline-list \ + project.optional-dependencies.test > _test-requirements.txt + + %generate_buildrequires -%pyproject_buildrequires -R +%pyproject_buildrequires -R _install-requirements.txt _test-requirements.txt %build %pyproject_wheel @@ -287,6 +295,9 @@ popd %endif %changelog +* Fri Feb 02 2024 Maxwell G - 1.11.3-7 +- Use dynamic BuildRequires for python runtime dependencies + * Tue Jan 30 2024 Miro HronĨok - 1.11.3-6 - Skip fewer tests during build From 9dfef28e2ea939017b29202e04d1b446e2113c1c Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Feb 02 2024 02:48:13 +0000 Subject: [PATCH 2/4] Fix broken regex This sed invocation uses extended regex syntax (i.e., un-escaped `|` and parentheses capture groups) without the -E flag. --- diff --git a/scipy.spec b/scipy.spec index fb00ff9..f916130 100644 --- a/scipy.spec +++ b/scipy.spec @@ -157,7 +157,7 @@ for f in $(grep -Frl numpy.distutils); do done # Do not do benchmarking or coverage testing for RPM builds -sed -i '/^[[:blank:]]*"(asv|pytest-cov)"/d' pyproject.toml +sed -Ei '/^[[:blank:]]*"(asv|pytest-cov)"/d' pyproject.toml # No scikit-umfpack in Fedora sed -i '/^[[:blank:]]*"scikit-umfpack"/d' pyproject.toml From f77aeeb563caa6208261dab9974287fde18576cc Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Feb 02 2024 17:59:34 +0000 Subject: [PATCH 3/4] Remove test timeouts These are not pertinent to the RPM builds. We just want to know whether the tests succeed or not, not how long they take on our builders. --- diff --git a/scipy.spec b/scipy.spec index f916130..b1bd0a2 100644 --- a/scipy.spec +++ b/scipy.spec @@ -156,8 +156,8 @@ for f in $(grep -Frl numpy.distutils); do rm $f.orig done -# Do not do benchmarking or coverage testing for RPM builds -sed -Ei '/^[[:blank:]]*"(asv|pytest-cov)"/d' pyproject.toml +# Do not do benchmarking, coverage, or timeout testing for RPM builds +sed -Ei '/^[[:blank:]]*"(asv|pytest-cov|pytest-timeout)"/d' pyproject.toml # No scikit-umfpack in Fedora sed -i '/^[[:blank:]]*"scikit-umfpack"/d' pyproject.toml @@ -228,29 +228,20 @@ chmod 0755 %{buildroot}%{python3_sitearch}/scipy/sparse/linalg/_isolve/tests/tes # check against the reference BLAS/LAPACK export FLEXIBLAS=netlib -# default test timeout -TIMEOUT=500 - # TestDatasets try to download from the internet SKIP_ALL="not TestDatasets" export PYTEST_ADDOPTS="-k '$SKIP_ALL'" -%ifarch ppc64le -TIMEOUT=1000 -%endif - %ifarch aarch64 # TestConstructUtils::test_concatenate_int32_overflow is flaky on aarch64 export PYTEST_ADDOPTS="-k '$SKIP_ALL and \ not test_concatenate_int32_overflow'" -TIMEOUT=1000 %endif %ifarch s390x # https://bugzilla.redhat.com/show_bug.cgi?id=1959353 export PYTEST_ADDOPTS="-k '$SKIP_ALL and \ not test_distance_transform_cdt05'" -TIMEOUT=1000 %endif %ifarch x86_64 @@ -269,7 +260,7 @@ not test_svdp'" %endif pushd %{buildroot}/%{python3_sitearch} -%{pytest} --timeout=${TIMEOUT} scipy %{?!rhel:--numprocesses=auto} +%{pytest} scipy %{?!rhel:--numprocesses=auto} # Remove test remnants rm -rf gram{A,B} rm -rf .pytest_cache From 7d8ddcb20c278af0a26d1519a0fa8e9fdc225eb9 Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Feb 02 2024 18:51:43 +0000 Subject: [PATCH 4/4] Use inline python mini script instead of tomcli --- diff --git a/scipy.spec b/scipy.spec index b1bd0a2..2e4a5ee 100644 --- a/scipy.spec +++ b/scipy.spec @@ -67,7 +67,6 @@ Patch: https://github.com/scipy/scipy/pull/19443.patch BuildRequires: %{blaslib}-devel BuildRequires: gcc-gfortran, gcc-c++ -BuildRequires: tomcli BuildRequires: pybind11-devel BuildRequires: python3-devel, python3-numpy-f2py @@ -189,13 +188,17 @@ sed -i "s/\('has_openmemstream', \)'0'/\1'1'/" scipy/_lib/meson.build # static deps from pyproject.toml to a file, and use that with %%pyproject_buildrequires. # # See https://github.com/mesonbuild/meson-python/issues/236 for more discussion. -tomcli-get pyproject.toml -F newline-list \ - project.dependencies > _install-requirements.txt -# Do the same for test dependencies -tomcli-get pyproject.toml -F newline-list \ - project.optional-dependencies.test > _test-requirements.txt +# This could use tomcli, but we want to avoid pulling extra dependencies into ELN/RHEL. +python3 -c ' +import tomllib +from pathlib import Path +with open("pyproject.toml", "rb") as fp: + data = tomllib.load(fp) +Path("_install-requirements.txt").write_text("\n".join(data["project"]["dependencies"])) +Path("_test-requirements.txt").write_text("\n".join(data["project"]["optional-dependencies"]["test"])) +' %generate_buildrequires %pyproject_buildrequires -R _install-requirements.txt _test-requirements.txt