From f873de3e3b8d46eac131033829100f4f0a63162f Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Tue, 29 Aug 2023 10:52:22 +0200 Subject: [PATCH 01/11] find_package(PythonInterp... deprecated, change to python with comp --- CMakeLists.txt | 13 +++++-------- cmake/NetgenConfig.cmake.in | 4 ++-- cmake/SuperBuild.cmake | 13 +++++-------- ng/CMakeLists.txt | 2 +- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21edc576..80f47e1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,12 +85,9 @@ endif() set(NG_INSTALL_SUFFIX netgen CACHE STRING "Suffix appended to install directories (project name)") if(USE_PYTHON) - find_package(PythonInterp 3 REQUIRED) - if(NOT BUILD_FOR_CONDA) - find_package(PythonLibs 3 REQUIRED) - endif() + find_package(Python3 REQUIRED COMPONENTS Interpreter Development) - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1,0,''))" OUTPUT_VARIABLE PYTHON_PACKAGES_INSTALL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${Python3_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1,0,''))" OUTPUT_VARIABLE PYTHON_PACKAGES_INSTALL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) file(TO_CMAKE_PATH ${PYTHON_PACKAGES_INSTALL_DIR} PYTHON_PACKAGES_INSTALL_DIR) endif(USE_PYTHON) @@ -316,11 +313,11 @@ if (USE_PYTHON) add_subdirectory(external_dependencies/pybind11) endif() - target_include_directories(netgen_python INTERFACE ${pybind11_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS}) - target_include_directories(nglib PRIVATE ${pybind11_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS}) + target_include_directories(netgen_python INTERFACE ${pybind11_INCLUDE_DIR} ${Python3_INCLUDE_DIRS}) + target_include_directories(nglib PRIVATE ${pybind11_INCLUDE_DIR} ${Python3_INCLUDE_DIRS}) if(NOT ${BUILD_FOR_CONDA} OR WIN32) # Don't link python libraries in conda environments - target_link_libraries(netgen_python INTERFACE ${PYTHON_LIBRARIES}) + target_link_libraries(netgen_python INTERFACE ${Python3_LIBRARIES}) endif() if(NG_INSTALL_PYBIND) diff --git a/cmake/NetgenConfig.cmake.in b/cmake/NetgenConfig.cmake.in index ddb8850b..f58d8778 100644 --- a/cmake/NetgenConfig.cmake.in +++ b/cmake/NetgenConfig.cmake.in @@ -39,8 +39,8 @@ set(NETGEN_OCC_LIBRARIES "@OCC_LIBRARIES@") set(NETGEN_OCC_LIBRARY_DIR "@OpenCASCADE_LIBRARY_DIR@") set(NETGEN_OPENGL_LIBRARIES "@OPENGL_LIBRARIES@") set(NETGEN_PYTHON_EXECUTABLE "@PYTHON_EXECUTABLE@") -set(NETGEN_PYTHON_INCLUDE_DIRS "@PYTHON_INCLUDE_DIRS@") -set(NETGEN_PYTHON_LIBRARIES "@PYTHON_LIBRARIES@") +set(NETGEN_PYTHON_INCLUDE_DIRS "@Python3_INCLUDE_DIRS@") +set(NETGEN_PYTHON_LIBRARIES "@Python3_LIBRARIES@") set(NETGEN_TCL_INCLUDE_PATH "@TCL_INCLUDE_PATH@") set(NETGEN_TCL_LIBRARY "@TCL_STUB_LIBRARY@") set(NETGEN_TK_DND_LIBRARY "@TK_DND_LIBRARY@") diff --git a/cmake/SuperBuild.cmake b/cmake/SuperBuild.cmake index 091b2477..8c1c0a69 100644 --- a/cmake/SuperBuild.cmake +++ b/cmake/SuperBuild.cmake @@ -181,16 +181,13 @@ if (USE_PYTHON) else( PYBIND_INCLUDE_DIR ) message(FATAL_ERROR "Could NOT find pybind11!") endif( PYBIND_INCLUDE_DIR ) - find_package(PythonInterp 3 REQUIRED) - if(NOT BUILD_FOR_CONDA) - find_package(PythonLibs 3 REQUIRED) - endif() + find_package(Python3 REQUIRED COMPONENTS Interpreter Development) set_vars(NETGEN_CMAKE_ARGS - PYTHON_INCLUDE_DIRS - PYTHON_LIBRARIES - PYTHON_EXECUTABLE - PYTHON_VERSION + Python3_INCLUDE_DIRS + Python3_LIBRARIES + Python3_EXECUTABLE + Python3_VERSION PYBIND_INCLUDE_DIR NG_INSTALL_PYBIND ) diff --git a/ng/CMakeLists.txt b/ng/CMakeLists.txt index 3ad3d8be..710a780c 100644 --- a/ng/CMakeLists.txt +++ b/ng/CMakeLists.txt @@ -28,7 +28,7 @@ if(USE_GUI) if(APPLE) set_target_properties(netgen PROPERTIES OUTPUT_NAME netgen) endif(APPLE) - target_link_libraries( netgen ${PYTHON_LIBRARIES} ${TCL_LIBRARY} ${TK_LIBRARY}) + target_link_libraries( netgen ${Python3_LIBRARIES} ${TCL_LIBRARY} ${TK_LIBRARY}) endif(NOT BUILD_FOR_CONDA) install(TARGETS nggui ${NG_INSTALL_DIR}) From 5c87a797ff4469e4d4f3f2e3c1d01f0f68e9056d Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Tue, 29 Aug 2023 11:24:01 +0200 Subject: [PATCH 02/11] some more missing PYTHON -> Python3 renamings --- CMakeLists.txt | 2 +- cmake/NetgenConfig.cmake.in | 2 +- cmake/external_projects/tcltk.cmake | 4 ++-- python/CMakeLists.txt | 4 ++-- python/config_template.py | 6 +++--- tests/pytest/CMakeLists.txt | 6 +++--- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 80f47e1f..cc6d4f9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -341,7 +341,7 @@ if (USE_MPI) target_compile_definitions(netgen_metis INTERFACE METIS ) if(USE_MPI4PY AND USE_PYTHON) - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import mpi4py;print(mpi4py.get_include())" OUTPUT_VARIABLE mpi4py_path OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${Python3_EXECUTABLE} -c "import mpi4py;print(mpi4py.get_include())" OUTPUT_VARIABLE mpi4py_path OUTPUT_STRIP_TRAILING_WHITESPACE) find_path(MPI4PY_INCLUDE_DIR mpi4py.h HINTS ${mpi4py_path}/mpi4py NO_DEFAULT_PATH REQUIRED) target_include_directories(netgen_metis INTERFACE ${MPI4PY_INCLUDE_DIR}) target_compile_definitions(netgen_metis INTERFACE NG_MPI4PY ) diff --git a/cmake/NetgenConfig.cmake.in b/cmake/NetgenConfig.cmake.in index f58d8778..477ed214 100644 --- a/cmake/NetgenConfig.cmake.in +++ b/cmake/NetgenConfig.cmake.in @@ -38,7 +38,7 @@ set(NETGEN_OCC_LIBRARIES_BIN "@OpenCASCADE_BINARY_DIR@") set(NETGEN_OCC_LIBRARIES "@OCC_LIBRARIES@") set(NETGEN_OCC_LIBRARY_DIR "@OpenCASCADE_LIBRARY_DIR@") set(NETGEN_OPENGL_LIBRARIES "@OPENGL_LIBRARIES@") -set(NETGEN_PYTHON_EXECUTABLE "@PYTHON_EXECUTABLE@") +set(NETGEN_PYTHON_EXECUTABLE "@Python3_EXECUTABLE@") set(NETGEN_PYTHON_INCLUDE_DIRS "@Python3_INCLUDE_DIRS@") set(NETGEN_PYTHON_LIBRARIES "@Python3_LIBRARIES@") set(NETGEN_TCL_INCLUDE_PATH "@TCL_INCLUDE_PATH@") diff --git a/cmake/external_projects/tcltk.cmake b/cmake/external_projects/tcltk.cmake index 8d1e1247..9542f3c0 100644 --- a/cmake/external_projects/tcltk.cmake +++ b/cmake/external_projects/tcltk.cmake @@ -7,7 +7,7 @@ else(LINUX) if(SKBUILD) # we are building a pip package - download the tcl/tk sources matching the tkinter version (for private headers not shipped with python) -execute_process(COMMAND ${PYTHON_EXECUTABLE} -c +execute_process(COMMAND ${Python3_EXECUTABLE} -c "import tkinter;print(tkinter.Tcl().eval('info patchlevel').replace('.','-'))" OUTPUT_VARIABLE PYTHON_TCL_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -39,7 +39,7 @@ set(TK_INCLUDE_PATH ${TK_DIR}/generic) list(APPEND NETGEN_DEPENDENCIES project_tcl project_tk) if(APPLE OR WIN32) - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; print(sys.prefix)" OUTPUT_VARIABLE PYTHON_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${Python3_EXECUTABLE} -c "import sys; print(sys.prefix)" OUTPUT_VARIABLE PYTHON_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) file(TO_CMAKE_PATH ${PYTHON_PREFIX} PYTHON_PREFIX) set(tcl_find_args diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index ccab5494..792b337c 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -26,13 +26,13 @@ install(FILES # build stub files for pybind11 packages if(BUILD_STUB_FILES) -execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import pybind11_stubgen; print(pybind11_stubgen.__file__)" OUTPUT_VARIABLE stubgen_path RESULT_VARIABLE pybind11_stubgen) +execute_process(COMMAND ${Python3_EXECUTABLE} -c "import pybind11_stubgen; print(pybind11_stubgen.__file__)" OUTPUT_VARIABLE stubgen_path RESULT_VARIABLE pybind11_stubgen) if(pybind11_stubgen AND NOT ${pybind11_stubgen} EQUAL 0) message(WARNING "pybind11-stubgen not found, if you want to create stub files for better autocompletion support install it with pip.") else() message("-- Found pybind11-stubgen: ${stubgen_path}") - install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pybind11_stubgen --no-setup-py --ignore-invalid=all netgen)") + install(CODE "execute_process(COMMAND ${Python3_EXECUTABLE} -m pybind11_stubgen --no-setup-py --ignore-invalid=all netgen)") install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../stubs/netgen-stubs/ DESTINATION ${NG_INSTALL_DIR_PYTHON}/netgen/ COMPONENT netgen) endif() endif(BUILD_STUB_FILES) diff --git a/python/config_template.py b/python/config_template.py index 38991567..c4232dff 100644 --- a/python/config_template.py +++ b/python/config_template.py @@ -52,8 +52,8 @@ NETGEN_VERSION_TWEAK = "@NETGEN_VERSION_TWEAK@" NETGEN_VERSION_PATCH = "@NETGEN_VERSION_PATCH@" NETGEN_VERSION_HASH = "@NETGEN_VERSION_HASH@" -PYTHON_VERSION = "@PYTHON_VERSION@" -PYTHON_VERSION_MAJOR = "@PYTHON_VERSION_MAJOR@" -PYTHON_VERSION_MINOR = "@PYTHON_VERSION_MINOR@" +PYTHON_VERSION = "@Python3_VERSION@" +PYTHON_VERSION_MAJOR = "@Python3_VERSION_MAJOR@" +PYTHON_VERSION_MINOR = "@Python3_VERSION_MINOR@" version = NETGEN_VERSION_GIT diff --git a/tests/pytest/CMakeLists.txt b/tests/pytest/CMakeLists.txt index 26c7d22f..375bd420 100644 --- a/tests/pytest/CMakeLists.txt +++ b/tests/pytest/CMakeLists.txt @@ -1,8 +1,8 @@ if(USE_PYTHON) - add_test(NAME pytest COMMAND ${PYTHON_EXECUTABLE} -m pytest WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) - add_custom_target(pytest ${PYTHON_EXECUTABLE} -m pytest WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + add_test(NAME pytest COMMAND ${Python3_EXECUTABLE} -m pytest WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + add_custom_target(pytest ${Python3_EXECUTABLE} -m pytest WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) set_tests_properties ( pytest PROPERTIES TIMEOUT 1800 ) if(USE_MPI AND USE_MPI4PY) - add_test(NAME pytest-mpi COMMAND ${MPIEXEC_EXECUTABLE} --allow-run-as-root -np 4 ${PYTHON_EXECUTABLE} -m pytest --with-mpi test_mpi4py.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + add_test(NAME pytest-mpi COMMAND ${MPIEXEC_EXECUTABLE} --allow-run-as-root -np 4 ${Python3_EXECUTABLE} -m pytest --with-mpi test_mpi4py.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) endif(USE_MPI AND USE_MPI4PY) endif(USE_PYTHON) From a94a940fe36512b3da792baabd5b3121fd5591a2 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Wed, 30 Aug 2023 13:27:53 +0200 Subject: [PATCH 03/11] set python3 root on mac explicitly --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9d90f9d1..62f06ac3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -241,6 +241,7 @@ build_mac: -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -DUSE_CGNS=ON -DUSE_OCC=ON + -DPython3_ROOT_DIR=/Library/Frameworks/Python.framework/Versions/3.8/ - make -j5 install test_mac: From 56d1dbb2b670783fdb231b0fa7d25f0dab262407 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Wed, 30 Aug 2023 16:04:22 +0200 Subject: [PATCH 04/11] set python3 root in setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index bea48af3..3d569574 100644 --- a/setup.py +++ b/setup.py @@ -102,7 +102,7 @@ cmake_args += [ ] pyprefix = pathlib.Path(sys.prefix).as_posix() -cmake_args += [f'-DCMAKE_PREFIX_PATH={pyprefix}'] +cmake_args += [f'-DCMAKE_PREFIX_PATH={pyprefix}', f'-DPython3_ROOT_DIR={pyprefix}'] setup( name=name, From 4f83d8b1b6144b49e4ed60fd9ad5dc209345590f Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Wed, 30 Aug 2023 16:11:14 +0200 Subject: [PATCH 05/11] Find python3 Development.Module, require CMake 3.18 --- CMakeLists.txt | 6 +++--- cmake/SuperBuild.cmake | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc6d4f9c..a4d52011 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,8 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING INTERNAL) endif(NOT CMAKE_BUILD_TYPE) -cmake_minimum_required(VERSION 3.13) -cmake_policy(VERSION 3.13) +cmake_minimum_required(VERSION 3.18) +cmake_policy(VERSION 3.18) if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0") cmake_policy(SET CMP0135 NEW) @@ -85,7 +85,7 @@ endif() set(NG_INSTALL_SUFFIX netgen CACHE STRING "Suffix appended to install directories (project name)") if(USE_PYTHON) - find_package(Python3 REQUIRED COMPONENTS Interpreter Development) + find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module) execute_process(COMMAND ${Python3_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1,0,''))" OUTPUT_VARIABLE PYTHON_PACKAGES_INSTALL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) file(TO_CMAKE_PATH ${PYTHON_PACKAGES_INSTALL_DIR} PYTHON_PACKAGES_INSTALL_DIR) diff --git a/cmake/SuperBuild.cmake b/cmake/SuperBuild.cmake index 8c1c0a69..d7de225c 100644 --- a/cmake/SuperBuild.cmake +++ b/cmake/SuperBuild.cmake @@ -181,7 +181,7 @@ if (USE_PYTHON) else( PYBIND_INCLUDE_DIR ) message(FATAL_ERROR "Could NOT find pybind11!") endif( PYBIND_INCLUDE_DIR ) - find_package(Python3 REQUIRED COMPONENTS Interpreter Development) + find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module) set_vars(NETGEN_CMAKE_ARGS Python3_INCLUDE_DIRS From af345043af73ab4cd94d038bd19657dcaf2ef0e9 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Wed, 30 Aug 2023 17:00:15 +0200 Subject: [PATCH 06/11] add Development.Embed --- CMakeLists.txt | 2 +- cmake/SuperBuild.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a4d52011..20c1ac8b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,7 +85,7 @@ endif() set(NG_INSTALL_SUFFIX netgen CACHE STRING "Suffix appended to install directories (project name)") if(USE_PYTHON) - find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module) + find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module Development.Embed) execute_process(COMMAND ${Python3_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1,0,''))" OUTPUT_VARIABLE PYTHON_PACKAGES_INSTALL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) file(TO_CMAKE_PATH ${PYTHON_PACKAGES_INSTALL_DIR} PYTHON_PACKAGES_INSTALL_DIR) diff --git a/cmake/SuperBuild.cmake b/cmake/SuperBuild.cmake index d7de225c..e5049d02 100644 --- a/cmake/SuperBuild.cmake +++ b/cmake/SuperBuild.cmake @@ -181,7 +181,7 @@ if (USE_PYTHON) else( PYBIND_INCLUDE_DIR ) message(FATAL_ERROR "Could NOT find pybind11!") endif( PYBIND_INCLUDE_DIR ) - find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module) + find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module Development.Embed) set_vars(NETGEN_CMAKE_ARGS Python3_INCLUDE_DIRS From 40546340a43743e358d86ec4e2b6a83b6864f106 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Wed, 30 Aug 2023 17:12:07 +0200 Subject: [PATCH 07/11] Revert "add Development.Embed" This reverts commit af345043af73ab4cd94d038bd19657dcaf2ef0e9. --- CMakeLists.txt | 2 +- cmake/SuperBuild.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 20c1ac8b..a4d52011 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,7 +85,7 @@ endif() set(NG_INSTALL_SUFFIX netgen CACHE STRING "Suffix appended to install directories (project name)") if(USE_PYTHON) - find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module Development.Embed) + find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module) execute_process(COMMAND ${Python3_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1,0,''))" OUTPUT_VARIABLE PYTHON_PACKAGES_INSTALL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) file(TO_CMAKE_PATH ${PYTHON_PACKAGES_INSTALL_DIR} PYTHON_PACKAGES_INSTALL_DIR) diff --git a/cmake/SuperBuild.cmake b/cmake/SuperBuild.cmake index e5049d02..d7de225c 100644 --- a/cmake/SuperBuild.cmake +++ b/cmake/SuperBuild.cmake @@ -181,7 +181,7 @@ if (USE_PYTHON) else( PYBIND_INCLUDE_DIR ) message(FATAL_ERROR "Could NOT find pybind11!") endif( PYBIND_INCLUDE_DIR ) - find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module Development.Embed) + find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module) set_vars(NETGEN_CMAKE_ARGS Python3_INCLUDE_DIRS From 68b5490621b504b68d25a3a990af18eb758d4cc7 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Wed, 30 Aug 2023 17:31:58 +0200 Subject: [PATCH 08/11] Change library type for pyngcore to MODULE --- libsrc/core/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/core/CMakeLists.txt b/libsrc/core/CMakeLists.txt index b763246a..de4b2604 100644 --- a/libsrc/core/CMakeLists.txt +++ b/libsrc/core/CMakeLists.txt @@ -77,7 +77,7 @@ endif(ENABLE_CPP_CORE_GUIDELINES_CHECK) add_dependencies(ngcore ng_generate_version_file) if(USE_PYTHON) - pybind11_add_module(pyngcore SHARED python_ngcore_export.cpp) + pybind11_add_module(pyngcore MODULE python_ngcore_export.cpp) target_link_libraries(pyngcore PUBLIC ngcore netgen_python) set_target_properties(pyngcore PROPERTIES INSTALL_RPATH "${NG_RPATH_TOKEN}/../${NETGEN_PYTHON_RPATH}") install(TARGETS pyngcore DESTINATION ${NG_INSTALL_DIR_PYTHON}/pyngcore COMPONENT netgen) From 24cbbe588ec403f3d036d16f696b7b80f4878ca0 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Wed, 30 Aug 2023 17:59:24 +0200 Subject: [PATCH 09/11] Require only CMake 3.16 --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a4d52011..60dac490 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,8 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING INTERNAL) endif(NOT CMAKE_BUILD_TYPE) -cmake_minimum_required(VERSION 3.18) -cmake_policy(VERSION 3.18) +cmake_minimum_required(VERSION 3.16) +cmake_policy(VERSION 3.16) if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0") cmake_policy(SET CMP0135 NEW) From 80098c1e934a9f78e1251663460bbe59b0044d45 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Wed, 30 Aug 2023 20:25:11 +0200 Subject: [PATCH 10/11] Set parameters to FindPython3 depending on CMake version --- CMakeLists.txt | 6 +++++- cmake/SuperBuild.cmake | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 60dac490..19af1133 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,7 +85,11 @@ endif() set(NG_INSTALL_SUFFIX netgen CACHE STRING "Suffix appended to install directories (project name)") if(USE_PYTHON) - find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module) + if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.18) + find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module) + else() + find_package(Python3 REQUIRED COMPONENTS Interpreter Development) + endif() execute_process(COMMAND ${Python3_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1,0,''))" OUTPUT_VARIABLE PYTHON_PACKAGES_INSTALL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) file(TO_CMAKE_PATH ${PYTHON_PACKAGES_INSTALL_DIR} PYTHON_PACKAGES_INSTALL_DIR) diff --git a/cmake/SuperBuild.cmake b/cmake/SuperBuild.cmake index d7de225c..2ebd3cd6 100644 --- a/cmake/SuperBuild.cmake +++ b/cmake/SuperBuild.cmake @@ -181,7 +181,11 @@ if (USE_PYTHON) else( PYBIND_INCLUDE_DIR ) message(FATAL_ERROR "Could NOT find pybind11!") endif( PYBIND_INCLUDE_DIR ) - find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module) + if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.18) + find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module) + else() + find_package(Python3 REQUIRED COMPONENTS Interpreter Development) + endif() set_vars(NETGEN_CMAKE_ARGS Python3_INCLUDE_DIRS From c8888086ae4f4c6965b74484e8febb61f1f96808 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Wed, 30 Aug 2023 21:03:04 +0200 Subject: [PATCH 11/11] CMake 3.16 compatibility --- CMakeLists.txt | 6 +++--- cmake/SuperBuild.cmake | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 19af1133..d4316a73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,7 +86,8 @@ set(NG_INSTALL_SUFFIX netgen CACHE STRING "Suffix appended to install directorie if(USE_PYTHON) if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.18) - find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module) + find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module) + find_package(Python3 COMPONENTS Interpreter Development.Embed) else() find_package(Python3 REQUIRED COMPONENTS Interpreter Development) endif() @@ -319,8 +320,7 @@ if (USE_PYTHON) target_include_directories(netgen_python INTERFACE ${pybind11_INCLUDE_DIR} ${Python3_INCLUDE_DIRS}) target_include_directories(nglib PRIVATE ${pybind11_INCLUDE_DIR} ${Python3_INCLUDE_DIRS}) - if(NOT ${BUILD_FOR_CONDA} OR WIN32) - # Don't link python libraries in conda environments + if(Python3_LIBRARIES) target_link_libraries(netgen_python INTERFACE ${Python3_LIBRARIES}) endif() diff --git a/cmake/SuperBuild.cmake b/cmake/SuperBuild.cmake index 2ebd3cd6..d0b70930 100644 --- a/cmake/SuperBuild.cmake +++ b/cmake/SuperBuild.cmake @@ -183,6 +183,7 @@ if (USE_PYTHON) endif( PYBIND_INCLUDE_DIR ) if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.18) find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module) + find_package(Python3 COMPONENTS Interpreter Development.Embed) else() find_package(Python3 REQUIRED COMPONENTS Interpreter Development) endif()