From 9ac107a25a99de074b411a12117e5b6f12b40988 Mon Sep 17 00:00:00 2001 From: Toby Smithe Date: Tue, 16 Apr 2013 22:44:26 +0100 Subject: [PATCH 1/8] fix up cmake for debian --- libs/numpy/cmake/FindPythonLibsNew.cmake | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libs/numpy/cmake/FindPythonLibsNew.cmake b/libs/numpy/cmake/FindPythonLibsNew.cmake index b2a5d60..7253fab 100644 --- a/libs/numpy/cmake/FindPythonLibsNew.cmake +++ b/libs/numpy/cmake/FindPythonLibsNew.cmake @@ -70,7 +70,7 @@ execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" "from distutils import sysconfig as s;import sys;import struct; print('.'.join(str(v) for v in sys.version_info)); print(s.PREFIX); -print(s.get_python_inc(plat_specific=True)); +print(s.get_python_inc()); print(s.get_python_lib(plat_specific=True)); print(s.get_config_var('SO')); print(hasattr(sys, 'gettotalrefcount')+0); @@ -96,10 +96,11 @@ string(REGEX REPLACE "\n" ";" _PYTHON_VALUES ${_PYTHON_VALUES}) list(GET _PYTHON_VALUES 0 _PYTHON_VERSION_LIST) list(GET _PYTHON_VALUES 1 PYTHON_PREFIX) list(GET _PYTHON_VALUES 2 PYTHON_INCLUDE_DIR) -list(GET _PYTHON_VALUES 3 PYTHON_SITE_PACKAGES) -list(GET _PYTHON_VALUES 4 PYTHON_MODULE_EXTENSION) -list(GET _PYTHON_VALUES 5 PYTHON_IS_DEBUG) -list(GET _PYTHON_VALUES 6 PYTHON_SIZEOF_VOID_P) +list(GET _PYTHON_VALUES 3 PYTHON_PLATFORM_INCLUDE_DIR) +list(GET _PYTHON_VALUES 4 PYTHON_SITE_PACKAGES) +list(GET _PYTHON_VALUES 5 PYTHON_MODULE_EXTENSION) +list(GET _PYTHON_VALUES 6 PYTHON_IS_DEBUG) +list(GET _PYTHON_VALUES 7 PYTHON_SIZEOF_VOID_P) # Make sure the Python has the same pointer-size as the chosen compiler if(NOT ${PYTHON_SIZEOF_VOID_P} MATCHES ${CMAKE_SIZEOF_VOID_P}) @@ -163,7 +164,7 @@ MARK_AS_ADVANCED( # cache entries because they are meant to specify the location of a single # library. We now set the variables listed by the documentation for this # module. -SET(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") +SET(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR};${PYTHON_PLATFORM_INCLUDE_DIR}") SET(PYTHON_LIBRARIES "${PYTHON_LIBRARY}") SET(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}") From b3f54a88f427896c142736b2914040e8f8a44bfb Mon Sep 17 00:00:00 2001 From: Toby Smithe Date: Tue, 16 Apr 2013 22:45:48 +0100 Subject: [PATCH 2/8] forgot a line --- libs/numpy/cmake/FindPythonLibsNew.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/numpy/cmake/FindPythonLibsNew.cmake b/libs/numpy/cmake/FindPythonLibsNew.cmake index 7253fab..a163046 100644 --- a/libs/numpy/cmake/FindPythonLibsNew.cmake +++ b/libs/numpy/cmake/FindPythonLibsNew.cmake @@ -71,6 +71,7 @@ execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" print('.'.join(str(v) for v in sys.version_info)); print(s.PREFIX); print(s.get_python_inc()); +print(s.get_python_inc(plat_specific=True)); print(s.get_python_lib(plat_specific=True)); print(s.get_config_var('SO')); print(hasattr(sys, 'gettotalrefcount')+0); From ff32ee9b36291dc468943e73c19acf68caf5054a Mon Sep 17 00:00:00 2001 From: Toby Smithe Date: Wed, 17 Apr 2013 01:09:27 +0100 Subject: [PATCH 3/8] fix so as to build with python3, and do not build examples --- CMakeLists.txt | 2 +- libs/numpy/src/numpy.cpp | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ee3b641..ae099ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,7 +112,7 @@ install(DIRECTORY boost # add submodules ADD_SUBDIRECTORY(libs/numpy/src) -ADD_SUBDIRECTORY(libs/numpy/example) +#ADD_SUBDIRECTORY(libs/numpy/example) ADD_SUBDIRECTORY(libs/numpy/test) if (BUILD_DOCS) diff --git a/libs/numpy/src/numpy.cpp b/libs/numpy/src/numpy.cpp index 883d971..365f83f 100644 --- a/libs/numpy/src/numpy.cpp +++ b/libs/numpy/src/numpy.cpp @@ -12,9 +12,19 @@ namespace boost namespace numpy { -void initialize(bool register_scalar_converters) +#if PY_MAJOR_VERSION >= 3 +int +#else +void +#endif +do_import_array() { import_array(); +} + +void initialize(bool register_scalar_converters) +{ + do_import_array(); import_ufunc(); if (register_scalar_converters) dtype::register_scalar_converters(); From 94d532669465ce24d39762d03b97f083498348fa Mon Sep 17 00:00:00 2001 From: Toby Smithe Date: Wed, 7 Aug 2013 15:45:58 +0100 Subject: [PATCH 4/8] Fix search for boost-python -- NB ONLY PYTHON 3 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae099ae..40ad104 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ find_package(NumPy REQUIRED) # set(Boost_USE_STATIC_LIBS ON) # set(Boost_USE_MULTITHREADED ON) # set(Boost_USE_STATIC_RUNTIME ON) -FIND_PACKAGE(Boost COMPONENTS python REQUIRED) +FIND_PACKAGE(Boost COMPONENTS python-py33 REQUIRED) message( STATUS "found boost:" "\nINCLUDE: ${Boost_INCLUDE_DIRS}" From 2f6d719e4e0e9247581ed7ea11d93d715e03b837 Mon Sep 17 00:00:00 2001 From: Toby Smithe Date: Tue, 27 Aug 2013 18:12:14 +0100 Subject: [PATCH 5/8] Build as static library --- CMakeLists.txt | 6 +++--- libs/numpy/src/CMakeLists.txt | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40ad104..1981000 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,10 +25,10 @@ find_package(NumPy REQUIRED) # find boost # -# set(Boost_USE_STATIC_LIBS ON) +set(Boost_USE_STATIC_LIBS ON) # set(Boost_USE_MULTITHREADED ON) # set(Boost_USE_STATIC_RUNTIME ON) -FIND_PACKAGE(Boost COMPONENTS python-py33 REQUIRED) +FIND_PACKAGE(Boost COMPONENTS python-py27 REQUIRED) message( STATUS "found boost:" "\nINCLUDE: ${Boost_INCLUDE_DIRS}" @@ -113,7 +113,7 @@ install(DIRECTORY boost # add submodules ADD_SUBDIRECTORY(libs/numpy/src) #ADD_SUBDIRECTORY(libs/numpy/example) -ADD_SUBDIRECTORY(libs/numpy/test) +#ADD_SUBDIRECTORY(libs/numpy/test) if (BUILD_DOCS) ADD_SUBDIRECTORY(libs/numpy/doc) diff --git a/libs/numpy/src/CMakeLists.txt b/libs/numpy/src/CMakeLists.txt index af11cb3..6a3d431 100644 --- a/libs/numpy/src/CMakeLists.txt +++ b/libs/numpy/src/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(boost_numpy ${LIBRARY_TYPE} +add_library(boost_numpy STATIC # ${LIBRARY_TYPE} # header files ../../../boost/numpy/dtype.hpp ../../../boost/numpy/internal.hpp @@ -18,6 +18,8 @@ add_library(boost_numpy ${LIBRARY_TYPE} numpy.cpp ) +TARGET_LINK_LIBRARIES(boost_numpy ${Boost_LIBRARIES}) + install(TARGETS boost_numpy ARCHIVE DESTINATION lib LIBRARY DESTINATION lib From 047f0c3651e391dba0c6f6700a90fade86e943aa Mon Sep 17 00:00:00 2001 From: Toby Smithe Date: Tue, 27 Aug 2013 19:21:09 +0100 Subject: [PATCH 6/8] Centralise python version control --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1981000..7d6e4df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,11 @@ find_package(NumPy REQUIRED) set(Boost_USE_STATIC_LIBS ON) # set(Boost_USE_MULTITHREADED ON) # set(Boost_USE_STATIC_RUNTIME ON) -FIND_PACKAGE(Boost COMPONENTS python-py27 REQUIRED) +if(BOOST_COMPONENTS) + FIND_PACKAGE(Boost COMPONENTS ${BOOST_COMPONENTS} REQUIRED) +else() + FIND_PACKAGE(Boost COMPONENTS python-py27 REQUIRED) +endif() message( STATUS "found boost:" "\nINCLUDE: ${Boost_INCLUDE_DIRS}" From 34ace9d01efb7a9cf0fe421b86c78400e9632f65 Mon Sep 17 00:00:00 2001 From: Toby Smithe Date: Thu, 26 Sep 2013 23:58:24 +0100 Subject: [PATCH 7/8] Update CMakeLists.txt to check for pre-set Python data --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d6e4df..d56f88d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,11 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin CACHE PATH "Output directory for executables and DLL's.") # find required python packages -find_package(PythonInterp REQUIRED) +if(PYVERSION) + find_package(PythonInterp ${PYVERSION} EXACT) +else() + find_package(PythonInterp REQUIRED) +endif() find_package(PythonLibsNew REQUIRED) find_package(NumPy REQUIRED) From 320664b6bcb564cd47f9517f11821a50535203bb Mon Sep 17 00:00:00 2001 From: Toby Smithe Date: Tue, 18 Feb 2014 23:19:08 +0000 Subject: [PATCH 8/8] Clarify static linking --- CMakeLists.txt | 2 +- libs/numpy/src/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d56f88d..eec3118 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,7 @@ message( STATUS "found boost:" if (WIN32) set(LIBRARY_TYPE STATIC CACHE STRING "type of library to make for boost_numpy") else() - set(LIBRARY_TYPE SHARED CACHE STRING "type of library to make for boost_numpy") + set(LIBRARY_TYPE STATIC CACHE STRING "type of library to make for boost_numpy") endif() # variable controlling building of documentation diff --git a/libs/numpy/src/CMakeLists.txt b/libs/numpy/src/CMakeLists.txt index 6a3d431..1e36040 100644 --- a/libs/numpy/src/CMakeLists.txt +++ b/libs/numpy/src/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(boost_numpy STATIC # ${LIBRARY_TYPE} +add_library(boost_numpy ${LIBRARY_TYPE} # header files ../../../boost/numpy/dtype.hpp ../../../boost/numpy/internal.hpp