From 486f81847653c2c27c09dbb51c6fa2c3b6a63ab2 Mon Sep 17 00:00:00 2001 From: Alexis DUBURCQ Date: Sat, 2 Nov 2024 10:04:40 +0100 Subject: [PATCH 1/6] Update numpy.hpp --- include/eigenpy/numpy.hpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/include/eigenpy/numpy.hpp b/include/eigenpy/numpy.hpp index bf738b32..fec71be8 100644 --- a/include/eigenpy/numpy.hpp +++ b/include/eigenpy/numpy.hpp @@ -11,20 +11,25 @@ #define PY_ARRAY_UNIQUE_SYMBOL EIGENPY_ARRAY_API #endif -// For compatibility with Numpy 2.x -// See +// 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 +#define NPY_API_SYMBOL_ATTRIBUTE + +// Numpy headers drags Python with them. As a result, it +// is necessary to include the desired Python library before +// Numpy picks the default one, as it would be impossible to +// to change it afterward. Boost::Python provides a helper +// specifically dedicated to selecting the right Python +// library depending on build type, so let's make use of it. +#include #include #ifdef NPY_1_8_API_VERSION #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #endif -/* Allow compiling against NumPy 1.x and 2.x - see: - https://github.com/numpy/numpy/blob/afea8fd66f6bdbde855f5aff0b4e73eb0213c646/doc/source/reference/c-api/array.rst#L1224 -*/ +// Allow compiling against NumPy 1.x and 2.x. See: +// https://github.com/numpy/numpy/blob/afea8fd66f6bdbde855f5aff0b4e73eb0213c646/doc/source/reference/c-api/array.rst#L1224 #if NPY_ABI_VERSION < 0x02000000 #define PyArray_DescrProto PyArray_Descr #endif From e40b1adebd786956f237565b0bece3ba1d79a2df Mon Sep 17 00:00:00 2001 From: Alexis DUBURCQ Date: Sun, 3 Nov 2024 12:57:04 +0100 Subject: [PATCH 2/6] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33ca836e..71e9445c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Fixed + +- Fix Python library linkage for Debug build on Windows ([[#514](https://github.com/stack-of-tasks/eigenpy/pull/514)]) + ## [3.10.1] - 2024-10-30 ### Added From b145e4509eebd87d1248dec655811d6ddb6b2d75 Mon Sep 17 00:00:00 2001 From: Alexis DUBURCQ Date: Sun, 3 Nov 2024 12:57:33 +0100 Subject: [PATCH 3/6] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71e9445c..f26e678e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed -- Fix Python library linkage for Debug build on Windows ([[#514](https://github.com/stack-of-tasks/eigenpy/pull/514)]) +- Fix Python library linkage for Debug build on Windows ([#514](https://github.com/stack-of-tasks/eigenpy/pull/514)) ## [3.10.1] - 2024-10-30 From f366cab3f8e30897d9d6a50a0e219161aad781be Mon Sep 17 00:00:00 2001 From: Alexis DUBURCQ Date: Sun, 3 Nov 2024 15:46:54 +0100 Subject: [PATCH 4/6] Update numpy.hpp --- 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 fec71be8..6cac2d0e 100644 --- a/include/eigenpy/numpy.hpp +++ b/include/eigenpy/numpy.hpp @@ -13,7 +13,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 // Numpy headers drags Python with them. As a result, it // is necessary to include the desired Python library before From d979fe2c40dd93653a224c71afb6415641413319 Mon Sep 17 00:00:00 2001 From: Joris Vaillant Date: Mon, 4 Nov 2024 17:12:17 +0100 Subject: [PATCH 5/6] core: Apply clang-format --- include/eigenpy/numpy.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/eigenpy/numpy.hpp b/include/eigenpy/numpy.hpp index 6cac2d0e..477791ff 100644 --- a/include/eigenpy/numpy.hpp +++ b/include/eigenpy/numpy.hpp @@ -16,10 +16,10 @@ #define NPY_API_SYMBOL_ATTRIBUTE EIGENPY_DLLAPI // Numpy headers drags Python with them. As a result, it -// is necessary to include the desired Python library before +// is necessary to include the desired Python library before // Numpy picks the default one, as it would be impossible to -// to change it afterward. Boost::Python provides a helper -// specifically dedicated to selecting the right Python +// to change it afterward. Boost::Python provides a helper +// specifically dedicated to selecting the right Python // library depending on build type, so let's make use of it. #include From 71c8f8bed311aed6f37bd279bc0616d8d36e5804 Mon Sep 17 00:00:00 2001 From: Alexis DUBURCQ Date: Thu, 14 Nov 2024 14:29:06 +0100 Subject: [PATCH 6/6] core: Precise in comment it's a Windows specific issue --- include/eigenpy/numpy.hpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/eigenpy/numpy.hpp b/include/eigenpy/numpy.hpp index 477791ff..f4b7419f 100644 --- a/include/eigenpy/numpy.hpp +++ b/include/eigenpy/numpy.hpp @@ -15,12 +15,15 @@ // https://numpy.org/devdocs/reference/c-api/array.html#c.NPY_API_SYMBOL_ATTRIBUTE #define NPY_API_SYMBOL_ATTRIBUTE EIGENPY_DLLAPI +// When building with MSVC, Python headers use some pragma operator to link +// against the Python DLL. +// Unfortunately, it can link against the wrong build type of the library +// leading to some linking issue. +// Boost::Python provides a helper specifically dedicated to selecting the right +// Python library depending on build type, so let's make use of it. // Numpy headers drags Python with them. As a result, it -// is necessary to include the desired Python library before -// Numpy picks the default one, as it would be impossible to -// to change it afterward. Boost::Python provides a helper -// specifically dedicated to selecting the right Python -// library depending on build type, so let's make use of it. +// is necessary to include this helper before including Numpy. +// See: https://github.com/stack-of-tasks/eigenpy/pull/514 #include #include