Konstantin Ladutenko 2 years ago
parent
commit
f7a759039d
4 changed files with 74 additions and 75 deletions
  1. 1 1
      .github/workflows/cmake.yml
  2. 43 44
      CMakeLists.txt
  3. 29 29
      src/CMakeLists.txt
  4. 1 1
      tox.ini

+ 1 - 1
.github/workflows/cmake.yml

@@ -22,7 +22,7 @@ jobs:
 
       # without GTest and Boost
       - name: Install Python NumPy and Pybind11
-        run: sudo apt install python-numpy python-all-dev python-numpy-dev python3-pybind11 && sudo pip3 install tox
+        run: sudo apt install python-numpy python-all-dev python-numpy-dev python3-pybind11 python3-distutils && sudo pip3 install tox
 
       - name: Configure CMake
         # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.

+ 43 - 44
CMakeLists.txt

@@ -56,47 +56,47 @@ if (Boost_FOUND)
     endif ()
 endif()
 
-#Find Python, NumPy and PyBind11
-find_package(Python COMPONENTS Interpreter Development)
-
-include_directories(${Python_INCLUDE_DIRS})
-
-message("Python_EXECUTABLE: ${Python_EXECUTABLE}")
-message("Python_FOUND: ${Python_FOUND}")
-message("Python_VERSION: ${Python_VERSION}")
-message("Python_Development_FOUND: ${Python_Development_FOUND}")
-message("Python_LIBRARIES: ${Python_LIBRARIES}")
-message("Python_INCLUDE_DIRS: ${Python_INCLUDE_DIRS}")
-
-# Ensure that numpy is installed and read its include dir
-exec_program(${Python_EXECUTABLE}
-        ARGS "-c \"import numpy; print(numpy.get_include())\""
-        OUTPUT_VARIABLE NUMPY_INCLUDE_DIR
-        RETURN_VALUE NUMPY_NOT_FOUND
-        )
-if (NUMPY_NOT_FOUND)
-    message(FATAL_ERROR "NumPy headers not found")
-endif ()
-
-# Ensure that pybind11 is installed and read its include dir
-exec_program(${Python_EXECUTABLE}
-        ARGS "-c \"import pybind11; print(pybind11.get_include())\""
-        OUTPUT_VARIABLE PYBIND11_INCLUDE_DIR
-        RETURN_VALUE PYBIND11_NOT_FOUND
-        )
-if (PYBIND11_NOT_FOUND)
-    message(FATAL_ERROR "PyBind11 headers not found")
-endif ()
-
-# Determine correct extension suffix
-exec_program(${Python_EXECUTABLE}
-        ARGS "-c \"import distutils.sysconfig; print(distutils.sysconfig.get_config_var('EXT_SUFFIX'))\""
-        OUTPUT_VARIABLE EXT_SUFFIX
-        RETURN_VALUE SUFFIX_NOT_FOUND
-        )
-if (SUFFIX_NOT_FOUND)
-    message(FATAL_ERROR "Extension suffix not found")
-endif ()
+##Find Python, NumPy and PyBind11
+#find_package(Python COMPONENTS Interpreter Development)
+#
+#include_directories(${Python_INCLUDE_DIRS})
+#
+#message("Python_EXECUTABLE: ${Python_EXECUTABLE}")
+#message("Python_FOUND: ${Python_FOUND}")
+#message("Python_VERSION: ${Python_VERSION}")
+#message("Python_Development_FOUND: ${Python_Development_FOUND}")
+#message("Python_LIBRARIES: ${Python_LIBRARIES}")
+#message("Python_INCLUDE_DIRS: ${Python_INCLUDE_DIRS}")
+#
+## Ensure that numpy is installed and read its include dir
+#exec_program(${Python_EXECUTABLE}
+#        ARGS "-c \"import numpy; print(numpy.get_include())\""
+#        OUTPUT_VARIABLE NUMPY_INCLUDE_DIR
+#        RETURN_VALUE NUMPY_NOT_FOUND
+#        )
+#if (NUMPY_NOT_FOUND)
+#    message(FATAL_ERROR "NumPy headers not found")
+#endif ()
+#
+## Ensure that pybind11 is installed and read its include dir
+#exec_program(${Python_EXECUTABLE}
+#        ARGS "-c \"import pybind11; print(pybind11.get_include())\""
+#        OUTPUT_VARIABLE PYBIND11_INCLUDE_DIR
+#        RETURN_VALUE PYBIND11_NOT_FOUND
+#        )
+#if (PYBIND11_NOT_FOUND)
+#    message(FATAL_ERROR "PyBind11 headers not found")
+#endif ()
+#
+## Determine correct extension suffix
+#exec_program(${Python_EXECUTABLE}
+#        ARGS "-c \"import distutils.sysconfig; print(distutils.sysconfig.get_config_var('EXT_SUFFIX'))\""
+#        OUTPUT_VARIABLE EXT_SUFFIX
+#        RETURN_VALUE SUFFIX_NOT_FOUND
+#        )
+#if (SUFFIX_NOT_FOUND)
+#    message(FATAL_ERROR "Extension suffix not found")
+#endif ()
 
 #include_directories(src)
 add_subdirectory(src)
