Skip to content

Commit 4a3c420

Browse files
committed
fix boost python
1 parent 242ee25 commit 4a3c420

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

bindings/python/boost/src/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function(mgis_python_module name output_name)
2020
# include directories
2121
target_include_directories(${module}
2222
SYSTEM
23-
PRIVATE "${PROJECT_SOURCE_DIR}/bindings/python/include"
23+
PRIVATE "${PROJECT_SOURCE_DIR}/bindings/python/boost/include"
2424
PRIVATE "${Boost_INCLUDE_DIRS}")
2525
# Link flags for python modules.
2626
#
@@ -37,7 +37,7 @@ function(mgis_python_module name output_name)
3737
target_link_libraries(${module}
3838
PRIVATE
3939
MFrontGenericInterface
40-
${CONAN_LIBS} Python::NumPy Python::Module)
40+
${CONAN_LIBS} Python::Python Python::NumPy)
4141
else(APPLE)
4242
target_link_libraries(${module}
4343
PRIVATE
@@ -57,7 +57,8 @@ function(mgis_python_module name output_name)
5757
target_link_libraries(${module}
5858
PRIVATE
5959
MFrontGenericInterface
60-
${Boost_NUMPY_LIBRARY} ${Boost_PYTHON_LIBRARY} Python::NumPy Python::Module)
60+
${Boost_NUMPY_LIBRARY} ${Boost_PYTHON_LIBRARY}
61+
Python::Python Python::NumPy)
6162
endif(disable_python_library_linking)
6263
endif(MGIS_USES_CONAN)
6364
# installation

bindings/python/boost/src/NumPySupport.cxx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,26 @@
1313
*/
1414

1515
#include <numpy/ndarrayobject.h>
16-
#include <boost/python/numpy.hpp>
16+
// #include <boost/python/numpy.hpp>
1717
#include "MGIS/Raise.hxx"
1818
#include "MGIS/Python/NumPySupport.hxx"
1919

2020
namespace mgis::python {
2121

22-
void initializeNumPy() {
23-
Py_Initialize();
24-
boost::python::numpy::initialize();
25-
} // end of initializeNumPy
22+
#if PY_MAJOR_VERSION == 2
23+
static void wrapInitializeNumPy() { import_array(); }
24+
#else
25+
static void* wrapInitializeNumPy() {
26+
import_array();
27+
return nullptr;
28+
}
29+
#endif
30+
31+
void initializeNumPy() { wrapInitializeNumPy(); } // end of initializeNumPy
32+
33+
// void initializeNumPy() { wrapInitializeNumPy(); } // end of initializeNumPy void initializeNumPy() {
34+
// boost::python::numpy::initialize();
35+
// } // end of initializeNumPy
2636

2737
boost::python::object wrapInNumPyArray(std::span<double>& v) {
2838
npy_intp dims[1] = {static_cast<npy_intp>(v.size())};

0 commit comments

Comments
 (0)