From 705a372c7e4a967ef6216309d3c66f788bfef33e49b0228b7d351671e3e7f333 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Sat, 15 Jan 2022 13:04:10 +0000 Subject: [PATCH] Accepting request 946603 from home:bnavigator:branches:devel:languages:python:numeric - Update to 0.55.0 - Add numba-pr7748-random32bitwidth.patch -- gh#numba/numba#7748 Next try. Let's see if i586 also builds server-side. OBS-URL: https://build.opensuse.org/request/show/946603 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-numba?expand=0&rev=51 --- numba-0.54.1.tar.gz | 3 - numba-0.55.0.tar.gz | 3 + numba-pr7483-numpy1_21.patch | 242 ---------------------------- numba-pr7748-random32bitwidth.patch | 58 +++++++ python-numba.changes | 70 ++++++++ python-numba.spec | 39 ++--- 6 files changed, 148 insertions(+), 267 deletions(-) delete mode 100644 numba-0.54.1.tar.gz create mode 100644 numba-0.55.0.tar.gz delete mode 100644 numba-pr7483-numpy1_21.patch create mode 100644 numba-pr7748-random32bitwidth.patch diff --git a/numba-0.54.1.tar.gz b/numba-0.54.1.tar.gz deleted file mode 100644 index 4fb5e23..0000000 --- a/numba-0.54.1.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f9dfc803c864edcc2381219b800abf366793400aea55e26d4d5b7d953e14f43f -size 2232957 diff --git a/numba-0.55.0.tar.gz b/numba-0.55.0.tar.gz new file mode 100644 index 0000000..1789e12 --- /dev/null +++ b/numba-0.55.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b221ebd997662a1dcb77e4f09140e022fbfe7577ad0781fc2e0214135dba6cbd +size 2300580 diff --git a/numba-pr7483-numpy1_21.patch b/numba-pr7483-numpy1_21.patch deleted file mode 100644 index e24fcbf..0000000 --- a/numba-pr7483-numpy1_21.patch +++ /dev/null @@ -1,242 +0,0 @@ -From 3a2c5042fa85ac9b8fe398d605d6d373d27f42bb Mon Sep 17 00:00:00 2001 -From: Stuart Archibald -Date: Thu, 14 Oct 2021 09:35:24 +0100 -Subject: [PATCH 1/7] Update build matrix for NumPy 1.21 as per NEP-029. - -As title. ---- - azure-pipelines.yml | 68 ++++++++++++++-------------- - buildscripts/azure/azure-windows.yml | 8 ++-- - 2 files changed, 38 insertions(+), 38 deletions(-) - -Index: numba-0.54.1/setup.py -=================================================================== ---- numba-0.54.1.orig/setup.py -+++ numba-0.54.1/setup.py -@@ -22,8 +22,7 @@ except ImportError: - min_python_version = "3.7" - max_python_version = "3.10" # exclusive - min_numpy_build_version = "1.11" --min_numpy_run_version = "1.17" --max_numpy_run_version = "1.21" -+min_numpy_run_version = "1.18" - min_llvmlite_version = "0.37.0rc1" - max_llvmlite_version = "0.38" - -@@ -360,7 +359,7 @@ packages = find_packages(include=["numba - build_requires = ['numpy >={}'.format(min_numpy_build_version)] - install_requires = [ - 'llvmlite >={},<{}'.format(min_llvmlite_version, max_llvmlite_version), -- 'numpy >={},<{}'.format(min_numpy_run_version, max_numpy_run_version), -+ 'numpy >={}'.format(min_numpy_run_version), - 'setuptools', - ] - -Index: numba-0.54.1/numba/__init__.py -=================================================================== ---- numba-0.54.1.orig/numba/__init__.py -+++ numba-0.54.1/numba/__init__.py -@@ -137,10 +137,8 @@ def _ensure_critical_deps(): - if PYVERSION < (3, 7): - raise ImportError("Numba needs Python 3.7 or greater") - -- if numpy_version < (1, 17): -- raise ImportError("Numba needs NumPy 1.17 or greater") -- elif numpy_version > (1, 20): -- raise ImportError("Numba needs NumPy 1.20 or less") -+ if numpy_version < (1, 18): -+ raise ImportError("Numba needs NumPy 1.18 or greater") - - try: - import scipy -Index: numba-0.54.1/README.rst -=================================================================== ---- numba-0.54.1.orig/README.rst -+++ numba-0.54.1/README.rst -@@ -50,7 +50,7 @@ Dependencies - - * Python versions: 3.7-3.9 - * llvmlite 0.37.* --* NumPy >=1.17,<1.21 (can build with 1.11 for ABI compatibility). -+* NumPy >=1.18 (can build with 1.11 for ABI compatibility). - - Optionally: - -Index: numba-0.54.1/docs/source/user/5minguide.rst -=================================================================== ---- numba-0.54.1.orig/docs/source/user/5minguide.rst -+++ numba-0.54.1/docs/source/user/5minguide.rst -@@ -18,7 +18,7 @@ Out of the box Numba works with the foll - support on M1/Arm64. - * GPUs: Nvidia CUDA. - * CPython --* NumPy 1.17 - latest -+* NumPy 1.18 - latest - - How do I get it? - ---------------- -Index: numba-0.54.1/numba/np/ufunc/_internal.c -=================================================================== ---- numba-0.54.1.orig/numba/np/ufunc/_internal.c -+++ numba-0.54.1/numba/np/ufunc/_internal.c -@@ -276,6 +276,7 @@ static PyMemberDef dufunc_members[] = { - */ - - static struct _ufunc_dispatch { -+ /* Note that the following may also hold `_PyCFunctionFastWithKeywords` */ - PyCFunctionWithKeywords ufunc_reduce; - PyCFunctionWithKeywords ufunc_accumulate; - PyCFunctionWithKeywords ufunc_reduceat; -@@ -286,7 +287,7 @@ static struct _ufunc_dispatch { - } ufunc_dispatch; - - static int --init_ufunc_dispatch(void) -+init_ufunc_dispatch(int *numpy_uses_fastcall) - { - int result = 0; - PyMethodDef * crnt = PyUFunc_Type.tp_methods; -@@ -329,6 +330,16 @@ init_ufunc_dispatch(void) - result = -1; /* Unknown method */ - } - if (result < 0) break; -+ -+ /* Check whether NumPy uses fastcall (ufunc.at never uses it) */ -+ if (strncmp(crnt_name, "at", 3) != 0) { -+ if (*numpy_uses_fastcall == -1) { -+ *numpy_uses_fastcall = crnt->ml_flags & METH_FASTCALL; -+ } -+ else if (*numpy_uses_fastcall != (crnt->ml_flags & METH_FASTCALL)) { -+ return -1; -+ } -+ } - } - if (result == 0) { - /* Sanity check. */ -@@ -344,6 +355,7 @@ init_ufunc_dispatch(void) - return result; - } - -+ - static PyObject * - dufunc_reduce(PyDUFuncObject * self, PyObject * args, PyObject *kws) - { -@@ -368,6 +380,47 @@ dufunc_outer(PyDUFuncObject * self, PyOb - return ufunc_dispatch.ufunc_outer((PyObject*)self->ufunc, args, kws); - } - -+ -+/* -+ * The following are the vectorcall versions of the above, since NumPy -+ * uses the FASTCALL/Vectorcall protocol starting with version 1.21. -+ * The only NumPy versions supporting vectorcall use Python 3.7 or higher. -+ */ -+static PyObject * -+dufunc_reduce_fast(PyDUFuncObject * self, -+ PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames) -+{ -+ return ((_PyCFunctionFastWithKeywords)ufunc_dispatch.ufunc_reduce)( -+ (PyObject*)self->ufunc, args, len_args, kwnames); -+} -+ -+static PyObject * -+dufunc_reduceat_fast(PyDUFuncObject * self, -+ PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames) -+{ -+ return ((_PyCFunctionFastWithKeywords)ufunc_dispatch.ufunc_reduceat)( -+ (PyObject*)self->ufunc, args, len_args, kwnames); -+} -+ -+ -+static PyObject * -+dufunc_accumulate_fast(PyDUFuncObject * self, -+ PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames) -+{ -+ return ((_PyCFunctionFastWithKeywords)ufunc_dispatch.ufunc_accumulate)( -+ (PyObject*)self->ufunc, args, len_args, kwnames); -+} -+ -+ -+static PyObject * -+dufunc_outer_fast(PyDUFuncObject * self, -+ PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames) -+{ -+ return ((_PyCFunctionFastWithKeywords)ufunc_dispatch.ufunc_outer)( -+ (PyObject*)self->ufunc, args, len_args, kwnames); -+} -+ -+ - #if NPY_API_VERSION >= 0x00000008 - static PyObject * - dufunc_at(PyDUFuncObject * self, PyObject * args) -@@ -568,6 +621,41 @@ static struct PyMethodDef dufunc_methods - {NULL, NULL, 0, NULL} /* sentinel */ - }; - -+ -+/* -+ * If Python is new enough, NumPy may use fastcall. In that case we have to -+ * also use fastcall for simplicity and speed. -+ */ -+static struct PyMethodDef dufunc_methods_fast[] = { -+ {"reduce", -+ (PyCFunction)dufunc_reduce_fast, -+ METH_FASTCALL | METH_KEYWORDS, NULL }, -+ {"accumulate", -+ (PyCFunction)dufunc_accumulate_fast, -+ METH_FASTCALL | METH_KEYWORDS, NULL }, -+ {"reduceat", -+ (PyCFunction)dufunc_reduceat_fast, -+ METH_FASTCALL | METH_KEYWORDS, NULL }, -+ {"outer", -+ (PyCFunction)dufunc_outer_fast, -+ METH_FASTCALL | METH_KEYWORDS, NULL}, -+#if NPY_API_VERSION >= 0x00000008 -+ {"at", -+ (PyCFunction)dufunc_at, -+ METH_VARARGS, NULL}, -+#endif -+ {"_compile_for_args", -+ (PyCFunction)dufunc__compile_for_args, -+ METH_VARARGS | METH_KEYWORDS, -+ "Abstract method: subclasses should overload _compile_for_args() to compile the ufunc at the given arguments' types."}, -+ {"_add_loop", -+ (PyCFunction)dufunc__add_loop, -+ METH_VARARGS, -+ NULL}, -+ {NULL, NULL, 0, NULL} /* sentinel */ -+}; -+ -+ - static PyObject * - dufunc_getfrozen(PyDUFuncObject * self, void * closure) - { -@@ -681,8 +769,15 @@ MOD_INIT(_internal) - return MOD_ERROR_VAL; - - PyDUFunc_Type.tp_new = PyType_GenericNew; -- if (init_ufunc_dispatch() <= 0) -+ -+ int numpy_uses_fastcall = -1; -+ if (init_ufunc_dispatch(&numpy_uses_fastcall) <= 0) - return MOD_ERROR_VAL; -+ -+ if (numpy_uses_fastcall) { -+ PyDUFunc_Type.tp_methods = dufunc_methods_fast; -+ } -+ - if (PyType_Ready(&PyDUFunc_Type) < 0) - return MOD_ERROR_VAL; - Py_INCREF(&PyDUFunc_Type); -Index: numba-0.54.1/numba/tests/test_array_reductions.py -=================================================================== ---- numba-0.54.1.orig/numba/tests/test_array_reductions.py -+++ numba-0.54.1/numba/tests/test_array_reductions.py -@@ -725,6 +725,7 @@ class TestArrayReductions(MemoryLeakMixi - self.check_npdatetime(array_argmax) - self.check_nptimedelta(array_argmax) - -+ @unittest.skip("https://github.com/numpy/numpy/issues/20376") - def test_median_npdatetime(self): - self.check_nptimedelta(array_median_global) - diff --git a/numba-pr7748-random32bitwidth.patch b/numba-pr7748-random32bitwidth.patch new file mode 100644 index 0000000..5f22766 --- /dev/null +++ b/numba-pr7748-random32bitwidth.patch @@ -0,0 +1,58 @@ +From e6df66d52152156ba8bcda64b37f4995bda72d2f Mon Sep 17 00:00:00 2001 +From: Graham Markall +Date: Fri, 14 Jan 2022 21:24:40 +0000 +Subject: [PATCH] Fix #7713: Ensure _prng_random_hash return has correct + bitwidth + +When the hash width is 32 bits, get_next_int32 needs to be used because +that returns a 32-bit integer, as opposed to get_next_int, which returns +a 64-bit integer regardless of the supplied bitwidth. + +This commit also alters the signature of _prng_random_hash to use +_Py_hash_t as the return type - it will be equal to types.intp, but the +intent should be clearer. +--- + numba/cpython/hashing.py | 21 +++++++++++++++++---- + 1 file changed, 17 insertions(+), 4 deletions(-) + +diff --git a/numba/cpython/hashing.py b/numba/cpython/hashing.py +index 5a8673b04b..227fc4e1c5 100644 +--- a/numba/cpython/hashing.py ++++ b/numba/cpython/hashing.py +@@ -18,7 +18,8 @@ + from numba.core import errors + from numba.core import types, utils + from numba.core.unsafe.bytes import grab_byte, grab_uint64_t +-from numba.cpython.randomimpl import get_state_ptr, get_next_int, const_int ++from numba.cpython.randomimpl import (const_int, get_next_int, get_next_int32, ++ get_state_ptr) + + _py38_or_later = utils.PYVERSION >= (3, 8) + _py310_or_later = utils.PYVERSION >= (3, 10) +@@ -137,11 +138,23 @@ def _prng_random_hash(tyctx): + + def impl(cgctx, builder, signature, args): + state_ptr = get_state_ptr(cgctx, builder, "internal") +- bits = const_int(types.intp.bitwidth) +- value = get_next_int(cgctx, builder, state_ptr, bits, False) ++ bits = const_int(_hash_width) ++ ++ # Why not just use get_next_int() with the correct bitwidth? ++ # get_next_int() always returns an i64, because the bitwidth it is ++ # passed may not be a compile-time constant, so it needs to allocate ++ # the largest unit of storage that may be required. Therefore, if the ++ # hash width is 32, then we need to use get_next_int32() to ensure we ++ # don't return a wider-than-expected hash, even if everything above ++ # the low 32 bits would have been zero. ++ if _hash_width == 32: ++ value = get_next_int32(cgctx, builder, state_ptr) ++ else: ++ value = get_next_int(cgctx, builder, state_ptr, bits, False) ++ + return value + +- sig = types.intp() ++ sig = _Py_hash_t() + return sig, impl + + diff --git a/python-numba.changes b/python-numba.changes index 97f81e1..e49f915 100644 --- a/python-numba.changes +++ b/python-numba.changes @@ -1,3 +1,73 @@ +------------------------------------------------------------------- +Fri Jan 14 16:55:37 UTC 2022 - Ben Greiner + +- Update to 0.55.0 + * This release includes a significant number important dependency + upgrades along with a number of new features and bug fixes. + * NOTE: Due to NumPy CVE-2021-33430 this release has bypassed the + usual release process so as to promptly provide a Numba release + that supports NumPy 1.21. A single release candidate (RC1) was + made and a few issues were reported, these are summarised as + follows and will be fixed in a subsequent 0.55.1 release. + * Known issues with this release: + - Incorrect result copying array-typed field of structured + array (#7693) + - Two issues in DebugInfo generation (#7726, #7730) + - Compilation failure for hash of floating point values on 32 + bit Windows when using Python 3.10 (#7713). + * Support for Python 3.10 + * Support for NumPy 1.21 + * The minimum supported NumPy version is raised to 1.18 for + runtime (compilation however remains compatible with NumPy + 1.11). + * Experimental support for isinstance. + * The following functions are now supported: + - np.broadcast_to + - np.float_power + - np.cbrt + - np.logspace + - np.take_along_axis + - np.average + - np.argmin gains support for the axis kwarg. + - np.ndarray.astype gains support for types expressed as + literal strings. + * For users of the Numba extension API, Numba now has a new error + handling mode whereby it will treat all exceptions that do not + inherit from numba.errors.NumbaException as a “hard error” and + immediately unwind the stack. This makes it much easier to + debug when writing @overloads etc from the extension API as + there’s now no confusion between Python errors and Numba + errors. This feature can be enabled by setting the environment + variable: NUMBA_CAPTURED_ERRORS='new_style'. + * The threading layer selection priority can now be changed via + the environment variable NUMBA_THREADING_LAYER_PRIORITY. + * Support for NVIDIA’s CUDA Python bindings. + * Support for 16-bit floating point numbers and their basic + operations via intrinsics. + * Streams are provided in the Stream.async_done result, making it + easier to implement asynchronous work queues. + * Support for structured types in device arrays, character + sequences in NumPy arrays, and some array operations on nested + arrays. + * Much underlying refactoring to align the CUDA target more + closely with the CPU target, which lays the groudwork for + supporting the high level extension API in CUDA in future + releases. + * Intel also kindly sponsored research and development into + native debug (DWARF) support and handling per-function + compilation flags: + * Line number/location tracking is much improved. + * Numba’s internal representation of containers (e.g. tuples, + arrays) are now encoded as structures. + * Numba’s per-function compilation flags are encoded into the ABI + field of the mangled name of the function such that it’s + possible to compile and differentiate between versions of the + same function with different flags set. + * There are no new general deprecations. + * There are no new CUDA target deprecations. +- Drop numba-pr7483-numpy1_21.patch +- Add numba-pr7748-random32bitwidth.patch -- gh#numba/numba#7748 + ------------------------------------------------------------------- Sat Jan 8 22:19:07 UTC 2022 - Ben Greiner diff --git a/python-numba.spec b/python-numba.spec index 35a4004..8ddef2e 100644 --- a/python-numba.spec +++ b/python-numba.spec @@ -16,9 +16,8 @@ # -%{?!python_module:%define python_module() python-%{**} python3-%{**}} +%{?!python_module:%define python_module() python3-%{**}} %define skip_python2 1 -%define skip_python310 1 %define plainpython python %global flavor @BUILD_FLAVOR@%{nil} %if "%{flavor}" == "test" @@ -29,7 +28,7 @@ %bcond_with test %endif Name: python-numba%{psuffix} -Version: 0.54.1 +Version: 0.55.0 Release: 0 Summary: NumPy-aware optimizing compiler for Python using LLVM License: BSD-2-Clause @@ -37,26 +36,25 @@ URL: https://numba.pydata.org/ Source: https://files.pythonhosted.org/packages/source/n/numba/numba-%{version}.tar.gz # PATCH-FIX-UPSTREAM fix-max-name-size.patch -- fix for gh#numba/numba#3876 -- from gh#numba/numba#4373 Patch0: fix-max-name-size.patch -# PATCH-FIX-UPSTREAM support numpy 1.21 -- gh#numba/numba#7176, gh#numba/numba#7483, gh#numpy/numpy#20376 -Patch1: numba-pr7483-numpy1_21.patch +# PATCH-FIX-UPSTREAM numba-pr7748-random32bitwidth.patch -- gh#numba/numba#7748 +Patch1: numba-pr7748-random32bitwidth.patch # PATCH-FIX-OPENSUSE skip tests failing due to OBS specifics Patch3: skip-failing-tests.patch -BuildRequires: %{python_module devel >= 3.7 with %python-devel < 3.10} +BuildRequires: %{python_module devel >= 3.7} BuildRequires: %{python_module numpy-devel >= 1.18 with %python-numpy-devel < 1.22} BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: gcc-c++ BuildRequires: python-rpm-macros BuildRequires: tbb-devel >= 2021 -Requires: python-llvmlite < 0.38 -Requires: python-llvmlite >= 0.37 -Requires: python-scipy >= 0.16 +Requires: (python-llvmlite >= 0.38 with python-llvmlite < 0.39) Requires: (python-numpy >= 1.18 with python-numpy < 1.22) Requires(post): update-alternatives Requires(preun):update-alternatives Recommends: python-Jinja2 Recommends: python-Pygments Recommends: python-cffi +Recommends: python-scipy > 1.0 Recommends: python-tbb %if %{with test} BuildRequires: %{python_module Jinja2} @@ -69,7 +67,7 @@ BuildRequires: %{python_module numba-devel >= %{version}} BuildRequires: %{python_module pip} BuildRequires: %{python_module psutil} BuildRequires: %{python_module pytest} -BuildRequires: %{python_module scipy >= 0.16} +BuildRequires: %{python_module scipy >= 1.0} BuildRequires: %{python_module tbb} %endif %python_subpackages @@ -102,17 +100,13 @@ Requires: %{plainpython}(abi) = %{python_version} This package contains files for developing applications using numba. %prep -%setup -q -n numba-%{version} -%autopatch -p1 +%autosetup -p1 -n numba-%{version} +sed -i -e '1{/env python/ d}' numba/misc/appdirs.py -# timeouts randomly in OBS +# random timeouts in OBS rm numba/tests/test_typedlist.py # if we reduced the amount of tests too much: # sed -i -e '/check_testsuite_size/ s/5000/3000/' numba/tests/test_runtests.py -# our setup imports distutils. Not sure why, but should not be a problem. -sed -i -e "/def test_laziness/,/def/ {/'distutils',/ d}" numba/tests/test_import.py - -sed -i -e '1{/env python/ d}' numba/misc/appdirs.py %build %if !%{with test} @@ -136,13 +130,14 @@ sed 's|^%{buildroot}|%%exclude |' devel-files0-%{$python_bin_suffix}.files > dev %check %if %{with test} -mv numba numba_temp -export NUMBA_PARALLEL_DIAGNOSTICS=1 -%{python_expand # test the installed package +# test the installed package, not the source without compiled modules +mkdir emtpytestdir +pushd emtpytestdir +%{python_expand # numbatests: check specific tests with `osc build -M test --define="numbatests "` %{_bindir}/numba-%{$python_bin_suffix} -s -$python -m numba.runtests -v -b --exclude-tags='long_running' -m %{_smp_build_ncpus} -- numba.tests +$python -m numba.runtests -v -b --exclude-tags='long_running' -m %{_smp_build_ncpus} -- %{?!numbatests:numba.tests}%{?numbatests} } -mv numba_temp numba +popd %endif %if !%{with test}