@@ -118,7 +118,6 @@ enable_testing()
 add_subdirectory(tests)
 add_test(NAME BuildExtWithPythonSetupPy
    COMMAND ${Python_EXECUTABLE} setup.py build_ext
-    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) 
+    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
 add_test(NAME tox
-    COMMAND tox) 
- 
+    COMMAND tox)

+ 29 - 29
src/CMakeLists.txt

@@ -1,31 +1,31 @@
-# Sources for python extension
-set(_scattnlay_python_sources
-        ${CMAKE_CURRENT_LIST_DIR}/nmie.hpp
-        ${CMAKE_CURRENT_LIST_DIR}/nmie.cc
-        ${CMAKE_CURRENT_LIST_DIR}/nmie-precision.hpp
-        ${CMAKE_CURRENT_LIST_DIR}/special-functions-impl.hpp
-        ${CMAKE_CURRENT_LIST_DIR}/nmie-basic.hpp
-        ${CMAKE_CURRENT_LIST_DIR}/nmie-nearfield.hpp
-        ${CMAKE_CURRENT_LIST_DIR}/pb11_wrapper.cc)
-
-# Define python extension
-add_library(python3-scattnlay SHARED ${_scattnlay_python_sources})
-if (${ENABLE_MP} AND ${Boost_FOUND})
-    target_link_libraries(python3-scattnlay PRIVATE Boost::headers ${Python_LIBRARIES})
-else()
-    target_link_libraries(python3-scattnlay PRIVATE ${Python_LIBRARIES})
-endif()
-target_include_directories(python3-scattnlay PRIVATE ${NUMPY_INCLUDE_DIR} ${PYBIND11_INCLUDE_DIR})
-set_target_properties(python3-scattnlay PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
+## Sources for python extension
+#set(_scattnlay_python_sources
+#        ${CMAKE_CURRENT_LIST_DIR}/nmie.hpp
+#        ${CMAKE_CURRENT_LIST_DIR}/nmie.cc
+#        ${CMAKE_CURRENT_LIST_DIR}/nmie-precision.hpp
+#        ${CMAKE_CURRENT_LIST_DIR}/special-functions-impl.hpp
+#        ${CMAKE_CURRENT_LIST_DIR}/nmie-basic.hpp
+#        ${CMAKE_CURRENT_LIST_DIR}/nmie-nearfield.hpp
+#        ${CMAKE_CURRENT_LIST_DIR}/pb11_wrapper.cc)
+#
+## Define python extension
+#add_library(python3-scattnlay SHARED ${_scattnlay_python_sources})
+#if (${ENABLE_MP} AND ${Boost_FOUND})
+#    target_link_libraries(python3-scattnlay PRIVATE Boost::headers ${Python_LIBRARIES})
+#else()
+#    target_link_libraries(python3-scattnlay PRIVATE ${Python_LIBRARIES})
+#endif()
+#target_include_directories(python3-scattnlay PRIVATE ${NUMPY_INCLUDE_DIR} ${PYBIND11_INCLUDE_DIR})
+#set_target_properties(python3-scattnlay PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
 
-set_target_properties(
-        python3-scattnlay
-        PROPERTIES
-        PREFIX ""
-        OUTPUT_NAME "scattnlay"
-        SUFFIX "${EXT_SUFFIX}"
-        LINKER_LANGUAGE C
-)
+#set_target_properties(
+#        python3-scattnlay
+#        PROPERTIES
+#        PREFIX ""
+#        OUTPUT_NAME "scattnlay"
+#        SUFFIX "${EXT_SUFFIX}"
+#        LINKER_LANGUAGE C
+#)
 
 # Sources for far field calculation
 set(_scattnlay_farfield_sources
@@ -55,11 +55,11 @@ set_target_properties(nearfield PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINA
 
 # Rename files to match precision
 if (${ENABLE_MP} AND ${Boost_FOUND})
-    set_property(TARGET python3-scattnlay APPEND_STRING PROPERTY OUTPUT_NAME "_mp")
+#    set_property(TARGET python3-scattnlay APPEND_STRING PROPERTY OUTPUT_NAME "_mp")
     set_property(TARGET farfield APPEND_STRING PROPERTY OUTPUT_NAME "farfield-mp")
     set_property(TARGET nearfield APPEND_STRING PROPERTY OUTPUT_NAME "nearfield-mp")
 else ()
-    set_property(TARGET python3-scattnlay APPEND_STRING PROPERTY OUTPUT_NAME "_dp")
+#    set_property(TARGET python3-scattnlay APPEND_STRING PROPERTY OUTPUT_NAME "_dp")
     set_property(TARGET farfield APPEND_STRING PROPERTY OUTPUT_NAME "farfield-dp")
     set_property(TARGET nearfield APPEND_STRING PROPERTY OUTPUT_NAME "nearfield-dp")
 endif ()

+ 1 - 1
tox.ini

@@ -4,7 +4,7 @@
 # and then run "tox" from this directory.
 
 [tox]
-envlist = py38, py39, py310
+envlist = py38, py310
 
 [testenv]
 commands =