From db1093d93e6e53d39b7023f7030c26d17a104937 Mon Sep 17 00:00:00 2001 From: Justin Carpentier Date: Tue, 27 Aug 2024 15:23:04 +0200 Subject: [PATCH 1/5] core: include minimal headers for numpy.hpp --- include/eigenpy/numpy.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/eigenpy/numpy.hpp b/include/eigenpy/numpy.hpp index f5aee019..dcfd48dd 100644 --- a/include/eigenpy/numpy.hpp +++ b/include/eigenpy/numpy.hpp @@ -5,7 +5,7 @@ #ifndef __eigenpy_numpy_hpp__ #define __eigenpy_numpy_hpp__ -#include "eigenpy/fwd.hpp" +#include "eigenpy/config.hpp" #ifndef PY_ARRAY_UNIQUE_SYMBOL #define PY_ARRAY_UNIQUE_SYMBOL EIGENPY_ARRAY_API @@ -50,6 +50,8 @@ static inline void _Py_SET_TYPE(PyObject* o, PyTypeObject* type) { #define EIGENPY_GET_PY_ARRAY_TYPE(array) PyArray_MinScalarType(array)->type_num #endif +#include + namespace eigenpy { void EIGENPY_DLLAPI import_numpy(); int EIGENPY_DLLAPI PyArray_TypeNum(PyTypeObject* type); From f82cd350a32d38b4d46900f4a6acccc27c16e2f1 Mon Sep 17 00:00:00 2001 From: Justin Carpentier Date: Tue, 27 Aug 2024 15:23:28 +0200 Subject: [PATCH 2/5] core: use NPY_API_SYMBOL_ATTRIBUTE for Numpy >= 2.x --- include/eigenpy/numpy.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/eigenpy/numpy.hpp b/include/eigenpy/numpy.hpp index dcfd48dd..fd63f3b8 100644 --- a/include/eigenpy/numpy.hpp +++ b/include/eigenpy/numpy.hpp @@ -11,6 +11,11 @@ #define PY_ARRAY_UNIQUE_SYMBOL EIGENPY_ARRAY_API #endif +// For compatibility with Numpy 2.x +// See +// https://numpy.org/devdocs/reference/c-api/array.html#c.NPY_API_SYMBOL_ATTRIBUTE +#define NPY_API_SYMBOL_ATTRIBUTE + #include #ifdef NPY_1_8_API_VERSION #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION From 2632b8685023684f73ce20d5dcc06ae6c03c1ae1 Mon Sep 17 00:00:00 2001 From: Justin Carpentier Date: Tue, 27 Aug 2024 15:23:43 +0200 Subject: [PATCH 3/5] ci/conda: test on NumPy 2.x --- .github/workflows/conda/environment_all.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/conda/environment_all.yml b/.github/workflows/conda/environment_all.yml index eac1ec0f..5d8e21c5 100644 --- a/.github/workflows/conda/environment_all.yml +++ b/.github/workflows/conda/environment_all.yml @@ -4,7 +4,7 @@ channels: dependencies: - eigen - cmake - - numpy<2.0 + - numpy - pkg-config - boost - ccache From 4f99421755840004e64c08b5e027eacd70a3a2b6 Mon Sep 17 00:00:00 2001 From: Joris Vaillant Date: Tue, 24 Sep 2024 17:53:45 +0200 Subject: [PATCH 4/5] core: Try to use DLLAPI to fix Windows link --- include/eigenpy/numpy.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/eigenpy/numpy.hpp b/include/eigenpy/numpy.hpp index fd63f3b8..f74349dd 100644 --- a/include/eigenpy/numpy.hpp +++ b/include/eigenpy/numpy.hpp @@ -14,7 +14,7 @@ // For compatibility with Numpy 2.x // See // https://numpy.org/devdocs/reference/c-api/array.html#c.NPY_API_SYMBOL_ATTRIBUTE -#define NPY_API_SYMBOL_ATTRIBUTE +#define NPY_API_SYMBOL_ATTRIBUTE EIGENPY_DLLAPI #include #ifdef NPY_1_8_API_VERSION From 61c1d93b9239c933a5e2d98fffee61e1881ba7a2 Mon Sep 17 00:00:00 2001 From: Joris Vaillant Date: Wed, 25 Sep 2024 16:59:55 +0200 Subject: [PATCH 5/5] changelog: Add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66562df5..291eac76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Add more general visitor `GenericMapPythonVisitor` for map types test `boost::unordered_map` ([#504](https://github.com/stack-of-tasks/eigenpy/pull/504)) - Support for non-[default-contructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible) types in map types ([#504](https://github.com/stack-of-tasks/eigenpy/pull/504)) - Add type_info helpers ([#502](https://github.com/stack-of-tasks/eigenpy/pull/502)) +- Add NumPy 2 support ([#496](https://github.com/stack-of-tasks/eigenpy/pull/496)) ### Changed