mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-26 05:50:32 +05:00
Merge branch 'find_python' into 'master'
find_package(PythonInterp... deprecated, change to python with comp See merge request ngsolve/netgen!595
This commit is contained in:
commit
0043eee0e0
@ -241,6 +241,7 @@ build_mac:
|
|||||||
-DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
|
-DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
|
||||||
-DUSE_CGNS=ON
|
-DUSE_CGNS=ON
|
||||||
-DUSE_OCC=ON
|
-DUSE_OCC=ON
|
||||||
|
-DPython3_ROOT_DIR=/Library/Frameworks/Python.framework/Versions/3.8/
|
||||||
- make -j5 install
|
- make -j5 install
|
||||||
|
|
||||||
test_mac:
|
test_mac:
|
||||||
|
@ -2,8 +2,8 @@ if(NOT CMAKE_BUILD_TYPE)
|
|||||||
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING INTERNAL)
|
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING INTERNAL)
|
||||||
endif(NOT CMAKE_BUILD_TYPE)
|
endif(NOT CMAKE_BUILD_TYPE)
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
cmake_policy(VERSION 3.13)
|
cmake_policy(VERSION 3.16)
|
||||||
|
|
||||||
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0")
|
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0")
|
||||||
cmake_policy(SET CMP0135 NEW)
|
cmake_policy(SET CMP0135 NEW)
|
||||||
@ -85,12 +85,14 @@ endif()
|
|||||||
set(NG_INSTALL_SUFFIX netgen CACHE STRING "Suffix appended to install directories (project name)")
|
set(NG_INSTALL_SUFFIX netgen CACHE STRING "Suffix appended to install directories (project name)")
|
||||||
|
|
||||||
if(USE_PYTHON)
|
if(USE_PYTHON)
|
||||||
find_package(PythonInterp 3 REQUIRED)
|
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.18)
|
||||||
if(NOT BUILD_FOR_CONDA)
|
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
|
||||||
find_package(PythonLibs 3 REQUIRED)
|
find_package(Python3 COMPONENTS Interpreter Development.Embed)
|
||||||
endif()
|
else()
|
||||||
|
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
|
||||||
|
endif()
|
||||||
|
|
||||||
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)
|
file(TO_CMAKE_PATH ${PYTHON_PACKAGES_INSTALL_DIR} PYTHON_PACKAGES_INSTALL_DIR)
|
||||||
endif(USE_PYTHON)
|
endif(USE_PYTHON)
|
||||||
|
|
||||||
@ -315,11 +317,10 @@ if (USE_PYTHON)
|
|||||||
add_subdirectory(external_dependencies/pybind11)
|
add_subdirectory(external_dependencies/pybind11)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(netgen_python INTERFACE ${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} ${PYTHON_INCLUDE_DIRS})
|
target_include_directories(nglib PRIVATE ${pybind11_INCLUDE_DIR} ${Python3_INCLUDE_DIRS})
|
||||||
if(NOT ${BUILD_FOR_CONDA} OR WIN32)
|
if(Python3_LIBRARIES)
|
||||||
# Don't link python libraries in conda environments
|
target_link_libraries(netgen_python INTERFACE ${Python3_LIBRARIES})
|
||||||
target_link_libraries(netgen_python INTERFACE ${PYTHON_LIBRARIES})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NG_INSTALL_PYBIND)
|
if(NG_INSTALL_PYBIND)
|
||||||
@ -343,7 +344,7 @@ if (USE_MPI)
|
|||||||
target_compile_definitions(netgen_metis INTERFACE METIS )
|
target_compile_definitions(netgen_metis INTERFACE METIS )
|
||||||
|
|
||||||
if(USE_MPI4PY AND USE_PYTHON)
|
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)
|
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_include_directories(netgen_metis INTERFACE ${MPI4PY_INCLUDE_DIR})
|
||||||
target_compile_definitions(netgen_metis INTERFACE NG_MPI4PY )
|
target_compile_definitions(netgen_metis INTERFACE NG_MPI4PY )
|
||||||
|
@ -38,9 +38,9 @@ set(NETGEN_OCC_LIBRARIES_BIN "@OpenCASCADE_BINARY_DIR@")
|
|||||||
set(NETGEN_OCC_LIBRARIES "@OCC_LIBRARIES@")
|
set(NETGEN_OCC_LIBRARIES "@OCC_LIBRARIES@")
|
||||||
set(NETGEN_OCC_LIBRARY_DIR "@OpenCASCADE_LIBRARY_DIR@")
|
set(NETGEN_OCC_LIBRARY_DIR "@OpenCASCADE_LIBRARY_DIR@")
|
||||||
set(NETGEN_OPENGL_LIBRARIES "@OPENGL_LIBRARIES@")
|
set(NETGEN_OPENGL_LIBRARIES "@OPENGL_LIBRARIES@")
|
||||||
set(NETGEN_PYTHON_EXECUTABLE "@PYTHON_EXECUTABLE@")
|
set(NETGEN_PYTHON_EXECUTABLE "@Python3_EXECUTABLE@")
|
||||||
set(NETGEN_PYTHON_INCLUDE_DIRS "@PYTHON_INCLUDE_DIRS@")
|
set(NETGEN_PYTHON_INCLUDE_DIRS "@Python3_INCLUDE_DIRS@")
|
||||||
set(NETGEN_PYTHON_LIBRARIES "@PYTHON_LIBRARIES@")
|
set(NETGEN_PYTHON_LIBRARIES "@Python3_LIBRARIES@")
|
||||||
set(NETGEN_TCL_INCLUDE_PATH "@TCL_INCLUDE_PATH@")
|
set(NETGEN_TCL_INCLUDE_PATH "@TCL_INCLUDE_PATH@")
|
||||||
set(NETGEN_TCL_LIBRARY "@TCL_STUB_LIBRARY@")
|
set(NETGEN_TCL_LIBRARY "@TCL_STUB_LIBRARY@")
|
||||||
set(NETGEN_TK_DND_LIBRARY "@TK_DND_LIBRARY@")
|
set(NETGEN_TK_DND_LIBRARY "@TK_DND_LIBRARY@")
|
||||||
|
@ -181,16 +181,18 @@ if (USE_PYTHON)
|
|||||||
else( PYBIND_INCLUDE_DIR )
|
else( PYBIND_INCLUDE_DIR )
|
||||||
message(FATAL_ERROR "Could NOT find pybind11!")
|
message(FATAL_ERROR "Could NOT find pybind11!")
|
||||||
endif( PYBIND_INCLUDE_DIR )
|
endif( PYBIND_INCLUDE_DIR )
|
||||||
find_package(PythonInterp 3 REQUIRED)
|
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.18)
|
||||||
if(NOT BUILD_FOR_CONDA)
|
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
|
||||||
find_package(PythonLibs 3 REQUIRED)
|
find_package(Python3 COMPONENTS Interpreter Development.Embed)
|
||||||
|
else()
|
||||||
|
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set_vars(NETGEN_CMAKE_ARGS
|
set_vars(NETGEN_CMAKE_ARGS
|
||||||
PYTHON_INCLUDE_DIRS
|
Python3_INCLUDE_DIRS
|
||||||
PYTHON_LIBRARIES
|
Python3_LIBRARIES
|
||||||
PYTHON_EXECUTABLE
|
Python3_EXECUTABLE
|
||||||
PYTHON_VERSION
|
Python3_VERSION
|
||||||
PYBIND_INCLUDE_DIR
|
PYBIND_INCLUDE_DIR
|
||||||
NG_INSTALL_PYBIND
|
NG_INSTALL_PYBIND
|
||||||
)
|
)
|
||||||
|
@ -7,7 +7,7 @@ else(LINUX)
|
|||||||
if(SKBUILD)
|
if(SKBUILD)
|
||||||
# we are building a pip package - download the tcl/tk sources matching the tkinter version (for private headers not shipped with python)
|
# 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('.','-'))"
|
"import tkinter;print(tkinter.Tcl().eval('info patchlevel').replace('.','-'))"
|
||||||
OUTPUT_VARIABLE PYTHON_TCL_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
|
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)
|
list(APPEND NETGEN_DEPENDENCIES project_tcl project_tk)
|
||||||
|
|
||||||
if(APPLE OR WIN32)
|
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)
|
file(TO_CMAKE_PATH ${PYTHON_PREFIX} PYTHON_PREFIX)
|
||||||
|
|
||||||
set(tcl_find_args
|
set(tcl_find_args
|
||||||
|
@ -78,7 +78,7 @@ endif(ENABLE_CPP_CORE_GUIDELINES_CHECK)
|
|||||||
add_dependencies(ngcore ng_generate_version_file)
|
add_dependencies(ngcore ng_generate_version_file)
|
||||||
|
|
||||||
if(USE_PYTHON)
|
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)
|
target_link_libraries(pyngcore PUBLIC ngcore netgen_python)
|
||||||
set_target_properties(pyngcore PROPERTIES INSTALL_RPATH "${NG_RPATH_TOKEN}/../${NETGEN_PYTHON_RPATH}")
|
set_target_properties(pyngcore PROPERTIES INSTALL_RPATH "${NG_RPATH_TOKEN}/../${NETGEN_PYTHON_RPATH}")
|
||||||
install(TARGETS pyngcore DESTINATION ${NG_INSTALL_DIR_PYTHON}/pyngcore COMPONENT netgen)
|
install(TARGETS pyngcore DESTINATION ${NG_INSTALL_DIR_PYTHON}/pyngcore COMPONENT netgen)
|
||||||
|
@ -28,7 +28,7 @@ if(USE_GUI)
|
|||||||
if(APPLE)
|
if(APPLE)
|
||||||
set_target_properties(netgen PROPERTIES OUTPUT_NAME netgen)
|
set_target_properties(netgen PROPERTIES OUTPUT_NAME netgen)
|
||||||
endif(APPLE)
|
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)
|
endif(NOT BUILD_FOR_CONDA)
|
||||||
|
|
||||||
install(TARGETS nggui ${NG_INSTALL_DIR})
|
install(TARGETS nggui ${NG_INSTALL_DIR})
|
||||||
|
@ -26,13 +26,13 @@ install(FILES
|
|||||||
|
|
||||||
# build stub files for pybind11 packages
|
# build stub files for pybind11 packages
|
||||||
if(BUILD_STUB_FILES)
|
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)
|
if(pybind11_stubgen AND NOT ${pybind11_stubgen} EQUAL 0)
|
||||||
message(WARNING "pybind11-stubgen not found, if you want to create stub files
|
message(WARNING "pybind11-stubgen not found, if you want to create stub files
|
||||||
for better autocompletion support install it with pip.")
|
for better autocompletion support install it with pip.")
|
||||||
else()
|
else()
|
||||||
message("-- Found pybind11-stubgen: ${stubgen_path}")
|
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)
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../stubs/netgen-stubs/ DESTINATION ${NG_INSTALL_DIR_PYTHON}/netgen/ COMPONENT netgen)
|
||||||
endif()
|
endif()
|
||||||
endif(BUILD_STUB_FILES)
|
endif(BUILD_STUB_FILES)
|
||||||
|
@ -52,8 +52,8 @@ NETGEN_VERSION_TWEAK = "@NETGEN_VERSION_TWEAK@"
|
|||||||
NETGEN_VERSION_PATCH = "@NETGEN_VERSION_PATCH@"
|
NETGEN_VERSION_PATCH = "@NETGEN_VERSION_PATCH@"
|
||||||
NETGEN_VERSION_HASH = "@NETGEN_VERSION_HASH@"
|
NETGEN_VERSION_HASH = "@NETGEN_VERSION_HASH@"
|
||||||
|
|
||||||
PYTHON_VERSION = "@PYTHON_VERSION@"
|
PYTHON_VERSION = "@Python3_VERSION@"
|
||||||
PYTHON_VERSION_MAJOR = "@PYTHON_VERSION_MAJOR@"
|
PYTHON_VERSION_MAJOR = "@Python3_VERSION_MAJOR@"
|
||||||
PYTHON_VERSION_MINOR = "@PYTHON_VERSION_MINOR@"
|
PYTHON_VERSION_MINOR = "@Python3_VERSION_MINOR@"
|
||||||
|
|
||||||
version = NETGEN_VERSION_GIT
|
version = NETGEN_VERSION_GIT
|
||||||
|
2
setup.py
2
setup.py
@ -102,7 +102,7 @@ cmake_args += [
|
|||||||
]
|
]
|
||||||
|
|
||||||
pyprefix = pathlib.Path(sys.prefix).as_posix()
|
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(
|
setup(
|
||||||
name=name,
|
name=name,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
if(USE_PYTHON)
|
if(USE_PYTHON)
|
||||||
add_test(NAME pytest COMMAND ${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 ${PYTHON_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 )
|
set_tests_properties ( pytest PROPERTIES TIMEOUT 1800 )
|
||||||
if(USE_MPI AND USE_MPI4PY)
|
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_MPI AND USE_MPI4PY)
|
||||||
endif(USE_PYTHON)
|
endif(USE_PYTHON)
|
||||||
|
Loading…
Reference in New Issue
Block a user