From 48cbabdad7b96800a3a5be408f90bbbfc91c369bde1fd33797e7d1be3cf881c5 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Thu, 27 Jul 2023 12:18:23 +0000 Subject: [PATCH] Accepting request 1101054 from home:mcalabkova:branches:devel:languages:python:numeric - Add upstream numpy-longdouble.patch and numpy-complex.patch to support new numpy OBS-URL: https://build.opensuse.org/request/show/1101054 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-pythran?expand=0&rev=26 --- numpy-complex.patch | 39 +++++++++++++ numpy-longdouble.patch | 122 +++++++++++++++++++++++++++++++++++++++++ python-pythran.changes | 5 ++ python-pythran.spec | 4 ++ 4 files changed, 170 insertions(+) create mode 100644 numpy-complex.patch create mode 100644 numpy-longdouble.patch diff --git a/numpy-complex.patch b/numpy-complex.patch new file mode 100644 index 0000000..5c3ed4c --- /dev/null +++ b/numpy-complex.patch @@ -0,0 +1,39 @@ +From a49dc44076f7068205c22f532975c50cc4c03958 Mon Sep 17 00:00:00 2001 +From: Lysandros Nikolaou +Date: Wed, 19 Jul 2023 13:03:41 +0200 +Subject: [PATCH] Use npy_creal/npy_cimag from npy_math in from_python::convert + +--- + pythran/pythonic/types/complex.hpp | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/pythran/pythonic/types/complex.hpp b/pythran/pythonic/types/complex.hpp +index 9b57f7384..929a3d200 100644 +--- a/pythran/pythonic/types/complex.hpp ++++ b/pythran/pythonic/types/complex.hpp +@@ -177,6 +177,7 @@ PYTHONIC_NS_END + #ifdef ENABLE_PYTHON_MODULE + + #include "numpy/arrayscalars.h" ++#include "numpy/npy_math.h" + #include "pythonic/python/core.hpp" + + PYTHONIC_NS_BEGIN +@@ -228,7 +229,7 @@ inline std::complex + from_python>::convert(PyObject *obj) + { + auto val = PyArrayScalar_VAL(obj, CLongDouble); +- return {val.real, val.imag}; ++ return {npy_creall(val), npy_cimagl(val)}; + } + + template <> +@@ -243,7 +244,7 @@ inline std::complex + from_python>::convert(PyObject *obj) + { + auto val = PyArrayScalar_VAL(obj, CFloat); +- return {val.real, val.imag}; ++ return {npy_crealf(val), npy_cimagf(val)}; + } + PYTHONIC_NS_END + #endif diff --git a/numpy-longdouble.patch b/numpy-longdouble.patch new file mode 100644 index 0000000..a6a5c98 --- /dev/null +++ b/numpy-longdouble.patch @@ -0,0 +1,122 @@ +From 339fb5dcdf28f40311b5051925fd8a2c86286ac6 Mon Sep 17 00:00:00 2001 +From: serge-sans-paille +Date: Thu, 6 Jul 2023 22:06:20 +0200 +Subject: [PATCH] Introduce pythran/pythonic/include/types/longdouble.hpp et + cie + +New numpy version alias np.float128 to np.longdouble, so we need these +headers too. Same for np.complex256 and np.clongdouble. + +SLightly adjust notebook tests for portability to that respect. +--- + pythran/pythonic/include/types/clongdouble.hpp | 6 ++++++ + pythran/pythonic/include/types/longdouble.hpp | 4 ++++ + pythran/pythonic/types/clongdouble.hpp | 7 +++++++ + pythran/pythonic/types/float128.hpp | 2 +- + pythran/pythonic/types/longdouble.hpp | 6 ++++++ + pythran/tests/notebooks/export.ipynb | 14 +++++++------- + 6 files changed, 31 insertions(+), 8 deletions(-) + create mode 100644 pythran/pythonic/include/types/clongdouble.hpp + create mode 100644 pythran/pythonic/include/types/longdouble.hpp + create mode 100644 pythran/pythonic/types/clongdouble.hpp + create mode 100644 pythran/pythonic/types/longdouble.hpp + +diff --git a/pythran/pythonic/include/types/clongdouble.hpp b/pythran/pythonic/include/types/clongdouble.hpp +new file mode 100644 +index 0000000000..dd666a52f5 +--- /dev/null ++++ b/pythran/pythonic/include/types/clongdouble.hpp +@@ -0,0 +1,6 @@ ++#ifndef PYTHONIC_INCLUDE_TYPES_CLONGDOUBLE_HPP ++#define PYTHONIC_INCLUDE_TYPES_CLONGDOUBLE_HPP ++ ++#include "pythonic/include/types/complex.hpp" ++ ++#endif +diff --git a/pythran/pythonic/include/types/longdouble.hpp b/pythran/pythonic/include/types/longdouble.hpp +new file mode 100644 +index 0000000000..1ee2fca96c +--- /dev/null ++++ b/pythran/pythonic/include/types/longdouble.hpp +@@ -0,0 +1,4 @@ ++#ifndef PYTHONIC_INCLUDE_TYPES_LONGDOUBLE_HPP ++#define PYTHONIC_INCLUDE_TYPES_LONGDOUBLE_HPP ++ ++#endif +diff --git a/pythran/pythonic/types/clongdouble.hpp b/pythran/pythonic/types/clongdouble.hpp +new file mode 100644 +index 0000000000..057a2b9cb6 +--- /dev/null ++++ b/pythran/pythonic/types/clongdouble.hpp +@@ -0,0 +1,7 @@ ++#ifndef PYTHONIC_TYPES_CLONGDOUBLE_HPP ++#define PYTHONIC_TYPES_CLONGDOUBLE_HPP ++ ++#include "pythonic/include/types/clongdouble.hpp" ++#include "pythonic/types/complex.hpp" ++ ++#endif +diff --git a/pythran/pythonic/types/float128.hpp b/pythran/pythonic/types/float128.hpp +index bf67552447..0943827ff3 100644 +--- a/pythran/pythonic/types/float128.hpp ++++ b/pythran/pythonic/types/float128.hpp +@@ -1,6 +1,6 @@ + #ifndef PYTHONIC_TYPES_FLOAT128_HPP + #define PYTHONIC_TYPES_FLOAT128_HPP + +-#include "pythonic/include/types/float64.hpp" ++#include "pythonic/include/types/float128.hpp" + + #endif +diff --git a/pythran/pythonic/types/longdouble.hpp b/pythran/pythonic/types/longdouble.hpp +new file mode 100644 +index 0000000000..b3944cea6a +--- /dev/null ++++ b/pythran/pythonic/types/longdouble.hpp +@@ -0,0 +1,6 @@ ++#ifndef PYTHONIC_TYPES_LONGDOUBLE_HPP ++#define PYTHONIC_TYPES_LONGDOUBLE_HPP ++ ++#include "pythonic/include/types/longdouble.hpp" ++ ++#endif +diff --git a/pythran/tests/notebooks/export.ipynb b/pythran/tests/notebooks/export.ipynb +index aa2baadc06..3f390dc0f1 100644 +--- a/pythran/tests/notebooks/export.ipynb ++++ b/pythran/tests/notebooks/export.ipynb +@@ -418,20 +418,20 @@ + "name": "stdout", + "output_type": "stream", + "text": [ +- "(1.5, -1.5) \n", +- "(1.5, -1.5) \n", +- "(1.5, -1.5) \n" ++ "(1.5, -1.5)\n", ++ "(1.5, -1.5)\n", ++ "(1.5, -1.5)\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "x64 = dtype(np.complex64(1.5 + -1.5j))\n", +- "print(x64, type(x64[0]))\n", ++ "print(x64)\n", + "x128 = dtype(np.complex128(1.5 + -1.5j))\n", +- "print(x128, type(x128[0]))\n", ++ "print(x128)\n", + "x256 = dtype(np.complex256(1.5 + -1.5j))\n", +- "print(x256, type(x256[0]))" ++ "print(x256)" + ] + }, + { +@@ -969,7 +969,7 @@ + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", +- "version": "3.10.9" ++ "version": "3.10.11" + } + }, + "nbformat": 4, diff --git a/python-pythran.changes b/python-pythran.changes index 5915026..961bbd4 100644 --- a/python-pythran.changes +++ b/python-pythran.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Thu Jul 27 10:10:55 UTC 2023 - Markéta Machová + +- Add upstream numpy-longdouble.patch and numpy-complex.patch to support new numpy + ------------------------------------------------------------------- Sat Jun 10 17:53:22 UTC 2023 - ecsos diff --git a/python-pythran.spec b/python-pythran.spec index 8073051..f02e1fd 100644 --- a/python-pythran.spec +++ b/python-pythran.spec @@ -52,6 +52,10 @@ URL: https://github.com/serge-sans-paille/pythran # Tests are only availble in github archive Source0: https://github.com/serge-sans-paille/pythran/archive/refs/tags/%{version}.tar.gz#/pythran-%{version}-gh.tar.gz Source99: python-pythran-rpmlintrc +#PATCH-FIX-UPSTREAM https://github.com/serge-sans-paille/pythran/commit/339fb5dcdf28f40311b5051925fd8a2c86286ac6 Introduce pythran/pythonic/include/types/longdouble.hpp et cie +Patch: numpy-longdouble.patch +#PATCH-FIX-UPSTREAM https://github.com/serge-sans-paille/pythran/commit/a49dc44076f7068205c22f532975c50cc4c03958 Use npy_creal/npy_cimag from npy_math in from_python::convert +Patch: numpy-complex.patch BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros