diff --git a/.github/workflows/conda/environment_all.yml b/.github/workflows/conda/environment_all.yml index eac1ec0fa45488a12327dd4ea6f1c793e95f3291..5d8e21c5e962eedcb51514929baa082b84efb592 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 66562df51bf0db139944f2415b57788dc7f00fb2..291eac7614f8d68dd13c7b24f3dfc84cd4986b73 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<std::string, int>` ([#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 f5aee0199f6994f6b87bb3f8bd88aa29185ab478..f74349dd8b22b8886c4cd6306c342556927ca7c0 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 <numpy/numpyconfig.h> #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 <complex> + namespace eigenpy { void EIGENPY_DLLAPI import_numpy(); int EIGENPY_DLLAPI PyArray_TypeNum(PyTypeObject* type);