diff --git a/CMakeLists.txt b/CMakeLists.txt index ee3b641..eec3118 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,16 +19,24 @@ 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) # 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 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}" @@ -43,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 @@ -112,8 +120,8 @@ install(DIRECTORY boost # add submodules ADD_SUBDIRECTORY(libs/numpy/src) -ADD_SUBDIRECTORY(libs/numpy/example) -ADD_SUBDIRECTORY(libs/numpy/test) +#ADD_SUBDIRECTORY(libs/numpy/example) +#ADD_SUBDIRECTORY(libs/numpy/test) if (BUILD_DOCS) ADD_SUBDIRECTORY(libs/numpy/doc) diff --git a/libs/numpy/cmake/FindPythonLibsNew.cmake b/libs/numpy/cmake/FindPythonLibsNew.cmake index b2a5d60..a163046 100644 --- a/libs/numpy/cmake/FindPythonLibsNew.cmake +++ b/libs/numpy/cmake/FindPythonLibsNew.cmake @@ -70,6 +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()); print(s.get_python_inc(plat_specific=True)); print(s.get_python_lib(plat_specific=True)); print(s.get_config_var('SO')); @@ -96,10 +97,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 +165,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}") diff --git a/libs/numpy/src/CMakeLists.txt b/libs/numpy/src/CMakeLists.txt index af11cb3..1e36040 100644 --- a/libs/numpy/src/CMakeLists.txt +++ b/libs/numpy/src/CMakeLists.txt @@ -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 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();