1
0

18 Commits

Author SHA256 Message Date
b47f69f09d Accepting request 1308073 from devel:languages:python:numeric
- prepare for py314 tests

- Add upstream np-fromstring.patch and np-frombuffer.patch to fix

OBS-URL: https://build.opensuse.org/request/show/1308073
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pythran?expand=0&rev=28
2025-09-30 15:48:34 +00:00
dfb9de9042 - prepare for py314 tests
- Add upstream np-fromstring.patch and np-frombuffer.patch to fix

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-pythran?expand=0&rev=70
2025-09-29 21:33:15 +00:00
ce64aa0405 Accepting request 1300343 from devel:languages:python:numeric
OBS-URL: https://build.opensuse.org/request/show/1300343
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pythran?expand=0&rev=27
2025-08-20 11:24:59 +00:00
9441fbba5a - Drop np-frombuffer.patch and np-fromstring.patch and substitute
them with np.patch, which is a PR which contains both of them
  and also other fixes, unskip the previously skipped test

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-pythran?expand=0&rev=68
2025-08-19 17:52:42 +00:00
78f1d3c8a5 Accepting request 1299416 from devel:languages:python:numeric
OBS-URL: https://build.opensuse.org/request/show/1299416
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pythran?expand=0&rev=26
2025-08-15 19:51:13 +00:00
fcf4f968b8 Sorry, I messed up before
- Add upstream np-fromstring.patch and np-frombuffer.patch to fix 
  tests with NumPy 2.3, skip one additional failing test
- Do not run any tests on Leap 16.0 due to lack of dependencies
  This is part of hplip enablement on 16.0
