diff --git a/numpy-2.1-interval.patch b/numpy-2.1-interval.patch new file mode 100644 index 0000000..54b9062 --- /dev/null +++ b/numpy-2.1-interval.patch @@ -0,0 +1,33 @@ +From 6b61e8a6b3dddab13b88e51309cbdf2f28247960 Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Thu, 22 Aug 2024 08:20:25 +0200 +Subject: [PATCH] Fix docstring and implementation of Interval.power + +This makes the code more resilient to future numpy changes. +--- + pythran/interval.py | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/pythran/interval.py b/pythran/interval.py +index 4e5dff8fd..b8ef42e69 100644 +--- a/pythran/interval.py ++++ b/pythran/interval.py +@@ -196,13 +196,15 @@ def __pow__(range1, range2): + >>> Interval(1, 5) ** Interval(-5, -4) + Interval(low=1.0, high=1.0) + >>> Interval(-1, 5) ** Interval(-5, 3) +- Interval(low=-1.0, high=125.0) ++ Interval(low=-1.0, high=125) + >>> Interval(1, 5) ** Interval(3, 8) +- Interval(low=1.0, high=390625.0) ++ Interval(low=1, high=390625) + """ + res = [v1 ** v2 for v1, v2 in + itertools.product(range1.bounds(), range2.bounds())] +- return Interval(numpy.ceil(min(res)), numpy.floor(max(res))) ++ minres, maxres = min(res), max(res) ++ return Interval(type(minres)(numpy.ceil(minres)), ++ type(maxres)(numpy.floor(maxres))) + + def __lshift__(range1, range2): + """ diff --git a/numpy-2.1-support.patch b/numpy-2.1-support.patch new file mode 100644 index 0000000..ecd7d85 --- /dev/null +++ b/numpy-2.1-support.patch @@ -0,0 +1,105 @@ +From 9261d30aa9618cb2a5a698d39752263b076f2d4b Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Tue, 20 Aug 2024 23:50:55 +0200 +Subject: [PATCH] Fix numpy.fix output type + +This one changed with recent numpy upgrade, see +https://github.com/numpy/numpy/pull/26766 +--- + pythran/pythonic/include/numpy/fix.hpp | 17 ++++++++++++++--- + pythran/pythonic/numpy/fix.hpp | 6 +++--- + pythran/tests/test_numpy_func0.py | 5 +++++ + 3 files changed, 22 insertions(+), 6 deletions(-) + +diff --git a/pythran/pythonic/include/numpy/fix.hpp b/pythran/pythonic/include/numpy/fix.hpp +index 2708930d6c..e4a85a5049 100644 +--- a/pythran/pythonic/include/numpy/fix.hpp ++++ b/pythran/pythonic/include/numpy/fix.hpp +@@ -1,18 +1,29 @@ + #ifndef PYTHONIC_INCLUDE_NUMPY_FIX_HPP + #define PYTHONIC_INCLUDE_NUMPY_FIX_HPP + +-#include "pythonic/include/utils/functor.hpp" + #include "pythonic/include/types/ndarray.hpp" ++#include "pythonic/include/utils/functor.hpp" + #include "pythonic/include/utils/numpy_traits.hpp" + + PYTHONIC_NS_BEGIN + + namespace numpy + { ++ namespace wrapper ++ { ++ template ++ E fix(E const &e) ++ { ++ if (std::is_integral::value) ++ return e; ++ else ++ return std::trunc(e); ++ } ++ } // namespace wrapper + #define NUMPY_NARY_FUNC_NAME fix +-#define NUMPY_NARY_FUNC_SYM std::trunc ++#define NUMPY_NARY_FUNC_SYM wrapper::fix + #include "pythonic/include/types/numpy_nary_expr.hpp" +-} ++} // namespace numpy + PYTHONIC_NS_END + + #endif +diff --git a/pythran/pythonic/numpy/fix.hpp b/pythran/pythonic/numpy/fix.hpp +index 5b1b020dc2..84773b61cf 100644 +--- a/pythran/pythonic/numpy/fix.hpp ++++ b/pythran/pythonic/numpy/fix.hpp +@@ -3,8 +3,8 @@ + + #include "pythonic/include/numpy/fix.hpp" + +-#include "pythonic/utils/functor.hpp" + #include "pythonic/types/ndarray.hpp" ++#include "pythonic/utils/functor.hpp" + #include "pythonic/utils/numpy_traits.hpp" + + PYTHONIC_NS_BEGIN +@@ -13,9 +13,9 @@ namespace numpy + { + + #define NUMPY_NARY_FUNC_NAME fix +-#define NUMPY_NARY_FUNC_SYM std::trunc ++#define NUMPY_NARY_FUNC_SYM wrapper::fix + #include "pythonic/types/numpy_nary_expr.hpp" +-} ++} // namespace numpy + PYTHONIC_NS_END + + #endif +diff --git a/pythran/tests/test_numpy_func0.py b/pythran/tests/test_numpy_func0.py +index 3e11133fec..41f716d900 100644 +--- a/pythran/tests/test_numpy_func0.py ++++ b/pythran/tests/test_numpy_func0.py +@@ -1,12 +1,16 @@ + import unittest + from pythran.tests import TestEnv + import numpy ++from packaging import version + import tempfile + import os + + from pythran.typing import NDArray, List, Tuple + + ++np_version = version.parse(numpy.version.version) ++ ++ + class TestNumpyFunc0(TestEnv): + + def test_extended_sum0(self): +@@ -910,6 +914,7 @@ def test_flatnonzero1(self): + def test_fix0(self): + self.run_test("def np_fix0(x): from numpy import fix ; return fix(x)", 3.14, np_fix0=[float]) + ++ @unittest.skipIf(np_version <= version.Version("2.1"), reason="np.fix used to return float on integral input") + def test_fix1(self): + self.run_test("def np_fix1(x): from numpy import fix ; return fix(x)", 3, np_fix1=[int]) + diff --git a/python-pythran.changes b/python-pythran.changes index beef741..76ea3f9 100644 --- a/python-pythran.changes +++ b/python-pythran.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Sun Sep 1 13:28:40 UTC 2024 - Dirk Müller + +- Add patch numpy-2.1-support.patch, numpy-2.1-interval.patch: + * Fix test suite failure with numpy 2.1 +- prepare for python 3.13 + ------------------------------------------------------------------- Wed Jul 31 04:32:03 UTC 2024 - Steve Kowalik diff --git a/python-pythran.spec b/python-pythran.spec index d60e0f1..95fac3f 100644 --- a/python-pythran.spec +++ b/python-pythran.spec @@ -34,6 +34,9 @@ %if "%{flavor}" != "test-py312" %define skip_python312 1 %endif +%if "%{flavor}" != "test-py313" +%define skip_python313 1 +%endif # Skip empty buildsets, last one is for sle15_python_module_pythons %if "%{shrink:%{pythons}}" == "" || ("%pythons" == "python311" && 0%{?skip_python311}) ExclusiveArch: donotbuild @@ -54,6 +57,8 @@ Source0: https://github.com/serge-sans-paille/pythran/archive/refs/tags/% Source99: python-pythran-rpmlintrc # PATCH-FIX-UPSTREAM gh#serge-sans-paille/pythran#840a0e706ec39963aec6bcd1f118bf33177c20b4 Patch0: support-gast-0.6.patch +Patch1: https://github.com/serge-sans-paille/pythran/pull/2231/commits/9261d30aa9618cb2a5a698d39752263b076f2d4b.patch#/numpy-2.1-support.patch +Patch2: https://github.com/serge-sans-paille/pythran/commit/6b61e8a6b3dddab13b88e51309cbdf2f28247960.patch#/numpy-2.1-interval.patch BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools} BuildRequires: %{python_module wheel}