From 680c6a43e624ca340b17dfd6a5049c7337be941f Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Thu, 31 Jul 2025 09:50:36 +0000 Subject: [PATCH 1/9] Update PyBind11 guard to 3.x release (#324) Fix #323 --- include/xtensor-python/pytensor.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/xtensor-python/pytensor.hpp b/include/xtensor-python/pytensor.hpp index 3eac157..e3746cc 100644 --- a/include/xtensor-python/pytensor.hpp +++ b/include/xtensor-python/pytensor.hpp @@ -214,7 +214,7 @@ namespace xt static self_type ensure(pybind11::handle h); static bool check_(pybind11::handle h); -#if PYBIND11_VERSION_MAJOR == 2 && PYBIND11_VERSION_MINOR >= 3 +#if (PYBIND11_VERSION_MAJOR == 2 && PYBIND11_VERSION_MINOR >= 3) || (PYBIND11_VERSION_MAJOR >= 3) // Prevent ambiguous overload resolution for operators defined for // both xt::xcontainer_semantic and pybind11::object. using semantic_base::operator+=; From afc1672f50e2901f95a32b4cd9f480fa28545468 Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Thu, 31 Jul 2025 15:28:06 +0000 Subject: [PATCH 2/9] Fix pybind11 compatibility for version 3.x (#326) Fix #323 - again --- include/xtensor-python/pyarray.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/xtensor-python/pyarray.hpp b/include/xtensor-python/pyarray.hpp index 0854fb3..c24a793 100644 --- a/include/xtensor-python/pyarray.hpp +++ b/include/xtensor-python/pyarray.hpp @@ -195,7 +195,7 @@ namespace xt static self_type ensure(pybind11::handle h); static bool check_(pybind11::handle h); -#if PYBIND11_VERSION_MAJOR == 2 && PYBIND11_VERSION_MINOR >= 3 +#if (PYBIND11_VERSION_MAJOR == 2 && PYBIND11_VERSION_MINOR >= 3) || PYBIND11_VERSION_MAJOR >= 3 // Prevent ambiguous overload resolution for operators defined for // both xt::xcontainer_semantic and pybind11::object. using semantic_base::operator+=; From 2f59002d9930fe61fee19f0808444d0411ac1c70 Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Thu, 31 Jul 2025 17:39:00 +0200 Subject: [PATCH 3/9] Upgraded to pybind11 3 (#325) --- README.md | 2 +- environment-dev.yml | 2 +- include/xtensor-python/pycontainer.hpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index acf2df1..3f24121 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,7 @@ from the `docs` subdirectory. | `xtensor-python` | `xtensor` | `pybind11` | |------------------|-----------|------------------| -| master | ^0.26.0 | >=2.6.1,<3 | +| master | ^0.26.0 | >=2.6.1,<4 | | 0.28.0 | ^0.26.0 | >=2.6.1,<3 | | 0.27.0 | ^0.25.0 | >=2.6.1,<3 | | 0.26.1 | ^0.24.0 | ~2.4.3 | diff --git a/environment-dev.yml b/environment-dev.yml index 72275dd..876678b 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -8,7 +8,7 @@ dependencies: # Host dependencies - xtensor>=0.26,<0.27 - numpy>=2.0 - - pybind11>=2.12.0,<3 + - pybind11>=2.12.0,<4 # Test dependencies - setuptools - pytest diff --git a/include/xtensor-python/pycontainer.hpp b/include/xtensor-python/pycontainer.hpp index 5e80a32..f01c390 100644 --- a/include/xtensor-python/pycontainer.hpp +++ b/include/xtensor-python/pycontainer.hpp @@ -129,7 +129,7 @@ namespace xt private: -#if PYBIND11_VERSION_MAJOR == 2 && PYBIND11_VERSION_MINOR >= 3 +#if (PYBIND11_VERSION_MAJOR == 2 && PYBIND11_VERSION_MINOR >= 3) || PYBIND11_VERSION_MAJOR >= 3 // Prevent ambiguous overload resolution for operators defined for // both xt::xcontainer and pybind11::object. using pybind11::object::operator~; From 30ce883824a5a1acc23a519913773d714dd38c8f Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Fri, 10 Oct 2025 11:06:48 +0200 Subject: [PATCH 4/9] Upgrade (#329) Co-authored-by: Roy Kid --- CMakeLists.txt | 4 ++-- environment-dev.yml | 2 +- test_python/setup.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e6b9227..b0f98d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ message(STATUS "xtensor-python v${${PROJECT_NAME}_VERSION}") # Dependencies # ============ -set(xtensor_REQUIRED_VERSION 0.26.0) +set(xtensor_REQUIRED_VERSION 0.27.0) if(TARGET xtensor) set(xtensor_VERSION ${XTENSOR_VERSION_MAJOR}.${XTENSOR_VERSION_MINOR}.${XTENSOR_VERSION_PATCH}) # Note: This is not SEMVER compatible comparison @@ -48,7 +48,7 @@ endif() find_package(Python COMPONENTS Interpreter REQUIRED) -set(pybind11_REQUIRED_VERSION 2.6.1) +set(pybind11_REQUIRED_VERSION 3.0.0) if (NOT TARGET pybind11::headers) # Defaults to ON for cmake >= 3.18 # https://github.com/pybind/pybind11/blob/35ff42b56e9d34d9a944266eb25f2c899dbdfed7/CMakeLists.txt#L96 diff --git a/environment-dev.yml b/environment-dev.yml index 876678b..4d3b27b 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -6,7 +6,7 @@ dependencies: - cmake - ninja # Host dependencies - - xtensor>=0.26,<0.27 + - xtensor>=0.27,<0.28 - numpy>=2.0 - pybind11>=2.12.0,<4 # Test dependencies diff --git a/test_python/setup.py b/test_python/setup.py index 58dbd2d..895f60d 100644 --- a/test_python/setup.py +++ b/test_python/setup.py @@ -78,8 +78,8 @@ def cpp_flag(compiler): """Return the -std=c++17 compiler flag and errors when the flag is no available. """ - if has_flag(compiler, '-std=c++17'): - return '-std=c++17' + if has_flag(compiler, '-std=c++20'): + return '-std=c++20' else: raise RuntimeError('C++17 support is required by xtensor!') @@ -104,7 +104,7 @@ def build_extensions(self): opts.append('-fvisibility=hidden') elif ct == 'msvc': opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version()) - opts.append('/std:c++17') + opts.append('/std:c++20') for ext in self.extensions: ext.extra_compile_args = opts build_ext.build_extensions(self) From 53132f41441120ac695ad3643e78e480797feba2 Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Fri, 10 Oct 2025 09:07:20 +0000 Subject: [PATCH 5/9] Add missing default constructor for stride iterator (#327) It's a requirement for being adapted by std::reverse_iterator --- include/xtensor-python/pystrides_adaptor.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/xtensor-python/pystrides_adaptor.hpp b/include/xtensor-python/pystrides_adaptor.hpp index fde929a..bde3923 100644 --- a/include/xtensor-python/pystrides_adaptor.hpp +++ b/include/xtensor-python/pystrides_adaptor.hpp @@ -89,6 +89,8 @@ namespace xt using iterator_category = std::random_access_iterator_tag; using shape_pointer = typename pystrides_adaptor::shape_type; + pystrides_iterator() = default; + inline pystrides_iterator(pointer current, shape_pointer shape) : p_current(current) , p_shape(shape) From f95746f7edc97d85d6997bde32364bf37c69cee7 Mon Sep 17 00:00:00 2001 From: "Matwey V. Kornilov" Date: Fri, 10 Oct 2025 12:14:47 +0300 Subject: [PATCH 6/9] Install as arch-independent (#309) xternsor-python is header only library, so prefer arch-independed paths cmake. References: * https://github.com/xtensor-stack/xtl/commit/d877d94836aff4d0f727acf3eaab8f4880ecb625 * https://github.com/xtensor-stack/xtensor/commit/7738389861044c9618c7d59fb7602f7dddc1df7f Co-authored-by: Johan Mabille --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0f98d3..1dba9ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,13 +124,14 @@ export(EXPORT ${PROJECT_NAME}-targets install(FILES ${XTENSOR_PYTHON_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xtensor-python) + configure_file(${PROJECT_NAME}.pc.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" DESTINATION "${CMAKE_INSTALL_DATADIR}/pkgconfig/") -set(XTENSOR_PYTHON_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE +set(XTENSOR_PYTHON_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}" CACHE STRING "install path for xtensor-pythonConfig.cmake") configure_package_config_file(${PROJECT_NAME}Config.cmake.in From 03e5da2712ae96cf089a9d03ae29aa51389031e5 Mon Sep 17 00:00:00 2001 From: "Matwey V. Kornilov" Date: Fri, 10 Oct 2025 12:26:18 +0300 Subject: [PATCH 7/9] Reenable python tests (#315) Co-authored-by: Johan Mabille --- test_python/test_pyarray.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test_python/test_pyarray.py b/test_python/test_pyarray.py index 9955ee7..4e7d5eb 100644 --- a/test_python/test_pyarray.py +++ b/test_python/test_pyarray.py @@ -23,7 +23,6 @@ import numpy as np class XtensorTest(TestCase): - """ def test_rm(self): xt.test_rm(np.array([10], dtype=int)) @@ -62,7 +61,6 @@ def test_example3(self): with self.assertRaises(TypeError): x = np.arange(3*2).reshape(3, 2) xt.example3_xfixed2(x) - """ def test_broadcast_addition(self): x = np.array([[2., 3., 4., 5.]]) y = np.array([[1., 2., 3., 4.], @@ -73,7 +71,6 @@ def test_broadcast_addition(self): [3., 5., 7., 9.]]) z = xt.array_addition(x, y) np.testing.assert_allclose(z, res, 1e-12) - """ def test_broadcast_subtraction(self): x = np.array([[4., 5., 6., 7.]]) y = np.array([[4., 3., 2., 1.], @@ -307,7 +304,6 @@ def test_native_casters(self): self.assertEqual(adapter.shape, (2, 2)) adapter[1, 1] = -3 self.assertEqual(arr[0, 5], -3) - """ class AttributeTest(TestCase): From 7065f733f4839066d1092bad38b9cbbdd9fc6dee Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Fri, 10 Oct 2025 11:36:50 +0200 Subject: [PATCH 8/9] Release 0.29.0 --- README.md | 3 ++- include/xtensor-python/xtensor_python_config.hpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3f24121..e50064b 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,8 @@ from the `docs` subdirectory. | `xtensor-python` | `xtensor` | `pybind11` | |------------------|-----------|------------------| -| master | ^0.26.0 | >=2.6.1,<4 | +| master | ^0.27.0 | >=2.6.1,<4 | +| 0.29.0 | ^0.27.0 | >=2.6.1,<4 | | 0.28.0 | ^0.26.0 | >=2.6.1,<3 | | 0.27.0 | ^0.25.0 | >=2.6.1,<3 | | 0.26.1 | ^0.24.0 | ~2.4.3 | diff --git a/include/xtensor-python/xtensor_python_config.hpp b/include/xtensor-python/xtensor_python_config.hpp index f6840a7..4bb0882 100644 --- a/include/xtensor-python/xtensor_python_config.hpp +++ b/include/xtensor-python/xtensor_python_config.hpp @@ -11,7 +11,7 @@ #define XTENSOR_PYTHON_CONFIG_HPP #define XTENSOR_PYTHON_VERSION_MAJOR 0 -#define XTENSOR_PYTHON_VERSION_MINOR 28 +#define XTENSOR_PYTHON_VERSION_MINOR 29 #define XTENSOR_PYTHON_VERSION_PATCH 0 #endif From 2b46b48c074dbdefa80e0c890e12a05a97db28d8 Mon Sep 17 00:00:00 2001 From: Sylvain Corlay Date: Fri, 31 Oct 2025 22:47:53 +0100 Subject: [PATCH 9/9] Replace link to gitter with Zulip link. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e50064b..fbe1946 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![GHA OSX](https://github.com/xtensor-stack/xtensor/actions/workflows/osx.yml/badge.svg)](https://github.com/xtensor-stack/xtensor/actions/workflows/osx.yml) [![GHA Windows](https://github.com/xtensor-stack/xtensor/actions/workflows/windows.yml/badge.svg)](https://github.com/xtensor-stack/xtensor/actions/workflows/windows.yml) [![Documentation](http://readthedocs.org/projects/xtensor-python/badge/?version=latest)](https://xtensor-python.readthedocs.io/en/latest/?badge=latest) -[![Join the Gitter Chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/QuantStack/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Zulip](https://img.shields.io/badge/social_chat-zulip-blue.svg)](https://xtensor.zulipchat.com/#narrow/channel/539553-Ask-anything) Python bindings for the [xtensor](https://github.com/xtensor-stack/xtensor) C++ multi-dimensional array library.