- Skip pythran/tests/test_xdoc.py::TestDoctest::test_utils, which
  is failing with 3.13.5 (gh#serge-sans-paille/pythran#2326).
- Add GCC15_pythran-PR2325-missing-operators.patch
  * Tracking Issues for this and the previous patch:
    gcc#120622
    gh#serge-sans-paille/pythran#2321
    gh#serge-sans-paille/pythran#2324
    gh#serge-sans-paille/pythran#2325
    boo#1243779
- Fix failures with GCC15:
  GCC15_fix_Add-missing-operators-to-nditerator.patch
- Update to 0.18.0 - balafenn
  * no upstream changelog.
  ## git commits (a few non-relevant filtered)
  * Fix uninitialized iexpr assignment
  * Fix folding of comparison operators
  * Take augassign into account when removing nested functions
  * Fix local processing in presence of else: clause in for loop
  * Fix detection of c++ compiler
  * Traverse augassign when computing scopes
  * Reproducible ContainerOf iteration
  * Fix overload handling for NoneType
  * Fix type inference in presence of augassign
  * Improve forward substitution in presence of augassign
  * Remove dead code in tests
  * Faster (and common!) implementation of make_integer_sequence
  * Only register a node in name_to_nodes if the combiner was
    succesful
  * Reproducible aliasing ordering
  * Reproducible nested functions removal
  * Reproducible topological order
  * Verify reproducibility of c++ output
  * Reproducible (because sortable) alias order
  * Stateless PType
  * Reproducible local declaration order
  * Reproducible identifiers generation
  * Reproducible include order
  * More flexible implementation of default list
  * Fix typing issue under complex slice combination
  * Add support for nonlocal keyword
  * Fix bug in nested function remover
  * Cope with numpy.bool deprecation
  * Be more informative about UnboundIdentifierError
  * Optimize generation of cxx types
  * Use inheritance instead of member type for __combined
    specialization
  * Remove redundant extra combiner for Assigned Subscript
  * Improve nested functions support
  * Harden error reporting: Do not trap when no lineno is available
  * Handle folding of static_if
  * Fix constness of std::get on an array_base r-value
  * Make none_type hashable
  * Get rid of clang workaround for containers of one element
  * Simplify backend type cache & fix handling of LTypes
  * Fix constness of dict's bool operator
  * Specialize dict for None Key
  * Drop support for builtins.None in favor of None
  * Add handling of numpy.bool in tog
  * replace quansight-labs/setup-python with actions/setup-python
  * [ci] Dump more info when compiling system dep
  * [test] Fix sign comparison code
  * [ci] Test unvendoring of xsimd and boost
  * Disable inlining in while test
  * Python 3.13 compat: detect removed find_exe
  * Fix test portability issue for ipython magic
  * Adjust --cflags-pythran-only implementation
  * ENH: improvements to pythran-config for build system
    integration
  * Have FastGExpr load its dependency in a lazy manner
  * Move GIL manipulation right after module creation
  * Better modeling of analyse and transformations
  * Fix pythran support for numpy.float128
  * Defer initialisation of global variables until the module is
    actually created
  * Fix interaction between static if and nested loop / function
  * Allow tuple with combinable items as array initializer
  * Have pythran generate freethreading compatible code
  * Remove legacy logic that handled py2/py3 compatibility
  * Remove any usage of __PYTHRAN__ macro
  * Make sure blas function argument actually have an associated
    buffer
  * Provide user hint when trying to use c-style type names in
    pythran spec
  * [typing] Support union type in annotation
  * Restore type qualifiers dropped by
    b8cd84b5a5ab5222d65781a0194916ad555bf70c
  * Add basic support for type annotation
  * [constant folding] Correctly model restrict_assign in constant
    folding
- Update test flavors
- Update to 0.17.0
	* Support parsing annotated statement
	* Document and test Meson integration
	* Update / improve Blas detection, including scipy-openblas
	* Fix usage of Blas library
	* Improve error reporting
	* Support array module
	* Reduce dependency on setuptools
	* Faster forward substitution
	* Enforce default optimization level to `-O2`
- Drop upstreamed numpy-2.1-interval.patch
- Drop upstreamed numpy-2.1-support.patch
- Drop upstreamed support-gast-0.6.patch
- 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
- Add patch support-gast-0.6.patch:
  * Support gast 0.6.0 changes, change Requires appropriately.
- limit to gast < 0.6.0
- update to 0.16.1:
  * Fix massive memory leakage in all ndarray
- Update to 0.16.0
  * Support numpy.vectorize, numpy.argsort's kind keyword,
    real/imag on numpy_iexpr
  * Add missing omp.set_num_thread descriptor
  * Provide --trace-allocations switch
  * Support empty PYTHRANRC for reproducible builds
  * Improve compilation time
  * Support ufunc creation through #pythran export ufunc
    func_name(arg_types...)
  * Fix memory leak when returing numpy_gexpr to Python
  * Numpy 2.x support
  * Upgrade xsimd to 13.0.0
  * Improve detection of non-overlapping memory area during gexpr
    assignment
  * Improve python 3.12 support (distutils removal)
  * Support imatmul
  * Only link blas when needed
- Refactor the multibuild test flavor logic
- Accomodate some 15.x intricacies for the failing tests:
  * use netlib lapack/blas instead of openblas
- Use newly supported shrink{} on OBS to exclude python flavors
  will all python versions skipped.
- Yet another fix of the python39 test skip
- Fix python312 tests: Force linking to openblas with custom
  pythranrc
- Remove test skips no longer needed
- Make test flavors future proof: Don't fail on empty buildset
- Skip python39 for all test flavors: The test-py39 multibuild has
  already been removed but it is still in the build set, so don't
  test it in the other multibuilds.
- Debundle xsimd
- update to 0.15.0:
  * Use pyproject.toml to store setup and build configuration
  * Upgrade xsimd to a48ab430d4b84ecd5449180ee1c6d2eed67c4191
  * Improve detection of non-overlapping memory area during gexpr
    assignment
  * Support python 3.12
  * Support list.clear
  * Improve detection of methods uses as functions
- drop python39 from testing, add python312
- Prepare for Python 3.12, by skipping it for the other test flavors, and
  adding one for it.
- Update to 0.14.0:
  * Numpy compatibility - update signatures, complex number handling, long
    double support
  * Lazyly import top-level modules and submodules
  * Improve array indexing by an array
  * Require at least clang 7 or gcc 8
  * Make pythran compilation reproducible
  * Support np.roll with multiple axis
  * Support numpy.ndarray.view
  * Improve list resizing speed
  * Fix bug when filtering an empty sequence
- Drop patches, now included upstream:
  * numpy-longdouble.patch
  * numpy-complex.patch
- Switch to pyproject macros.
- Fix build error in Leap, because it must not be two "Patch:" lines.
- Add upstream numpy-longdouble.patch and numpy-complex.patch to support new numpy
- Add %{?sle15_python_module_pythons}
- update to 0.13.1:
  * Bump xsimd dependency to 11.0.0, with a backported patch.
  * Improve performance of functions revieving scalar arguments.
    This changes the internal function call API.
  * Improve performance of fix-stride slicing, using a new slice
    representation.
  * Improve numpy.copyto performance, and detect copyto pattern usage.
  * Force internal linkage of generated functions, which gives more
    optimization room to the C++ compiler.
  * Provide entry points pythran.import_pythrancode and
    pythran.import_pythranfile, as a poor man JIT option.
  * Optimize numpy.argmax(cst * val) into numpy.argmax(val) when cst is
    positive.
  * Avoid copies upon numpy.array_split
  * Get rid of unused functions C++ warnings
  * Avoid generating a loop footer when the loop index is not used
    outside of the loop.
- fix the test-flavor splitting for python311
- update to 0.12.1:
  * Bump xsimd depdency to 10.0.0
  * Correctly raise KeyError when getting an unset dict item
  * Fix negative binomial implementation
  * Correctly convert strided array with offset
  * Support np.clip(v, None, x) and np.clip(v, x, None)
  * Support scipy.special.ndtr, scipy.special.ndtri, scipy.special.gammaincinv
  * Fix set intersection
  * Support numpy.fft.fftn
  * Support axis parameter in numpy.argsort
- Revert. 2046-fix-cli-doc-test.patch did not fix the tests.
  gh#serge-sans-paille/pythran#2046
- Add 2046-fix-cli-doc-test.patch to fix failing tests
  (gh#serge-sans-paille/pythran#2046).
- Skip also failing test_toolchain and test_cli
  (gh#serge-sans-paille/pythran#2044) tests.
- Update to 0.12.0
  * Improve numpy expression computation speed
  * Decent ICC support (fixing an issue from 2018!)
  * Much faster C++ code generation
  * Complete rework of constant folder
  * Support C++-time evaluation of numpy.ndarray.ndim
  * Improved omp declare reduction support
  * Allow indexing of ndarray by integers of mixed types
  * A lot of small pesty bug fixes in the C++ headers
- Drop patches
  * gcc12-fixes.patch
  * pythran-pr1984-fixdistutils.patch
- Add pythran-pr1984-fixdistutils.patch
  * gh#serge-sans-paille/pythran#1984
  * Fixes gh#serge-sans-paille/pythran#1984 with setuptools >= 60
- Add gcc12-fixes.patch in order to fix GCC 12 building issues.
- Fix errors uncovered by staging:
  * Mention python-pythran-rpmlintrc
  * also make :test-py* noarch so that no debuginfo package fails
- Initial specfile for 0.11
  * debundling inspired by Fedora package:
    https://src.fedoraproject.org/rpms/pythran/blob/rawhide/f/pythran.spec
- Required by scipy 1.7

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-pythran?expand=0&rev=66
2025-08-14 12:55:59 +00:00
690348986b - Add upstream np-fromstring.patch to fix tests with NumPy 2.3
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-pythran?expand=0&rev=65
2025-08-14 08:42:32 +00:00
97e0411112 Accepting request 1291117 from devel:languages:python:numeric
- Do not run any tests on Leap 16.0 due to lack of dependencies
  This is part of hplip enablement on 16.0

OBS-URL: https://build.opensuse.org/request/show/1291117
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pythran?expand=0&rev=25
2025-07-08 13:28:06 +00:00
9dab90effc OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-pythran?expand=0&rev=63 2025-07-07 18:34:36 +00:00
6cfc8c93ef skip testing on leap16
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-pythran?expand=0&rev=62
2025-07-07 18:31:37 +00:00
fc79112197 Accepting request 1286685 from devel:languages:python:numeric
OBS-URL: https://build.opensuse.org/request/show/1286685
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pythran?expand=0&rev=24
2025-06-18 20:28:45 +00:00
10c7a335e7 - Skip pythran/tests/test_xdoc.py::TestDoctest::test_utils, which
is failing with 3.13.5 (gh#serge-sans-paille/pythran#2326).

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-pythran?expand=0&rev=60
2025-06-18 12:26:00 +00:00
f8e8e5f5a6 Accepting request 1285647 from devel:languages:python:numeric
OBS-URL: https://build.opensuse.org/request/show/1285647
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pythran?expand=0&rev=23
2025-06-16 09:11:31 +00:00
844cea57bf - Add GCC15_pythran-PR2325-missing-operators.patch
* Tracking Issues for this and the previous patch:
    gcc#120622
    gh#serge-sans-paille/pythran#2321
    gh#serge-sans-paille/pythran#2324
    gh#serge-sans-paille/pythran#2325
    boo#1243779

- Fix failures with GCC15:
  GCC15_fix_Add-missing-operators-to-nditerator.patch

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-pythran?expand=0&rev=58
2025-06-13 20:05:09 +00:00
0e67cb4c62 Accepting request 1281377 from devel:languages:python:numeric
OBS-URL: https://build.opensuse.org/request/show/1281377
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pythran?expand=0&rev=22
2025-06-04 18:26:36 +00:00
59750e7e5a - Update to 0.18.0 - balafenn
* no upstream changelog.
  ## git commits (a few non-relevant filtered)
  * Fix uninitialized iexpr assignment
  * Fix folding of comparison operators
  * Take augassign into account when removing nested functions
  * Fix local processing in presence of else: clause in for loop
  * Fix detection of c++ compiler
  * Traverse augassign when computing scopes
  * Reproducible ContainerOf iteration
  * Fix overload handling for NoneType
  * Fix type inference in presence of augassign
  * Improve forward substitution in presence of augassign
  * Remove dead code in tests
  * Faster (and common!) implementation of make_integer_sequence
  * Only register a node in name_to_nodes if the combiner was
    succesful
  * Reproducible aliasing ordering
  * Reproducible nested functions removal
  * Reproducible topological order
  * Verify reproducibility of c++ output
  * Reproducible (because sortable) alias order
  * Stateless PType
  * Reproducible local declaration order
  * Reproducible identifiers generation
  * Reproducible include order
  * More flexible implementation of default list
  * Fix typing issue under complex slice combination
  * Add support for nonlocal keyword
  * Fix bug in nested function remover

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-pythran?expand=0&rev=56
2025-05-30 10:58:41 +00:00
4632f56ec3 Accepting request 1224949 from devel:languages:python:numeric
OBS-URL: https://build.opensuse.org/request/show/1224949
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pythran?expand=0&rev=21
2024-11-20 15:58:45 +00:00
60eb19dd17 - Update to 0.17.0
* Support parsing annotated statement
	* Document and test Meson integration
	* Update / improve Blas detection, including scipy-openblas
	* Fix usage of Blas library
	* Improve error reporting
	* Support array module
	* Reduce dependency on setuptools
	* Faster forward substitution
	* Enforce default optimization level to `-O2`
- Drop upstreamed numpy-2.1-interval.patch
- Drop upstreamed numpy-2.1-support.patch
- Drop upstreamed support-gast-0.6.patch

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-pythran?expand=0&rev=54
2024-11-18 21:09:46 +00:00
11 changed files with 962 additions and 230 deletions

View File

@@ -0,0 +1,129 @@
From 14b78f0db9cbd253414b751d14644843354e7557 Mon Sep 17 00:00:00 2001
From: cielavenir <cielartisan@gmail.com>
Date: Fri, 6 Jun 2025 16:21:52 +0900
Subject: [PATCH 1/5] Add missing operators to nditerator
---
pythran/pythonic/include/types/nditerator.hpp | 9 +++
pythran/pythonic/types/nditerator.hpp | 57 +++++++++++++++++++
2 files changed, 66 insertions(+)
diff --git a/pythran/pythonic/include/types/nditerator.hpp b/pythran/pythonic/include/types/nditerator.hpp
index 0d1f8281a..934e5cc0a 100644
--- a/pythran/pythonic/include/types/nditerator.hpp
+++ b/pythran/pythonic/include/types/nditerator.hpp
@@ -66,6 +66,9 @@ namespace types
bool operator!=(nditerator<E> const &other) const;
bool operator==(nditerator<E> const &other) const;
bool operator<(nditerator<E> const &other) const;
+ bool operator>(nditerator<E> const &other) const;
+ bool operator<=(nditerator<E> const &other) const;
+ bool operator>=(nditerator<E> const &other) const;
nditerator &operator=(nditerator const &other);
};
@@ -92,6 +95,9 @@ namespace types
bool operator!=(const_nditerator<E> const &other) const;
bool operator==(const_nditerator<E> const &other) const;
bool operator<(const_nditerator<E> const &other) const;
+ bool operator>(const_nditerator<E> const &other) const;
+ bool operator<=(const_nditerator<E> const &other) const;
+ bool operator>=(const_nditerator<E> const &other) const;
const_nditerator &operator=(const_nditerator const &other);
};
#ifdef USE_XSIMD
@@ -115,6 +121,9 @@ namespace types
bool operator!=(const_simd_nditerator const &other) const;
bool operator==(const_simd_nditerator const &other) const;
bool operator<(const_simd_nditerator const &other) const;
+ bool operator>(const_simd_nditerator const &other) const;
+ bool operator<=(const_simd_nditerator const &other) const;
+ bool operator>=(const_simd_nditerator const &other) const;
const_simd_nditerator &operator=(const_simd_nditerator const &other);
void store(xsimd::batch<typename E::dtype> const &);
};
diff --git a/pythran/pythonic/types/nditerator.hpp b/pythran/pythonic/types/nditerator.hpp
index 2cb2b9047..ef2b7c4a8 100644
--- a/pythran/pythonic/types/nditerator.hpp
+++ b/pythran/pythonic/types/nditerator.hpp
@@ -97,6 +97,24 @@ namespace types
return index < other.index;
}
+ template <class E>
+ bool nditerator<E>::operator>(nditerator<E> const &other) const
+ {
+ return index > other.index;
+ }
+
+ template <class E>
+ bool nditerator<E>::operator<=(nditerator<E> const &other) const
+ {
+ return !(index > other.index);
+ }
+
+ template <class E>
+ bool nditerator<E>::operator>=(nditerator<E> const &other) const
+ {
+ return !(index < other.index);
+ }
+
template <class E>
nditerator<E> &nditerator<E>::operator=(nditerator<E> const &other)
{
@@ -188,6 +206,24 @@ namespace types
return index < other.index;
}
+ template <class E>
+ bool const_nditerator<E>::operator>(const_nditerator<E> const &other) const
+ {
+ return index > other.index;
+ }
+
+ template <class E>
+ bool const_nditerator<E>::operator<=(const_nditerator<E> const &other) const
+ {
+ return !(index > other.index);
+ }
+
+ template <class E>
+ bool const_nditerator<E>::operator>=(const_nditerator<E> const &other) const
+ {
+ return !(index < other.index);
+ }
+
template <class E>
const_nditerator<E> &
const_nditerator<E>::operator=(const_nditerator const &other)
@@ -271,6 +307,27 @@ namespace types
return data < other.data;
}
+ template <class E>
+ bool const_simd_nditerator<E>::operator>(
+ const_simd_nditerator<E> const &other) const
+ {
+ return data > other.data;
+ }
+
+ template <class E>
+ bool const_simd_nditerator<E>::operator<=(
+ const_simd_nditerator<E> const &other) const
+ {
+ return !(data > other.data);
+ }
+
+ template <class E>
+ bool const_simd_nditerator<E>::operator>=(
+ const_simd_nditerator<E> const &other) const
+ {
+ return !(data < other.data);
+ }
+
template <class E>
const_simd_nditerator<E> &
const_simd_nditerator<E>::operator=(const_simd_nditerator const &other)
--
2.49.0

