Skip to content

Commit

Permalink
Merge pull request #496 from jcarpent/topic/devel
Browse files Browse the repository at this point in the history
Fix compatibility issue on Windows for NumPy 2.x
  • Loading branch information
jcarpent authored Sep 26, 2024
2 parents 3586fcb + 61c1d93 commit 9dde142
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/conda/environment_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
dependencies:
- eigen
- cmake
- numpy<2.0
- numpy
- pkg-config
- boost
- ccache
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 8 additions & 1 deletion include/eigenpy/numpy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 9dde142

Please sign in to comment.