diff --git a/.github/workflows/conda/environment_all.yml b/.github/workflows/conda/environment_all.yml index eac1ec0fa..5d8e21c5e 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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 66562df51..291eac761 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 diff --git a/include/eigenpy/numpy.hpp b/include/eigenpy/numpy.hpp index f5aee0199..f74349dd8 100644 --- a/include/eigenpy/numpy.hpp +++ b/include/eigenpy/numpy.hpp @@ -5,12 +5,17 @@ #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 #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 EIGENPY_DLLAPI + #include #ifdef NPY_1_8_API_VERSION #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION @@ -50,6 +55,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);