View File

@@ -0,0 +1,322 @@
From 623fa5031df7ec5c3dfe6789bf608cf11ac95c36 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <serge.guelton@telecom-bretagne.eu>
Date: Wed, 11 Jun 2025 23:49:40 +0200
Subject: [PATCH] Add missing iterator comparison operators
Fix #2324
---
pythran/pythonic/builtins/map.hpp | 37 +++++++++++++++----
pythran/pythonic/builtins/range.hpp | 6 +++
pythran/pythonic/include/builtins/map.hpp | 16 +++++---
pythran/pythonic/include/builtins/range.hpp | 1 +
.../pythonic/include/numpy/ndenumerate.hpp | 4 ++
pythran/pythonic/include/numpy/ndindex.hpp | 4 ++
pythran/pythonic/include/types/array.hpp | 8 +++-
pythran/pythonic/include/types/numpy_expr.hpp | 31 +++++++++-------
pythran/pythonic/include/types/str.hpp | 13 +++++--
9 files changed, 88 insertions(+), 32 deletions(-)
diff --git a/pythran/pythonic/builtins/map.hpp b/pythran/pythonic/builtins/map.hpp
index ac6eb0354..e81dd2c46 100644
--- a/pythran/pythonic/builtins/map.hpp
+++ b/pythran/pythonic/builtins/map.hpp
@@ -143,11 +143,35 @@ namespace builtins
return !(*this == other);
}
+ template <typename Operator, typename... Iters>
+ template <size_t N>
+ bool map_iterator<Operator, Iters...>::lt(
+ map_iterator<Operator, Iters...> const &other, utils::int_<N>) const
+ {
+ return std::get<N>(it) < std::get<N>(other.it) ||
+ ((std::get<N>(it) == std::get<N>(other.it)) &&
+ lt(other, utils::int_<N - 1>()));
+ }
+
+ template <typename Operator, typename... Iters>
+ bool map_iterator<Operator, Iters...>::lt(
+ map_iterator<Operator, Iters...> const &other, utils::int_<0>) const
+ {
+ return std::get<0>(it) < std::get<0>(other.it);
+ }
+
template <typename Operator, typename... Iters>
bool map_iterator<Operator, Iters...>::operator<(
map_iterator<Operator, Iters...> const &other) const
{
- return !(*this == other);
+ return lt(other, utils::int_<sizeof...(Iters) - 1>());
+ }
+
+ template <typename Operator, typename... Iters>
+ bool map_iterator<Operator, Iters...>::operator<=(
+ map_iterator<Operator, Iters...> const &other) const
+ {
+ return (*this == other) || (*this < other);
}
template <typename Operator, typename... Iters>
@@ -208,12 +232,11 @@ namespace builtins
} // namespace details
template <typename Operator, typename... Iter>
- auto map(Operator &&_op, Iter &&...iters)
- -> details::map<
- typename std::remove_cv<
- typename std::remove_reference<Operator>::type>::type,
- typename types::iterator<typename std::remove_cv<
- typename std::remove_reference<Iter>::type>::type>::type...>
+ auto map(Operator &&_op, Iter &&...iters) -> details::map<
+ typename std::remove_cv<
+ typename std::remove_reference<Operator>::type>::type,
+ typename types::iterator<typename std::remove_cv<
+ typename std::remove_reference<Iter>::type>::type>::type...>
{
return {std::forward<Operator>(_op), std::forward<Iter>(iters)...};
}
diff --git a/pythran/pythonic/builtins/range.hpp b/pythran/pythonic/builtins/range.hpp
index 2c3f3971d..bff58960e 100644
--- a/pythran/pythonic/builtins/range.hpp
+++ b/pythran/pythonic/builtins/range.hpp
@@ -89,6 +89,12 @@ namespace builtins
return sign * value_ < sign * other.value_;
}
+ inline bool range_iterator::operator<=(range_iterator const &other) const
+ {
+ const long sign = +1 | (step_ >> (sizeof(long) * CHAR_BIT - 1));
+ return sign * value_ <= sign * other.value_;
+ }
+
inline long range_iterator::operator-(range_iterator const &other) const
{
return (value_ - other.value_) / step_;
diff --git a/pythran/pythonic/include/builtins/map.hpp b/pythran/pythonic/include/builtins/map.hpp
index 788106712..8f358bd50 100644
--- a/pythran/pythonic/include/builtins/map.hpp
+++ b/pythran/pythonic/include/builtins/map.hpp
@@ -56,6 +56,7 @@ namespace builtins
bool operator==(map_iterator const &other) const;
bool operator!=(map_iterator const &other) const;
bool operator<(map_iterator const &other) const;
+ bool operator<=(map_iterator const &other) const;
long operator-(map_iterator const &other) const;
private:
@@ -69,6 +70,10 @@ namespace builtins
bool equal(map_iterator const &other, utils::int_<N>) const;
bool equal(map_iterator const &other, utils::int_<0>) const;
+ template <size_t N>
+ bool lt(map_iterator const &other, utils::int_<N>) const;
+ bool lt(map_iterator const &other, utils::int_<0>) const;
+
template <size_t I>
void advance(long i, utils::int_<I>);
void advance(long i, utils::int_<0>);
@@ -107,12 +112,11 @@ namespace builtins
} // namespace details
template <typename Operator, typename... Iter>
- auto map(Operator &&_op, Iter &&...iters)
- -> details::map<
- typename std::remove_cv<
- typename std::remove_reference<Operator>::type>::type,
- typename types::iterator<typename std::remove_cv<
- typename std::remove_reference<Iter>::type>::type>::type...>;
+ auto map(Operator &&_op, Iter &&...iters) -> details::map<
+ typename std::remove_cv<
+ typename std::remove_reference<Operator>::type>::type,
+ typename types::iterator<typename std::remove_cv<
+ typename std::remove_reference<Iter>::type>::type>::type...>;
DEFINE_FUNCTOR(pythonic::builtins, map);
} // namespace builtins
diff --git a/pythran/pythonic/include/builtins/range.hpp b/pythran/pythonic/include/builtins/range.hpp
index 7c40b6dcd..82e1c18ec 100644
--- a/pythran/pythonic/include/builtins/range.hpp
+++ b/pythran/pythonic/include/builtins/range.hpp
@@ -28,6 +28,7 @@ namespace builtins
bool operator!=(range_iterator const &other) const;
bool operator==(range_iterator const &other) const;
bool operator<(range_iterator const &other) const;
+ bool operator<=(range_iterator const &other) const;
long operator-(range_iterator const &other) const;
};
} // namespace
diff --git a/pythran/pythonic/include/numpy/ndenumerate.hpp b/pythran/pythonic/include/numpy/ndenumerate.hpp
index 18d78f2ef..ad8bbca22 100644
--- a/pythran/pythonic/include/numpy/ndenumerate.hpp
+++ b/pythran/pythonic/include/numpy/ndenumerate.hpp
@@ -25,6 +25,10 @@ namespace numpy
ndenumerate_iterator &operator++();
ndenumerate_iterator &operator+=(long n);
bool operator!=(ndenumerate_iterator const &other) const;
+ bool operator==(ndenumerate_iterator const &other) const
+ {
+ return !(*this != other);
+ }
bool operator<(ndenumerate_iterator const &other) const;
long operator-(ndenumerate_iterator const &other) const;
};
diff --git a/pythran/pythonic/include/numpy/ndindex.hpp b/pythran/pythonic/include/numpy/ndindex.hpp
index 387665cdb..8361f4ffd 100644
--- a/pythran/pythonic/include/numpy/ndindex.hpp
+++ b/pythran/pythonic/include/numpy/ndindex.hpp
@@ -25,6 +25,10 @@ namespace numpy
ndindex_iterator &operator++();
ndindex_iterator &operator+=(long n);
bool operator!=(ndindex_iterator const &other) const;
+ bool operator==(ndindex_iterator const &other) const
+ {
+ return !(*this != other);
+ }
bool operator<(ndindex_iterator const &other) const;
long operator-(ndindex_iterator const &other) const;
};
diff --git a/pythran/pythonic/include/types/array.hpp b/pythran/pythonic/include/types/array.hpp
index d4e6c1e06..b9bbe722b 100644
--- a/pythran/pythonic/include/types/array.hpp
+++ b/pythran/pythonic/include/types/array.hpp
@@ -129,6 +129,10 @@ namespace types
{
return index < other.index;
}
+ bool operator<=(array_iterator const &other) const
+ {
+ return index <= other.index;
+ }
array_iterator &operator=(array_iterator const &other)
{
index = other.index;
@@ -181,8 +185,8 @@ namespace types
using shape_t = types::array_tuple<long, value>;
template <size_t I>
- auto shape() const -> decltype(details::extract_shape(*this,
- utils::int_<I>{}))
+ auto shape() const
+ -> decltype(details::extract_shape(*this, utils::int_<I>{}))
{
return details::extract_shape(*this, utils::int_<I>{});
}
diff --git a/pythran/pythonic/include/types/numpy_expr.hpp b/pythran/pythonic/include/types/numpy_expr.hpp
index 0d13801a6..a6fc24d67 100644
--- a/pythran/pythonic/include/types/numpy_expr.hpp
+++ b/pythran/pythonic/include/types/numpy_expr.hpp
@@ -116,7 +116,7 @@ namespace types
}
auto operator*() const -> decltype(this->_dereference(
- utils::make_index_sequence<sizeof...(Iters)>{}))
+ utils::make_index_sequence<sizeof...(Iters)>{}))
{
return _dereference(utils::make_index_sequence<sizeof...(Iters)>{});
}
@@ -240,6 +240,11 @@ namespace types
{
return _lt(other, utils::int_<sizeof...(Iters)>{});
}
+
+ bool operator<=(numpy_expr_iterator const &other) const
+ {
+ return *this < other || *this == other;
+ }
};
#ifdef USE_XSIMD
template <class E, class Op, class Steps, class SIters, class... Iters>
@@ -279,7 +284,7 @@ namespace types
}
auto operator*() const -> decltype(this->_dereference(
- utils::make_index_sequence<sizeof...(Iters)>{}))
+ utils::make_index_sequence<sizeof...(Iters)>{}))
{
return _dereference(utils::make_index_sequence<sizeof...(Iters)>{});
}
@@ -439,7 +444,7 @@ namespace types
}
auto operator*() const -> decltype(this->_dereference(
- utils::make_index_sequence<sizeof...(Iters)>{}))
+ utils::make_index_sequence<sizeof...(Iters)>{}))
{
return _dereference(utils::make_index_sequence<sizeof...(Iters)>{});
}
@@ -583,9 +588,9 @@ namespace types
}
template <size_t... J, class Arg, class Shp, class... S>
- auto
- make_subslice(utils::index_sequence<J...>, Arg const &arg, Shp const &shp,
- std::tuple<S...> const &ss) -> decltype(arg(std::get<J>(ss)...))
+ auto make_subslice(utils::index_sequence<J...>, Arg const &arg,
+ Shp const &shp, std::tuple<S...> const &ss)
+ -> decltype(arg(std::get<J>(ss)...))
{
// we need to adapt_slice to take broadcasting into account
return arg(adapt_slice(
@@ -708,15 +713,14 @@ namespace types
}
template <class... Indices>
- auto map_fast(Indices... indices) const
- -> decltype(this->_map_fast(
- array_tuple<long, sizeof...(Indices)>{{indices...}},
- utils::make_index_sequence<sizeof...(Args)>{}));
+ auto map_fast(Indices... indices) const -> decltype(this->_map_fast(
+ array_tuple<long, sizeof...(Indices)>{{indices...}},
+ utils::make_index_sequence<sizeof...(Args)>{}));
public:
template <size_t I>
auto shape() const -> decltype(details::init_shape_element<I>(
- args, valid_indices<value, std::tuple<Args...>>{}))
+ args, valid_indices<value, std::tuple<Args...>>{}))
{
return details::init_shape_element<I>(
args, valid_indices<value, std::tuple<Args...>>{});
@@ -819,9 +823,8 @@ namespace types
return Op{}(std::get<I>(args)[s]...);
}
template <class S>
- auto operator[](S s) const
- -> decltype((*this)._index(
- (s.lower, s), utils::make_index_sequence<sizeof...(Args)>{}))
+ auto operator[](S s) const -> decltype((*this)._index(
+ (s.lower, s), utils::make_index_sequence<sizeof...(Args)>{}))
{
return _index(s, utils::make_index_sequence<sizeof...(Args)>{});
}
diff --git a/pythran/pythonic/include/types/str.hpp b/pythran/pythonic/include/types/str.hpp
index ca373c734..73a39f35a 100644
--- a/pythran/pythonic/include/types/str.hpp
+++ b/pythran/pythonic/include/types/str.hpp
@@ -275,6 +275,14 @@ namespace types
{
return curr != other.curr;
}
+ bool operator<(string_iterator const &other) const
+ {
+ return curr < other.curr;
+ }
+ bool operator<=(string_iterator const &other) const
+ {
+ return curr <= other.curr;
+ }
std::ptrdiff_t operator-(string_iterator const &other) const
{
return curr - other.curr;
@@ -328,9 +336,8 @@ namespace operator_
{
template <size_t N, class Arg>
- auto mod(const char (&fmt)[N],
- Arg &&arg) -> decltype(pythonic::types::str(fmt) %
- std::forward<Arg>(arg));
+ auto mod(const char (&fmt)[N], Arg &&arg)
+ -> decltype(pythonic::types::str(fmt) % std::forward<Arg>(arg));
pythonic::types::str add(char const *self, char const *other);

View File

@@ -1,5 +1,5 @@
<multibuild>
<package>test-py310</package>
<package>test-py311</package>
<package>test-py312</package>
<package>test-py313</package>
</multibuild>

343
np.patch Normal file
View File

@@ -0,0 +1,343 @@
From f78b07d7648a1efe543c01cc4019928791eb39e9 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <serge.guelton@telecom-bretagne.eu>
Date: Sun, 8 Jun 2025 19:00:10 +0200
Subject: [PATCH 1/4] Use more generic way of checking bool value of an object
This avoid bad interaction with numpy.bool_ as reported in #2322
---
pythran/pythonic/types/bool.hpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pythran/pythonic/types/bool.hpp b/pythran/pythonic/types/bool.hpp
index 35ac01d37..1436871f1 100644
--- a/pythran/pythonic/types/bool.hpp
+++ b/pythran/pythonic/types/bool.hpp
@@ -28,7 +28,7 @@ inline bool from_python<bool>::convert(PyObject *obj)
else if (obj == Py_False)
return false;
else
- return PyInt_AsLong(obj);
+ return PyObject_IsTrue(obj);
}
PYTHONIC_NS_END
From 2847f56dbbb388aeab5f3cab18c70fe26298d254 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <serge.guelton@telecom-bretagne.eu>
Date: Tue, 10 Jun 2025 07:23:03 +0200
Subject: [PATCH 2/4] Add support for numpy.frombuffer
Even though we have very partial support for bytes in Pythran
---
pythran/analyses/dependencies.py | 2 ++
pythran/backend.py | 8 +++++
pythran/pythonic/include/numpy/frombuffer.hpp | 26 ++++++++++++++
pythran/pythonic/numpy/frombuffer.hpp | 35 +++++++++++++++++++
pythran/tables.py | 1 +
pythran/tests/test_numpy_func0.py | 14 +++++++-
pythran/tests/test_numpy_random.py | 4 +--
pythran/types/conversion.py | 1 +
8 files changed, 88 insertions(+), 3 deletions(-)
create mode 100644 pythran/pythonic/include/numpy/frombuffer.hpp
create mode 100644 pythran/pythonic/numpy/frombuffer.hpp
diff --git a/pythran/analyses/dependencies.py b/pythran/analyses/dependencies.py
index f153558f8..e0988e103 100644
--- a/pythran/analyses/dependencies.py
+++ b/pythran/analyses/dependencies.py
@@ -127,6 +127,8 @@ def visit_Yield(self, node):
def visit_Constant(self, node):
if node.value is None:
self.result.add(('builtins', 'None'))
+ elif isinstance(node.value, bytes):
+ self.result.add(('types', 'str')) # FIXME: using str as backend
elif isinstance(node.value, str):
self.result.add(('types', 'str'))
elif isinstance(node.value, complex):
diff --git a/pythran/backend.py b/pythran/backend.py
index e5728ab3e..7b12773fa 100644
--- a/pythran/backend.py
+++ b/pythran/backend.py
@@ -1012,6 +1012,14 @@ def visit_Constant(self, node):
ret = 'pythonic::builtins::None'
elif isinstance(node.value, bool):
ret = str(node.value).lower()
+ elif isinstance(node.value, bytes):
+ quoted = "".join('\\' + hex(b)[1:] for b in node.value)
+ # FIXME: using str type as backend
+ if len(node.value) == 1:
+ quoted = quoted.replace("'", r"\'")
+ ret = 'pythonic::types::chr(\'' + quoted + '\')'
+ else:
+ ret = 'pythonic::types::str("' + quoted + '")'
elif isinstance(node.value, str):
quoted = quote_cxxstring(node.value)
if len(node.value) == 1:
diff --git a/pythran/pythonic/include/numpy/frombuffer.hpp b/pythran/pythonic/include/numpy/frombuffer.hpp
new file mode 100644
index 000000000..bb685d8b5
--- /dev/null
+++ b/pythran/pythonic/include/numpy/frombuffer.hpp
@@ -0,0 +1,26 @@
+#ifndef PYTHONIC_INCLUDE_NUMPY_FROMBUFFER_HPP
+#define PYTHONIC_INCLUDE_NUMPY_FROMBUFFER_HPP
+
+#include "pythonic/include/numpy/float64.hpp"
+#include "pythonic/include/types/list.hpp"
+#include "pythonic/include/types/ndarray.hpp"
+#include "pythonic/include/types/str.hpp"
+#include "pythonic/include/utils/functor.hpp"
+
+#include <limits>
+#include <sstream>
+
+PYTHONIC_NS_BEGIN
+
+namespace numpy
+{
+ template <class dtype = functor::float64>
+ types::ndarray<typename dtype::type, types::pshape<long>>
+ frombuffer(types::str const &string, dtype d = dtype(), long count = -1,
+ long offset = 0);
+
+ DEFINE_FUNCTOR(pythonic::numpy, frombuffer);
+} // namespace numpy
+PYTHONIC_NS_END
+
+#endif
diff --git a/pythran/pythonic/numpy/frombuffer.hpp b/pythran/pythonic/numpy/frombuffer.hpp
new file mode 100644
index 000000000..c0f625142
--- /dev/null
+++ b/pythran/pythonic/numpy/frombuffer.hpp
@@ -0,0 +1,35 @@
+#ifndef PYTHONIC_NUMPY_FROMBUFFER_HPP
+#define PYTHONIC_NUMPY_FROMBUFFER_HPP
+
+#include "pythonic/include/numpy/frombuffer.hpp"
+
+#include "pythonic/types/list.hpp"
+#include "pythonic/types/ndarray.hpp"
+#include "pythonic/types/str.hpp"
+#include "pythonic/utils/functor.hpp"
+
+#include <limits>
+#include <sstream>
+
+PYTHONIC_NS_BEGIN
+
+namespace numpy
+{
+ template <class dtype>
+ types::ndarray<typename dtype::type, types::pshape<long>>
+ frombuffer(types::str const &string, dtype d, long count, long offset)
+ {
+ if (count < 0)
+ count = string.size() / sizeof(typename dtype::type);
+ types::pshape<long> shape = count;
+ utils::shared_ref<types::raw_array<typename dtype::type>> buffer(
+ std::get<0>(shape));
+ auto const *tstring =
+ reinterpret_cast<typename dtype::type const *>(string.c_str()) + offset;
+ std::copy(tstring, tstring + std::get<0>(shape), buffer->data);
+ return {buffer, shape};
+ }
+} // namespace numpy
+PYTHONIC_NS_END
+
+#endif
diff --git a/pythran/tables.py b/pythran/tables.py
index a61709d19..bf0d9b220 100644
--- a/pythran/tables.py
+++ b/pythran/tables.py
@@ -3752,6 +3752,7 @@ def expand_numpy_2_args(args, defaults=None, force=False):
"fmin": UFunc(REDUCED_BINARY_UFUNC),
"fmod": UFunc(BINARY_UFUNC),
"frexp": ConstFunctionIntr(),
+ "frombuffer": ConstFunctionIntr(),
"fromfunction": ConstFunctionIntr(),
"fromiter": ConstFunctionIntr(args=("iterable", "dtype", "count"),
defaults=(-1,)),
diff --git a/pythran/tests/test_numpy_func0.py b/pythran/tests/test_numpy_func0.py
index 41f716d90..a97a43c50 100644
--- a/pythran/tests/test_numpy_func0.py
+++ b/pythran/tests/test_numpy_func0.py
@@ -560,11 +560,23 @@ def test_fromstring1(self):
self.run_test("def np_fromstring1(a): from numpy import fromstring, uint8 ; a = '\x01\x02\x03\x04' ; return fromstring(a, uint8,3)", '\x01\x02\x03\x04', np_fromstring1=[str])
def test_fromstring2(self):
- self.run_test("def np_fromstring2(a): from numpy import fromstring, uint32 ; return fromstring(a, uint32,-1, ' ')", '1 2 3 4', np_fromstring2=[str])
+ self.run_test("def np_fromstring2(a): from numpy import fromstring, uint32 ; return fromstring(a, uint32,-1, ' ')", '1 20 3 40', np_fromstring2=[str])
def test_fromstring3(self):
self.run_test("def np_fromstring3(a): from numpy import fromstring, uint32 ; return fromstring(a, uint32,2, ',')", '1,2, 3, 4', np_fromstring3=[str])
+ def test_frombuffer0(self):
+ self.run_test("def np_frombuffer0(a): from numpy import frombuffer, uint8 ; return frombuffer(b'\x01\x02' * a, uint8)", 1, np_frombuffer0=[int])
+
+ def test_frombuffer1(self):
+ self.run_test("def np_frombuffer1(a): from numpy import frombuffer, uint8 ; return frombuffer(b'\x01\x02\x03\x04' * a, uint8, 3)", 1, np_frombuffer1=[int])
+
+ def test_frombuffer2(self):
+ self.run_test("def np_frombuffer2(a): from numpy import frombuffer, uint16 ; return frombuffer(a * b'\x01\x02', uint16)", 1, np_frombuffer2=[int])
+
+ def test_frombuffer3(self):
+ self.run_test("def np_frombuffer3(a): from numpy import frombuffer, int8 ; return frombuffer(a * b'\x01\x02\x03\x04', int8, 3, 1)", 1, np_frombuffer3=[int])
+
def test_outer0(self):
self.run_test("def np_outer0(x): from numpy import outer ; return outer(x, x+2)", numpy.arange(6).reshape(2,3), np_outer0=[NDArray[int,:,:]])
diff --git a/pythran/tests/test_numpy_random.py b/pythran/tests/test_numpy_random.py
index aa3f22815..6547a2e92 100644
--- a/pythran/tests/test_numpy_random.py
+++ b/pythran/tests/test_numpy_random.py
@@ -638,9 +638,9 @@ def test_numpy_random_bytes1(self):
self.run_test("""
def numpy_random_bytes1(n):
from numpy.random import bytes
- from numpy import mean, fromstring, uint8, asarray
+ from numpy import mean, frombuffer, uint8, asarray
a = bytes(n)
- return (abs(mean(asarray(fromstring(a, uint8), dtype=float)) - 127.5) < .05)""",
+ return (abs(mean(asarray(frombuffer(a, uint8), dtype=float)) - 127.5) < .05)""",
10 ** 8, numpy_random_bytes1=[int])
###########################################################################
diff --git a/pythran/types/conversion.py b/pythran/types/conversion.py
index e149b7fb4..b3c86b5fd 100644
--- a/pythran/types/conversion.py
+++ b/pythran/types/conversion.py
@@ -9,6 +9,7 @@
PYTYPE_TO_CTYPE_TABLE = {
numpy.uint: 'npy_uint',
#
+ bytes: 'pythonic::types::str', # FIXME: using types::str as backend
complex: 'std::complex<double>',
bool: 'bool',
int: 'long',
From c01d4224ca0c34af6157ee4e82893a82f3e9bb43 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <serge.guelton@telecom-bretagne.eu>
Date: Sun, 8 Jun 2025 19:15:28 +0200
Subject: [PATCH 3/4] Do not test binary mode of numpy.fromstring for recent
numpy version
It's no longer supported as of numpy 2.3, see
https://numpy.org/devdocs/release/2.3.0-notes.html and
https://github.com/numpy/numpy/pull/28254
Fix #2322
---
pythran/tests/test_numpy_func0.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/pythran/tests/test_numpy_func0.py b/pythran/tests/test_numpy_func0.py
index a97a43c50..91c37e979 100644
--- a/pythran/tests/test_numpy_func0.py
+++ b/pythran/tests/test_numpy_func0.py
@@ -553,9 +553,11 @@ def test_fromfile5(self):
finally:
os.remove(temp_name)
+ @unittest.skipIf(np_version > version.Version("2.2"), reason="np.fromstring no longer supports binary mode")
def test_fromstring0(self):
self.run_test("def np_fromstring0(a): from numpy import fromstring, uint8 ; return fromstring(a, uint8)", '\x01\x02', np_fromstring0=[str])
+ @unittest.skipIf(np_version > version.Version("2.2"), reason="np.fromstring no longer supports binary mode")
def test_fromstring1(self):
self.run_test("def np_fromstring1(a): from numpy import fromstring, uint8 ; a = '\x01\x02\x03\x04' ; return fromstring(a, uint8,3)", '\x01\x02\x03\x04', np_fromstring1=[str])
From ef869953fbb16a31c5eb06c72296d4f23cf73e55 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <serge.guelton@telecom-bretagne.eu>
Date: Sun, 8 Jun 2025 19:22:49 +0200
Subject: [PATCH 4/4] Adjust doc validation to recent python 3.13
- force COLUMNS width for reproducible argparse help output
- gast Constant pretty printing has changed
Fix #2317
---
.github/workflows/core.yml | 2 +-
docs/TUTORIAL.rst | 6 +++---
pythran/tests/test_xdoc.py | 14 +++++++++++++-
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/core.yml b/.github/workflows/core.yml
index 5dca25973..8609be87e 100644
--- a/.github/workflows/core.yml
+++ b/.github/workflows/core.yml
@@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
- python-version: [3.7, 3.9, 3.11, 3.12, pypy-3.9]
+ python-version: [3.7, 3.9, 3.11, 3.12, 3.13, pypy-3.9]
cpp-version: [g++-12, clang-13]
steps:
- uses: actions/checkout@v2
diff --git a/docs/TUTORIAL.rst b/docs/TUTORIAL.rst
index e1dd80c4f..31ff4fffc 100644
--- a/docs/TUTORIAL.rst
+++ b/docs/TUTORIAL.rst
@@ -20,7 +20,7 @@ Python ships a standard module, ``ast`` to turn Python code into an AST. For ins
>>> code = "a=1"
>>> tree = ast.parse(code) # turn the code into an AST
>>> print(ast.dump(tree)) # view it as a string
- Module(body=[Assign(targets=[Name(id='a', ctx=Store())], value=Constant(value=1, kind=None))])
+ Module(body=[Assign(targets=[Name(id='a', ctx=Store())], value=Constant(value=1))])
Deciphering the above line, one learns that the single assignment is parsed as
a module containing a single statement, which is an assignment to a single
@@ -33,7 +33,7 @@ Eventually, one needs to parse more complex codes, and things get a bit more cry
... return n if n< 2 else fib(n-1) + fib(n-2)"""
>>> tree = ast.parse(fib_src)
>>> print(ast.dump(tree))
- Module(body=[FunctionDef(name='fib', args=arguments(args=[Name(id='n', ctx=Param())]), body=[Return(value=IfExp(test=Compare(left=Name(id='n', ctx=Load()), ops=[Lt()], comparators=[Constant(value=2, kind=None)]), body=Name(id='n', ctx=Load()), orelse=BinOp(left=Call(func=Name(id='fib', ctx=Load()), args=[BinOp(left=Name(id='n', ctx=Load()), op=Sub(), right=Constant(value=1, kind=None))]), op=Add(), right=Call(func=Name(id='fib', ctx=Load()), args=[BinOp(left=Name(id='n', ctx=Load()), op=Sub(), right=Constant(value=2, kind=None))]))))])])
+ Module(body=[FunctionDef(name='fib', args=arguments(args=[Name(id='n', ctx=Param())]), body=[Return(value=IfExp(test=Compare(left=Name(id='n', ctx=Load()), ops=[Lt()], comparators=[Constant(value=2)]), body=Name(id='n', ctx=Load()), orelse=BinOp(left=Call(func=Name(id='fib', ctx=Load()), args=[BinOp(left=Name(id='n', ctx=Load()), op=Sub(), right=Constant(value=1))]), op=Add(), right=Call(func=Name(id='fib', ctx=Load()), args=[BinOp(left=Name(id='n', ctx=Load()), op=Sub(), right=Constant(value=2))]))))])])
The idea remains the same. The whole Python syntax is described in
http://docs.python.org/2/library/ast.html and is worth a glance, otherwise
@@ -199,7 +199,7 @@ constant expressions. In the previous code, there is only two constant
>>> ce = pm.gather(analyses.ConstantExpressions, tree)
>>> sorted(map(ast.dump, ce))
- ["Attribute(value=Name(id='math', ctx=Load()), attr='cos', ctx=Load())", 'Constant(value=3, kind=None)']
+ ["Attribute(value=Name(id='math', ctx=Load()), attr='cos', ctx=Load())", 'Constant(value=3)']
One of the most critical analyse of Pythran is the points-to analysis. There
are two flavors of this analyse, one that computes an over-set of the aliased
diff --git a/pythran/tests/test_xdoc.py b/pythran/tests/test_xdoc.py
index 862dec1fa..1dddf36ca 100644
--- a/pythran/tests/test_xdoc.py
+++ b/pythran/tests/test_xdoc.py
@@ -20,6 +20,8 @@ class TestDoctest(unittest.TestCase):
@pytest.mark.skipif(sys.platform == "win32",
reason="We should create a file for windows.")
+ @pytest.mark.skipif(sys.version_info < (3, 13),
+ reason="ast output changed with 3.13")
def test_tutorial(self):
failed, _ = doctest.testfile('../../docs/TUTORIAL.rst')
self.assertEqual(failed, 0)
@@ -34,9 +36,19 @@ def test_internal(self):
@pytest.mark.skipif(sys.platform == "win32",
reason="We should create a file for windows.")
+ @pytest.mark.skipif(sys.version_info <= (3, 12),
+ reason="argparse output changed with 3.13")
def test_cli(self):
tmpfile = self.adapt_rst('../../docs/CLI.rst')
- failed, _ = doctest.testfile(tmpfile, False)
+ columns = os.environ.get('COLUMNS', None)
+ os.environ['COLUMNS'] = '80'
+ try:
+ failed, _ = doctest.testfile(tmpfile, False)
+ finally:
+ if columns is None:
+ del os.environ['COLUMNS']
+ else:
+ os.environ['COLUMNS'] = columns
self.assertEqual(failed, 0)
os.remove(tmpfile)

View File

@@ -1,33 +0,0 @@
From 6b61e8a6b3dddab13b88e51309cbdf2f28247960 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <serge.guelton@telecom-bretagne.eu>
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):
"""

View File

@@ -1,105 +0,0 @@
From 9261d30aa9618cb2a5a698d39752263b076f2d4b Mon Sep 17 00:00:00 2001
From: serge-sans-paille <serge.guelton@telecom-bretagne.eu>
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 <class E>
+ E fix(E const &e)
+ {
+ if (std::is_integral<E>::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])

View File

@@ -1,3 +1,150 @@
-------------------------------------------------------------------
Mon Sep 29 21:32:36 UTC 2025 - Dirk Müller <dmueller@suse.com>
- prepare for py314 tests
-------------------------------------------------------------------
Tue Aug 19 07:47:56 UTC 2025 - Markéta Machová <mmachova@suse.com>
- Drop np-frombuffer.patch and np-fromstring.patch and substitute
them with np.patch, which is a PR which contains both of them
and also other fixes, unskip the previously skipped test
-------------------------------------------------------------------
Thu Aug 14 08:37:43 UTC 2025 - Markéta Machová <mmachova@suse.com>
- Add upstream np-fromstring.patch and np-frombuffer.patch to fix
tests with NumPy 2.3, skip one additional failing test
-------------------------------------------------------------------
Mon Jul 7 18:31:44 UTC 2025 - Ben Greiner <code@bnavigator.de>
- Do not run any tests on Leap 16.0 due to lack of dependencies
This is part of hplip enablement on 16.0
-------------------------------------------------------------------
Wed Jun 18 10:47:55 UTC 2025 - Matej Cepl <mcepl@cepl.eu>
- Skip pythran/tests/test_xdoc.py::TestDoctest::test_utils, which
is failing with 3.13.5 (gh#serge-sans-paille/pythran#2326).
-------------------------------------------------------------------
Fri Jun 13 18:54:09 UTC 2025 - Ben Greiner <code@bnavigator.de>
- Add GCC15_pythran-PR2325-missing-operators.patch
* Tracking Issues for this and the previous patch:
gcc#120622
gh#serge-sans-paille/pythran#2321
gh#serge-sans-paille/pythran#2324
gh#serge-sans-paille/pythran#2325
boo#1243779
-------------------------------------------------------------------
Thu Jun 12 10:03:44 UTC 2025 - Ana Guerrero <ana.guerrero@suse.com>
- Fix failures with GCC15:
GCC15_fix_Add-missing-operators-to-nditerator.patch
-------------------------------------------------------------------
Thu May 29 19:47:43 UTC 2025 - Ben Greiner <code@bnavigator.de>
- Update to 0.18.0 - balafenn
* no upstream changelog.
## git commits (a few non-relevant filtered)
* Fix uninitialized iexpr assignment
* Fix folding of comparison operators
* Take augassign into account when removing nested functions
* Fix local processing in presence of else: clause in for loop
* Fix detection of c++ compiler
* Traverse augassign when computing scopes
* Reproducible ContainerOf iteration
* Fix overload handling for NoneType
* Fix type inference in presence of augassign
* Improve forward substitution in presence of augassign
* Remove dead code in tests
* Faster (and common!) implementation of make_integer_sequence
* Only register a node in name_to_nodes if the combiner was
succesful
* Reproducible aliasing ordering
* Reproducible nested functions removal
* Reproducible topological order
* Verify reproducibility of c++ output
* Reproducible (because sortable) alias order
* Stateless PType
* Reproducible local declaration order
* Reproducible identifiers generation
* Reproducible include order
* More flexible implementation of default list
* Fix typing issue under complex slice combination
* Add support for nonlocal keyword
* Fix bug in nested function remover
* Cope with numpy.bool deprecation
* Be more informative about UnboundIdentifierError
* Optimize generation of cxx types
* Use inheritance instead of member type for __combined
specialization
* Remove redundant extra combiner for Assigned Subscript
* Improve nested functions support
* Harden error reporting: Do not trap when no lineno is available
* Handle folding of static_if
* Fix constness of std::get on an array_base r-value
* Make none_type hashable
* Get rid of clang workaround for containers of one element
* Simplify backend type cache & fix handling of LTypes
* Fix constness of dict's bool operator
* Specialize dict for None Key
* Drop support for builtins.None in favor of None
* Add handling of numpy.bool in tog
* replace quansight-labs/setup-python with actions/setup-python
* [ci] Dump more info when compiling system dep
* [test] Fix sign comparison code
* [ci] Test unvendoring of xsimd and boost
* Disable inlining in while test
* Python 3.13 compat: detect removed find_exe
* Fix test portability issue for ipython magic
* Adjust --cflags-pythran-only implementation
* ENH: improvements to pythran-config for build system
integration
* Have FastGExpr load its dependency in a lazy manner
* Move GIL manipulation right after module creation
* Better modeling of analyse and transformations
* Fix pythran support for numpy.float128
* Defer initialisation of global variables until the module is
actually created
* Fix interaction between static if and nested loop / function
* Allow tuple with combinable items as array initializer
* Have pythran generate freethreading compatible code
* Remove legacy logic that handled py2/py3 compatibility
* Remove any usage of __PYTHRAN__ macro
* Make sure blas function argument actually have an associated
buffer
* Provide user hint when trying to use c-style type names in
pythran spec
* [typing] Support union type in annotation
* Restore type qualifiers dropped by
b8cd84b5a5ab5222d65781a0194916ad555bf70c
* Add basic support for type annotation
* [constant folding] Correctly model restrict_assign in constant
folding
- Update test flavors
-------------------------------------------------------------------
Mon Nov 18 18:01:06 UTC 2024 - Ben Greiner <code@bnavigator.de>
- Update to 0.17.0
* Support parsing annotated statement
* Document and test Meson integration
* Update / improve Blas detection, including scipy-openblas
* Fix usage of Blas library
* Improve error reporting
* Support array module
* Reduce dependency on setuptools
* Faster forward substitution
* Enforce default optimization level to `-O2`
- Drop upstreamed numpy-2.1-interval.patch
- Drop upstreamed numpy-2.1-support.patch
- Drop upstreamed support-gast-0.6.patch
-------------------------------------------------------------------
Sun Sep 1 13:28:40 UTC 2024 - Dirk Müller <dmueller@suse.com>

View File

@@ -1,7 +1,7 @@
#
# spec file for package python-pythran
#
# Copyright (c) 2024 SUSE LLC
# Copyright (c) 2025 SUSE LLC and contributors
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -25,9 +25,6 @@
%else
%define psuffix -%{flavor}
%bcond_without test
%if "%{flavor}" != "test-py310"
%define skip_python310 1
%endif
%if "%{flavor}" != "test-py311"
%define skip_python311 1
%endif
@@ -37,8 +34,11 @@
%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})
%if "%{flavor}" != "test-py314"
%define skip_python314 1
%endif
# Skip empty buildsets on tumbleweed, or non py311 flavors on sle15_python_module_pythons, or any testing on leap 16
%if "%{shrink:%{pythons}}" == "" || ("%pythons" == "python311" && 0%{?skip_python311}) || (0%{?is_opensuse} && 0%{?suse_version} == 1600)
ExclusiveArch: donotbuild
%define python_module() %flavor-not-enabled-in-buildset-for-suse-%{?suse_version}
%else
@@ -47,7 +47,7 @@ ExclusiveArch: x86_64
%endif
Name: python-pythran%{psuffix}
Version: 0.16.1
Version: 0.18.0
Release: 0
Summary: Ahead of Time compiler for numeric kernels
License: BSD-3-Clause
@@ -55,10 +55,12 @@ URL: https://github.com/serge-sans-paille/pythran
# Tests are only availble from the 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 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
# PATCH-FIX-UPSTREAM: https://github.com/serge-sans-paille/pythran/commit/14b78f0db9cbd253414b751d14644843354e7557
Patch0: GCC15_fix_Add-missing-operators-to-nditerator.patch
# PATCH-FIX-UPSTREAM: https://github.com/serge-sans-paille/pythran/commit/623fa5031df7ec5c3dfe6789bf608cf11ac95c36
Patch1: GCC15_pythran-PR2325-missing-operators.patch
# PATCH-FIX-UPSTREAM https://github.com/serge-sans-paille/pythran/pull/2323 Various fixes with recent numpy
Patch2: np.patch
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
@@ -138,8 +140,11 @@ libs=openblas
EOF
export PYTHRANRC=$PWD/config.pythranrc
%endif
# gh#serge-sans-paille/pythran#2317 -- changed AST in Py3.13
# gh#serge-sans-paille/pythran#2326
python313_skip_tests=("-k" "not (test_tutorial or test_utils)")
# pytest_extra_args is for debug builds with local defines on command line
%pytest %{?jobs:-n %jobs} %{?pytest_extra_args}
%pytest %{?jobs:-n %jobs} %{?pytest_extra_args} "${$python_skip_tests[@]}"
%endif
%if !%{with test}

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a2510f370a7d62761844daa112a455785e5a6a216cf9ae704c3926fe68eb65ce
size 3680817

3
pythran-0.18.0-gh.tar.gz Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d3f879f86fde1c0eb62e02e52fbe30e2468fb59d8751b951b7cc6faf16e7df3e
size 3707538

View File

@@ -1,76 +0,0 @@
From 840a0e706ec39963aec6bcd1f118bf33177c20b4 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <serge.guelton@telecom-bretagne.eu>
Date: Sat, 29 Jun 2024 19:13:02 +0200
Subject: [PATCH] Bump gast requirement to 0.6.0
This mostly helps for harmonious behavior wrt. gast.dump
---
docs/TUTORIAL.rst | 8 ++++----
pythran/utils.py | 2 +-
requirements.txt | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/docs/TUTORIAL.rst b/docs/TUTORIAL.rst
index 09f6902f9..7692547eb 100644
--- a/docs/TUTORIAL.rst
+++ b/docs/TUTORIAL.rst
@@ -20,7 +20,7 @@ Python ships a standard module, ``ast`` to turn Python code into an AST. For ins
>>> code = "a=1"
>>> tree = ast.parse(code) # turn the code into an AST
>>> print(ast.dump(tree)) # view it as a string
- Module(body=[Assign(targets=[Name(id='a', ctx=Store(), annotation=None, type_comment=None)], value=Constant(value=1, kind=None), type_comment=None)], type_ignores=[])
+ Module(body=[Assign(targets=[Name(id='a', ctx=Store())], value=Constant(value=1, kind=None))])
Deciphering the above line, one learns that the single assignment is parsed as
a module containing a single statement, which is an assignment to a single
@@ -33,7 +33,7 @@ Eventually, one needs to parse more complex codes, and things get a bit more cry
... return n if n< 2 else fib(n-1) + fib(n-2)"""
>>> tree = ast.parse(fib_src)
>>> print(ast.dump(tree))
- Module(body=[FunctionDef(name='fib', args=arguments(args=[Name(id='n', ctx=Param(), annotation=None, type_comment=None)], posonlyargs=[], vararg=None, kwonlyargs=[], kw_defaults=[], kwarg=None, defaults=[]), body=[Return(value=IfExp(test=Compare(left=Name(id='n', ctx=Load(), annotation=None, type_comment=None), ops=[Lt()], comparators=[Constant(value=2, kind=None)]), body=Name(id='n', ctx=Load(), annotation=None, type_comment=None), orelse=BinOp(left=Call(func=Name(id='fib', ctx=Load(), annotation=None, type_comment=None), args=[BinOp(left=Name(id='n', ctx=Load(), annotation=None, type_comment=None), op=Sub(), right=Constant(value=1, kind=None))], keywords=[]), op=Add(), right=Call(func=Name(id='fib', ctx=Load(), annotation=None, type_comment=None), args=[BinOp(left=Name(id='n', ctx=Load(), annotation=None, type_comment=None), op=Sub(), right=Constant(value=2, kind=None))], keywords=[]))))], decorator_list=[], returns=None, type_comment=None)], type_ignores=[])
+ Module(body=[FunctionDef(name='fib', args=arguments(args=[Name(id='n', ctx=Param())]), body=[Return(value=IfExp(test=Compare(left=Name(id='n', ctx=Load()), ops=[Lt()], comparators=[Constant(value=2, kind=None)]), body=Name(id='n', ctx=Load()), orelse=BinOp(left=Call(func=Name(id='fib', ctx=Load()), args=[BinOp(left=Name(id='n', ctx=Load()), op=Sub(), right=Constant(value=1, kind=None))]), op=Add(), right=Call(func=Name(id='fib', ctx=Load()), args=[BinOp(left=Name(id='n', ctx=Load()), op=Sub(), right=Constant(value=2, kind=None))]))))])])
The idea remains the same. The whole Python syntax is described in
http://docs.python.org/2/library/ast.html and is worth a glance, otherwise
@@ -199,7 +199,7 @@ constant expressions. In the previous code, there is only two constant
>>> ce = pm.gather(analyses.ConstantExpressions, tree)
>>> sorted(map(ast.dump, ce))
- ["Attribute(value=Name(id='math', ctx=Load(), annotation=None, type_comment=None), attr='cos', ctx=Load())", 'Constant(value=3, kind=None)']
+ ["Attribute(value=Name(id='math', ctx=Load()), attr='cos', ctx=Load())", 'Constant(value=3, kind=None)']
One of the most critical analyse of Pythran is the points-to analysis. There
are two flavors of this analyse, one that computes an over-set of the aliased
@@ -210,7 +210,7 @@ variable, and one that computes an under set. ``Aliases`` computes an over-set::
>>> al = pm.gather(analyses.Aliases, tree)
>>> returned = tree.body[-1].body[-1].value
>>> print(ast.dump(returned))
- Name(id='b', ctx=Load(), annotation=None, type_comment=None)
+ Name(id='b', ctx=Load())
>>> sorted(a.id for a in al[returned])
['c', 'd']
diff --git a/pythran/utils.py b/pythran/utils.py
index 2d7a67327..55a7e8ad6 100644
--- a/pythran/utils.py
+++ b/pythran/utils.py
@@ -106,7 +106,7 @@ def get_variable(assignable):
... slice=ast.Name('j', ast.Load(), None, None),
... ctx=ast.Load())
>>> ast.dump(get_variable(ref))
- "Name(id='a', ctx=Load(), annotation=None, type_comment=None)"
+ "Name(id='a', ctx=Load())"
"""
msg = "Only name and subscript can be assigned."
assert isinstance(assignable, (ast.Name, ast.Subscript)), msg
diff --git a/requirements.txt b/requirements.txt
index fd6a738e5..c7a25c52a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,5 +1,5 @@
ply>=3.4
setuptools
-gast~=0.5.0
+gast~=0.6.0
numpy
beniget~=0.4.0