diff options
Diffstat (limited to 'dev-python/numpy')
| -rw-r--r-- | dev-python/numpy/Manifest | 3 | ||||
| -rw-r--r-- | dev-python/numpy/files/numpy-2.2.5-py314.patch | 298 | ||||
| -rw-r--r-- | dev-python/numpy/files/numpy-2.2.6-gcc16.patch | 14 | ||||
| -rw-r--r-- | dev-python/numpy/numpy-2.5.4.ebuild (renamed from dev-python/numpy/numpy-2.2.6.ebuild) | 200 |
4 files changed, 164 insertions, 351 deletions
diff --git a/dev-python/numpy/Manifest b/dev-python/numpy/Manifest index e1384911dfd6..f3959ac23b34 100644 --- a/dev-python/numpy/Manifest +++ b/dev-python/numpy/Manifest @@ -1,4 +1,3 @@ -DIST numpy-2.2.6.tar.gz 20276440 BLAKE2B 597ebbc72b2b3901bba4e0946f4f63ff13baf3b04d2f44d6e1ce8d05112f5d7191cb2e2f80e20006f0bc57a5a3f395fcc6003d9593e41b057394c12ad44f69f7 SHA512 00c82476c6cc8e68c4cd3210896172d91bdb52a46676931d173a3bbd772b29cebc8e819dfbbaf621eba9225fff3fa3f81426fe864d8812de4ff2975e7ac5c338 DIST numpy-2.4.6.tar.gz 20735807 BLAKE2B 8866cd9117365797a377278f0002930f0cae264bddbc9d0d7943907b6d54c80d7b0c7cc81263bfed0310e60754693c66d461ed7230ce457c30d9b6d3e50b27e7 SHA512 6e78c61a54bb89e202b0365440cef8f5dc948ac94eb39dfcd5af56a1ddce96ba8c7b4cd9b9c474be5f7642e7ec56cdc8eb238eb1871238911b94f9a90e2720ca DIST numpy-2.4.6.tar.gz.provenance 9880 BLAKE2B ecfe5e7b5d53ac975d3ff69b3ea463be4495f7759b63a92a455be8c29b66931707c4ca8dc0fa8296ced2182246738c935814932d31649a624fbfb06ceaafb76c SHA512 724b0cc27b8120b62ef1aae8c8ed673cd2bf4c430ddddf56ff1550f9d80ecfbc499f3df4c0a3370fecf19691eb3057e48057bd10d4d25a875a1f2f6a512e5c2f DIST numpy-2.5.1.tar.gz 20755553 BLAKE2B be71d9f5c615cbc6b59fe5ed8a1c346be654a813f811807a275dff371dd56279979dce6f2218c5d195ae17657994644a44a9afb2e9a1466e14404a9f64bedefb SHA512 cbb1f844bc7feb845de24c4951bc378b0d4d96a1ac7eaa9fe1f615aaf470f33c81e94fddbbd83f555b7d9248b5db60b641a4582b9f39b0f6d906f7a8acdd7add @@ -7,3 +6,5 @@ DIST numpy-2.5.2.tar.gz 20773161 BLAKE2B 53f815c3bff9d5b9efc0dcda2ec5c4ce397402c DIST numpy-2.5.2.tar.gz.provenance 10057 BLAKE2B f60196c4ff61d3a0016024a85bcf2b407a205fad007354d141b73e949fb3d3822697e4973216a30f83a17e551eb1374836224231780e5fbb3c0b714501f7d745 SHA512 1eb508fe4b3f5f1a3e68435efa2c87e81c25cf8bf77cca4a956909733abd16f5dbef9e7ae001db82abe9bacf467d7d1b0b1e92868c063cd8edaf1db6537f1daf DIST numpy-2.5.3.tar.gz 20791231 BLAKE2B 37551f1d0066f06a402f6caf1a5c07a7aad255e7bf53402550fb08c19bd52af82e6cd3e4c547e87c2f431d9c803d2db1b0760a958bc1a0afeb0565b8c9393d72 SHA512 667ba01fc13669a8150b0b4797e6c6b953d27ce37d71f8dec02acd7050669fe9a461efc63e162d9732bc297deb3e5587675e40adbac923949da257a255f9b15b DIST numpy-2.5.3.tar.gz.provenance 9824 BLAKE2B 1c8ad74e3558242cce309a5540a058397f5dfddee80e7cb0657eb6f34baf4055b9831b82fa139dcebd6f7649a847092707aa0cac1270069652ef438e4f5ea04f SHA512 0d3ad6886fd357fbf4b53b20ea2463ddac3957b95d0aed7e36b4100ff4d0bed0c0372697b37aab00859fc42823700e4badbde3cb3ddc7223393ed98826090122 +DIST numpy-2.5.4.tar.gz 20866315 BLAKE2B 0946c54c70141f847c9d3987097c9d306a44050ca3b3231d9c51aeeb3f3f9bafa058b75515927606bb214d19fd0e05f70d77b64e462d19d2398b9aa7b380ae98 SHA512 571fe3c6dbdf3ee6481965fd463b0cb661f96260db1014e230fa45cdd6a4825fe236b29b415b94f48501922899e0283ad04762fa095ac8038bbd9db3bc652440 +DIST numpy-2.5.4.tar.gz.provenance 10029 BLAKE2B 4434cb23a4ebd48180dc667632a780a2cd578745545f2beec7a53f566d1c6d3e59f5b91b49528bf8dce0be6c86f54978874ed242256ba8fd116738035a7c17d3 SHA512 13193c227c9aa1803806e05d64f15c0e88e2f358f91c33a930940435414c7ecbfd50ca0618c16b8c706696dabd733532ae75a72cf2e9cc23696cff8a9800b147 diff --git a/dev-python/numpy/files/numpy-2.2.5-py314.patch b/dev-python/numpy/files/numpy-2.2.5-py314.patch deleted file mode 100644 index bdb0762e733c..000000000000 --- a/dev-python/numpy/files/numpy-2.2.5-py314.patch +++ /dev/null @@ -1,298 +0,0 @@ -From 57084ae28ed14f3bba89ab51104dd5521b7edb64 Mon Sep 17 00:00:00 2001 -From: Nathan Goldbaum <nathan.goldbaum@gmail.com> -Date: Tue, 22 Apr 2025 15:31:14 -0600 -Subject: [PATCH] ENH: Support Python 3.14 (#28748) - -* MNT: use CPython internal APIs to hotfix temporary elision on 3.14 - -This is based on a diff from Sam Gross, see -https://github.com/numpy/numpy/issues/28681#issuecomment-2810661401 - -* TST: use refcount deltas in tests that hardcode refcounts - -* TST: one more refcount test change I don't understand - -* TST: fix ResourceWarning - -* CI: add 3.14 and 3.14t linux CI - -* CI: try with setup-python instead of setup-uv - -* CI: fix 3.14t-dev cython install - -* Update numpy/_core/src/multiarray/temp_elide.c - -Co-authored-by: Ross Barnowski <rossbar@caltech.edu> - -* CI: drop linux 3.13t smoke test - -* TST: move refcount check inside with block - -* MNT: guard against a possible future PyPy 3.14 - ---------- - -Co-authored-by: Ross Barnowski <rossbar@caltech.edu> - -MNT: add support for 3.14.0b1 ---- - numpy/_core/src/multiarray/temp_elide.c | 19 +++++++++-- - numpy/_core/tests/test_dlpack.py | 8 ++--- - numpy/_core/tests/test_dtype.py | 3 +- - numpy/_core/tests/test_indexing.py | 6 ++-- - numpy/_core/tests/test_item_selection.py | 8 +++-- - numpy/_core/tests/test_multiarray.py | 4 ++- - numpy/_core/tests/test_nditer.py | 7 ++-- - numpy/_core/tests/test_regression.py | 43 +++++++++++------------- - numpy/_core/tests/test_umath.py | 4 +-- - 9 files changed, 62 insertions(+), 40 deletions(-) - -diff --git a/numpy/_core/src/multiarray/temp_elide.c b/numpy/_core/src/multiarray/temp_elide.c -index 662a2fa52b..9236476c42 100644 ---- a/numpy/_core/src/multiarray/temp_elide.c -+++ b/numpy/_core/src/multiarray/temp_elide.c -@@ -109,6 +109,19 @@ find_addr(void * addresses[], npy_intp naddr, void * addr) - return 0; - } - -+static int -+check_unique_temporary(PyObject *lhs) -+{ -+#if PY_VERSION_HEX == 0x030E00A7 && !defined(PYPY_VERSION) -+#error "NumPy is broken on CPython 3.14.0a7, please update to a newer version" -+#elif PY_VERSION_HEX >= 0x030E00B1 && !defined(PYPY_VERSION) -+ // see https://github.com/python/cpython/issues/133164 -+ return PyUnstable_Object_IsUniqueReferencedTemporary(lhs); -+#else -+ return 1; -+#endif -+} -+ - static int - check_callers(int * cannot) - { -@@ -295,7 +308,8 @@ can_elide_temp(PyObject *olhs, PyObject *orhs, int *cannot) - !PyArray_CHKFLAGS(alhs, NPY_ARRAY_OWNDATA) || - !PyArray_ISWRITEABLE(alhs) || - PyArray_CHKFLAGS(alhs, NPY_ARRAY_WRITEBACKIFCOPY) || -- PyArray_NBYTES(alhs) < NPY_MIN_ELIDE_BYTES) { -+ PyArray_NBYTES(alhs) < NPY_MIN_ELIDE_BYTES || -+ !check_unique_temporary(olhs)) { - return 0; - } - if (PyArray_CheckExact(orhs) || -@@ -372,7 +386,8 @@ can_elide_temp_unary(PyArrayObject * m1) - !PyArray_ISNUMBER(m1) || - !PyArray_CHKFLAGS(m1, NPY_ARRAY_OWNDATA) || - !PyArray_ISWRITEABLE(m1) || -- PyArray_NBYTES(m1) < NPY_MIN_ELIDE_BYTES) { -+ PyArray_NBYTES(m1) < NPY_MIN_ELIDE_BYTES || -+ !check_unique_temporary((PyObject *)m1)) { - return 0; - } - if (check_callers(&cannot)) { -diff --git a/numpy/_core/tests/test_dlpack.py b/numpy/_core/tests/test_dlpack.py -index 41dd724295..d273bd798e 100644 ---- a/numpy/_core/tests/test_dlpack.py -+++ b/numpy/_core/tests/test_dlpack.py -@@ -22,9 +22,9 @@ class TestDLPack: - def test_dunder_dlpack_refcount(self, max_version): - x = np.arange(5) - y = x.__dlpack__(max_version=max_version) -- assert sys.getrefcount(x) == 3 -+ startcount = sys.getrefcount(x) - del y -- assert sys.getrefcount(x) == 2 -+ assert startcount - sys.getrefcount(x) == 1 - - def test_dunder_dlpack_stream(self): - x = np.arange(5) -@@ -58,9 +58,9 @@ def test_strides_not_multiple_of_itemsize(self): - def test_from_dlpack_refcount(self, arr): - arr = arr.copy() - y = np.from_dlpack(arr) -- assert sys.getrefcount(arr) == 3 -+ startcount = sys.getrefcount(arr) - del y -- assert sys.getrefcount(arr) == 2 -+ assert startcount - sys.getrefcount(arr) == 1 - - @pytest.mark.parametrize("dtype", [ - np.bool, -diff --git a/numpy/_core/tests/test_dtype.py b/numpy/_core/tests/test_dtype.py -index deeca5171c..759eefeb2a 100644 ---- a/numpy/_core/tests/test_dtype.py -+++ b/numpy/_core/tests/test_dtype.py -@@ -1901,9 +1901,10 @@ class mytype: - if HAS_REFCOUNT: - # Create an array and test that memory gets cleaned up (gh-25949) - o = object() -+ startcount = sys.getrefcount(o) - a = np.array([o], dtype=dt) - del a -- assert sys.getrefcount(o) == 2 -+ assert sys.getrefcount(o) == startcount - - def test_custom_structured_dtype_errors(self): - class mytype: -diff --git a/numpy/_core/tests/test_indexing.py b/numpy/_core/tests/test_indexing.py -index f393c401cd..bb757cdf7e 100644 ---- a/numpy/_core/tests/test_indexing.py -+++ b/numpy/_core/tests/test_indexing.py -@@ -1174,6 +1174,8 @@ def _compare_index_result(self, arr, index, mimic_get, no_copy): - """Compare mimicked result to indexing result. - """ - arr = arr.copy() -+ if HAS_REFCOUNT: -+ startcount = sys.getrefcount(arr) - indexed_arr = arr[index] - assert_array_equal(indexed_arr, mimic_get) - # Check if we got a view, unless its a 0-sized or 0-d array. -@@ -1184,9 +1186,9 @@ def _compare_index_result(self, arr, index, mimic_get, no_copy): - if HAS_REFCOUNT: - if no_copy: - # refcount increases by one: -- assert_equal(sys.getrefcount(arr), 3) -+ assert_equal(sys.getrefcount(arr), startcount + 1) - else: -- assert_equal(sys.getrefcount(arr), 2) -+ assert_equal(sys.getrefcount(arr), startcount) - - # Test non-broadcast setitem: - b = arr.copy() -diff --git a/numpy/_core/tests/test_item_selection.py b/numpy/_core/tests/test_item_selection.py -index 5660ef583e..839127ecdb 100644 ---- a/numpy/_core/tests/test_item_selection.py -+++ b/numpy/_core/tests/test_item_selection.py -@@ -50,19 +50,23 @@ def test_simple(self): - - def test_refcounting(self): - objects = [object() for i in range(10)] -+ if HAS_REFCOUNT: -+ orig_rcs = [sys.getrefcount(o) for o in objects] - for mode in ('raise', 'clip', 'wrap'): - a = np.array(objects) - b = np.array([2, 2, 4, 5, 3, 5]) - a.take(b, out=a[:6], mode=mode) - del a - if HAS_REFCOUNT: -- assert_(all(sys.getrefcount(o) == 3 for o in objects)) -+ assert_(all(sys.getrefcount(o) == rc + 1 -+ for o, rc in zip(objects, orig_rcs))) - # not contiguous, example: - a = np.array(objects * 2)[::2] - a.take(b, out=a[:6], mode=mode) - del a - if HAS_REFCOUNT: -- assert_(all(sys.getrefcount(o) == 3 for o in objects)) -+ assert_(all(sys.getrefcount(o) == rc + 1 -+ for o, rc in zip(objects, orig_rcs))) - - def test_unicode_mode(self): - d = np.arange(10) -diff --git a/numpy/_core/tests/test_multiarray.py b/numpy/_core/tests/test_multiarray.py -index 87508732d8..3f26578c85 100644 ---- a/numpy/_core/tests/test_multiarray.py -+++ b/numpy/_core/tests/test_multiarray.py -@@ -6779,10 +6779,12 @@ def test_dot_3args(self): - v = np.random.random_sample((16, 32)) - - r = np.empty((1024, 32)) -+ if HAS_REFCOUNT: -+ orig_refcount = sys.getrefcount(r) - for i in range(12): - dot(f, v, r) - if HAS_REFCOUNT: -- assert_equal(sys.getrefcount(r), 2) -+ assert_equal(sys.getrefcount(r), orig_refcount) - r2 = dot(f, v, out=None) - assert_array_equal(r2, r) - assert_(r is dot(f, v, out=r)) -diff --git a/numpy/_core/tests/test_nditer.py b/numpy/_core/tests/test_nditer.py -index b0d911f24f..d6a9e42ae3 100644 ---- a/numpy/_core/tests/test_nditer.py -+++ b/numpy/_core/tests/test_nditer.py -@@ -1126,9 +1126,10 @@ def test_iter_object_arrays_conversions(): - rc = sys.getrefcount(ob) - for x in i: - x[...] += 1 -- if HAS_REFCOUNT: -- assert_(sys.getrefcount(ob) == rc-1) -- assert_equal(a, np.arange(6)+98172489) -+ if HAS_REFCOUNT: -+ newrc = sys.getrefcount(ob) -+ assert_(newrc == rc - 1) -+ assert_equal(a, np.arange(6) + 98172489) - - def test_iter_common_dtype(): - # Check that the iterator finds a common data type correctly -diff --git a/numpy/_core/tests/test_regression.py b/numpy/_core/tests/test_regression.py -index 851ce324d7..eeb640659e 100644 ---- a/numpy/_core/tests/test_regression.py -+++ b/numpy/_core/tests/test_regression.py -@@ -1586,29 +1586,26 @@ def test_take_refcount(self): - def test_fromfile_tofile_seeks(self): - # On Python 3, tofile/fromfile used to get (#1610) the Python - # file handle out of sync -- f0 = tempfile.NamedTemporaryFile() -- f = f0.file -- f.write(np.arange(255, dtype='u1').tobytes()) -- -- f.seek(20) -- ret = np.fromfile(f, count=4, dtype='u1') -- assert_equal(ret, np.array([20, 21, 22, 23], dtype='u1')) -- assert_equal(f.tell(), 24) -- -- f.seek(40) -- np.array([1, 2, 3], dtype='u1').tofile(f) -- assert_equal(f.tell(), 43) -- -- f.seek(40) -- data = f.read(3) -- assert_equal(data, b"\x01\x02\x03") -- -- f.seek(80) -- f.read(4) -- data = np.fromfile(f, dtype='u1', count=4) -- assert_equal(data, np.array([84, 85, 86, 87], dtype='u1')) -- -- f.close() -+ with tempfile.NamedTemporaryFile() as f: -+ f.write(np.arange(255, dtype='u1').tobytes()) -+ -+ f.seek(20) -+ ret = np.fromfile(f, count=4, dtype='u1') -+ assert_equal(ret, np.array([20, 21, 22, 23], dtype='u1')) -+ assert_equal(f.tell(), 24) -+ -+ f.seek(40) -+ np.array([1, 2, 3], dtype='u1').tofile(f) -+ assert_equal(f.tell(), 43) -+ -+ f.seek(40) -+ data = f.read(3) -+ assert_equal(data, b"\x01\x02\x03") -+ -+ f.seek(80) -+ f.read(4) -+ data = np.fromfile(f, dtype='u1', count=4) -+ assert_equal(data, np.array([84, 85, 86, 87], dtype='u1')) - - def test_complex_scalar_warning(self): - for tp in [np.csingle, np.cdouble, np.clongdouble]: -diff --git a/numpy/_core/tests/test_umath.py b/numpy/_core/tests/test_umath.py -index 4d56c785d5..d432e33412 100644 ---- a/numpy/_core/tests/test_umath.py -+++ b/numpy/_core/tests/test_umath.py -@@ -269,9 +269,9 @@ class ArrSubclass(np.ndarray): - pass - - arr = np.arange(10).view(ArrSubclass) -- -+ orig_refcount = sys.getrefcount(arr) - arr *= 1 -- assert sys.getrefcount(arr) == 2 -+ assert sys.getrefcount(arr) == orig_refcount - - - class TestComparisons: diff --git a/dev-python/numpy/files/numpy-2.2.6-gcc16.patch b/dev-python/numpy/files/numpy-2.2.6-gcc16.patch deleted file mode 100644 index a297551ded05..000000000000 --- a/dev-python/numpy/files/numpy-2.2.6-gcc16.patch +++ /dev/null @@ -1,14 +0,0 @@ -https://github.com/google/highway/issues/2577 -https://github.com/google/highway/commit/7cde540171a1718a9bdfa8f896d70e47eb0785d5 ---- a/numpy/_core/src/highway/hwy/ops/set_macros-inl.h -+++ b/numpy/_core/src/highway/hwy/ops/set_macros-inl.h -@@ -141,7 +141,8 @@ - #define HWY_TARGET_STR_AVX2 \ - HWY_TARGET_STR_SSE4 ",avx,avx2" HWY_TARGET_STR_BMI2_FMA HWY_TARGET_STR_F16C - --#if HWY_COMPILER_GCC_ACTUAL >= 1400 || HWY_COMPILER_CLANG >= 1800 -+#if (HWY_COMPILER_GCC_ACTUAL >= 1400 && HWY_COMPILER_GCC_ACTUAL < 1600) || \ -+ HWY_COMPILER_CLANG >= 1800 - #define HWY_TARGET_STR_AVX3_VL512 ",evex512" - #else - #define HWY_TARGET_STR_AVX3_VL512 diff --git a/dev-python/numpy/numpy-2.2.6.ebuild b/dev-python/numpy/numpy-2.5.4.ebuild index ab989c443b99..d22a019b6c54 100644 --- a/dev-python/numpy/numpy-2.2.6.ebuild +++ b/dev-python/numpy/numpy-2.5.4.ebuild @@ -1,10 +1,11 @@ -# Copyright 1999-2025 Gentoo Authors +# Copyright 1999-2026 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 DISTUTILS_EXT=1 DISTUTILS_USE_PEP517=meson-python +PYPI_VERIFY_REPO=https://github.com/numpy/numpy-release PYTHON_COMPAT=( python3_{13..14} ) PYTHON_REQ_USE="threads(+)" FORTRAN_NEEDED=lapack @@ -18,23 +19,37 @@ HOMEPAGE=" https://pypi.org/project/numpy/ " -LICENSE="BSD" +LICENSE="BSD 0BSD MIT ZLIB CC0-1.0" SLOT="0/2" -KEYWORDS="~alpha amd64 arm arm64 ~hppa ~loong ~m68k ~mips ppc ppc64 ~riscv ~s390 ~sparc x86" +if [[ ${PV} != *_rc* ]]; then + KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86" +fi # +lapack because the internal fallbacks are pretty slow. Building without blas # is barely supported anyway, see bug #914358. -IUSE="big-endian +lapack" +IUSE="big-endian +cpudetection index64 +lapack" + +# upstream-flag[:gentoo-flag] +ARM_FLAGS=( neon{,-fp16} vfpv4 asimd{,hp,dp,fhm} sve ) +PPC_FLAGS=( vsx vsx2 vsx3 vsx4 ) +X86_FLAGS=( + avx2 avx512{bw,dq,vl} avx512_{bf16,bitalg,fp16,vbmi2} sse4_2 +) +IUSE+=" + ${ARM_FLAGS[*]/#/cpu_flags_arm_} + ${PPC_FLAGS[*]/#/cpu_flags_ppc_} + ${X86_FLAGS[*]/#/cpu_flags_x86_} +" RDEPEND=" lapack? ( - >=virtual/cblas-3.8 - >=virtual/lapack-3.8 + >=virtual/cblas-3.8[index64(-)?] + >=virtual/lapack-3.8[index64(-)?] ) " BDEPEND=" ${RDEPEND} - >=dev-build/meson-1.1.0 - >=dev-python/cython-3.0.6[${PYTHON_USEDEP}] + >=dev-build/meson-1.5.2 + >=dev-python/cython-3.1.0[${PYTHON_USEDEP}] lapack? ( virtual/pkgconfig ) @@ -43,9 +58,6 @@ BDEPEND=" >=dev-python/cffi-1.14.0[${PYTHON_USEDEP}] ' 'python*') dev-python/charset-normalizer[${PYTHON_USEDEP}] - >=dev-python/hypothesis-5.8.0[${PYTHON_USEDEP}] - dev-python/pytest-rerunfailures[${PYTHON_USEDEP}] - dev-python/pytest-timeout[${PYTHON_USEDEP}] >=dev-python/pytz-2019.3[${PYTHON_USEDEP}] ) " @@ -55,52 +67,151 @@ QA_CONFIG_IMPL_DECL_SKIP=( vrndq_f32 ) +EPYTEST_PLUGINS=( hypothesis pytest-timeout ) EPYTEST_XDIST=1 distutils_enable_tests pytest -python_prepare_all() { - local PATCHES=( - # https://github.com/numpy/numpy/pull/28748 - # https://github.com/numpy/numpy/pull/28928 - "${FILESDIR}/${PN}-2.2.5-py314.patch" - # https://github.com/google/highway/issues/2577 - # github.com/google/highway/commit/7cde540171a1718a9bdfa8f896d70e47eb0785d5 - "${FILESDIR}/${PN}-2.2.6-gcc16.patch" - ) - - # bug #922457 - filter-lto - # https://github.com/numpy/numpy/issues/25004 - append-flags -fno-strict-aliasing - - distutils-r1_python_prepare_all +has_all_x86() { + local flag + for flag; do + if ! use "cpu_flags_x86_${flag}"; then + return 1 + fi + done + return 0 } python_configure_all() { + local cpu_baseline=() + local map flag + case ${ARCH} in + arm) + # every flag implies the previous one + for map in NEON:neon NEON_FP16:neon-fp16 NEON_VFPV4:vfpv4; do + if ! use "cpu_flags_arm_${map#*:}"; then + break + fi + cpu_baseline+=( "${map%:*}" ) + done + ;& + arm64) + # on 32-bit ARM, ASIMD implies all NEON* flags + # on 64-bit ARM, they are all linked together + if use arm64 || + [[ ${cpu_baseline[@]} && ${cpu_baseline[-1]} == NEON_VFPV4 ]] + then + cpu_baseline+=( $(usev cpu_flags_arm_asimd ASIMD) ) + fi + + # these two imply ASIMD + if [[ ${cpu_baseline[@]} && ${cpu_baseline[-1]} == ASIMD ]]; then + for flag in dp hp; do + cpu_baseline+=( + $(usev "cpu_flags_arm_asimd${flag}" "ASIMD${flag^^}") + ) + done + fi + + # these two imply ASIMDHP + if [[ ${cpu_baseline[@]} && ${cpu_baseline[-1]} == ASIMDHP ]]; then + for flag in asimdfhm sve; do + cpu_baseline+=( + $(usev "cpu_flags_arm_${flag}" "${flag^^}") + ) + done + fi + ;; + ppc64) + # every flag implies the previous one + for flag in '' 2 3 4; do + if ! use "cpu_flags_ppc_vsx${flag}"; then + break + fi + cpu_baseline+=( "VSX${flag}" ) + done + ;; + amd64|x86) + # upstream combines multiple instructions into sets + local mapping=( + # for these, we just check the newest instruction set, + # since all earlier instruction sets imply it + "X86_V2=sse4_2" + "X86_V3=avx2" + # from here on, we check all features that were added + # in the lowest CPU supporting them all + # https://en.wikipedia.org/wiki/AVX-512 + "X86_V4=avx512bw avx512dq avx512vl" + "AVX512_ICL=avx512_vbmi2 avx512_bitalg" + "AVX512_SPR=avx512_bf16 avx512_fp16" + ) + + local m + for m in "${mapping[@]}"; do + local feature=${m%=*} + local sets=${m#*=} + + if has_all_x86 ${sets}; then + einfo "${feature} enabled: all of ${sets} enabled" + cpu_baseline+=( "${feature}" ) + else + einfo "${feature} disabled: not all of ${sets} enabled" + break + fi + done + ;; + *) + cpu_baseline=MIN + ;; + esac + DISTUTILS_ARGS=( -Dallow-noblas=$(usex !lapack true false) - -Dblas=$(usev lapack cblas) - -Dlapack=$(usev lapack lapack) - # TODO: cpu-* options + -Duse-ilp64=$(usex index64 true false) + -Dblas=$(usev lapack $(usex index64 cblas64 cblas)) + -Dlapack=$(usev lapack $(usex index64 lapack64 lapack)) + -Dcpu-baseline="${cpu_baseline[*]}" + -Dcpu-baseline-detect=disabled + -Dcpu-dispatch="$(usev cpudetection MAX)" ) + + # bug #922457 + filter-lto + # https://github.com/numpy/numpy/issues/25004 + append-flags -fno-strict-aliasing } python_test() { + # We run tests in parallel, so avoid having n^2 threads in lapack + # tests. + local -x BLIS_NUM_THREADS=1 + local -x MKL_NUM_THREADS=1 + local -x OMP_NUM_THREADS=1 + local -x OPENBLAS_NUM_THREADS=1 + + # don't run tests that require more than 2 GiB of RAM (per process) + local -x NPY_AVAILABLE_MEM="2 GiB" + local EPYTEST_DESELECT=( # Very disk-and-memory-hungry - numpy/lib/tests/test_io.py::TestSaveTxt::test_large_zip numpy/lib/tests/test_io.py::TestSavezLoad::test_closing_fid numpy/lib/tests/test_io.py::TestSavezLoad::test_closing_zipfile_after_load # Precision problems numpy/_core/tests/test_umath_accuracy.py::TestAccuracy::test_validate_transcendentals - # Runs the whole test suite recursively, that's just crazy - numpy/core/tests/test_mem_policy.py::test_new_policy - numpy/typing/tests/test_typing.py - # Uses huge amount of memory - numpy/core/tests/test_mem_overlap.py + + # Flaky, reruns don't help + numpy/f2py/tests/test_crackfortran.py + numpy/f2py/tests/test_data.py::TestData{,F77}::test_crackedlines + numpy/f2py/tests/test_f2py2e.py::test_gen_pyf + numpy/f2py/tests/test_f2py2e.py::test_gh22819_cli + + # Broken by new setuptools + numpy/distutils/tests/test_fcompiler.py + numpy/distutils/tests/test_fcompiler_gnu.py + numpy/distutils/tests/test_fcompiler_intel.py + numpy/distutils/tests/test_fcompiler_nagfor.py ) if [[ $(uname -m) == armv8l ]]; then @@ -194,9 +305,22 @@ python_test() { ) fi - local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 + case ${EPYTHON} in + pypy3.11) + EPYTEST_DESELECT+=( + numpy/_core/tests/test_regression.py::TestRegression::test_buffer_hashlib + numpy/random/tests/test_generator_mt19937.py::TestIntegers::test_repeatability + numpy/random/tests/test_generator_mt19937.py::TestRandomDist::test_choice_large_sample + numpy/random/tests/test_generator_mt19937.py::test_jumped + numpy/random/tests/test_random.py::TestRandint::test_repeatability + numpy/random/tests/test_randomstate.py::TestRandint::test_repeatability + numpy/random/tests/test_randomstate.py::test_integer_repeat + ) + ;; + esac + cd "${BUILD_DIR}/install$(python_get_sitedir)" || die - epytest -p rerunfailures --reruns=5 + epytest } python_install_all() { |
