mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-12 00:59:16 +05:00
Merge branch 'pip_mr' into 'master'
pip installer See merge request jschoeberl/netgen!441
This commit is contained in:
commit
93e188688a
@ -2,6 +2,7 @@ stages:
|
||||
- build
|
||||
- test
|
||||
- test_ngsolve
|
||||
- deploy
|
||||
- cleanup
|
||||
|
||||
push_github_sourceforge:
|
||||
@ -268,3 +269,36 @@ cleanup_mac:
|
||||
allow_failure: true
|
||||
needs: ["test_mac"]
|
||||
|
||||
pip_linux:
|
||||
image: quay.io/pypa/manylinux2014_x86_64
|
||||
stage: build
|
||||
tags:
|
||||
- pip
|
||||
- linux
|
||||
- docker
|
||||
script:
|
||||
- ./tests/build_pip.sh
|
||||
when: manual
|
||||
|
||||
pip_windows:
|
||||
stage: build
|
||||
tags:
|
||||
- pip
|
||||
- windows
|
||||
script:
|
||||
- .\tests\build_pip.ps1 C:\Python38
|
||||
- .\tests\build_pip.ps1 C:\Python39
|
||||
- .\tests\build_pip.ps1 C:\Python310
|
||||
when: manual
|
||||
|
||||
pip_macos:
|
||||
stage: build
|
||||
tags:
|
||||
- pip
|
||||
- macosx
|
||||
- m1
|
||||
script:
|
||||
- ./tests/build_pip_mac.sh 3.8
|
||||
#- ./tests/build_pip_mac.sh 3.9
|
||||
- ./tests/build_pip_mac.sh 3.10
|
||||
when: manual
|
||||
|
@ -9,6 +9,8 @@ else(WIN32)
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
endif(WIN32)
|
||||
|
||||
cmake_policy(VERSION 3.12)
|
||||
|
||||
option( USE_NATIVE_ARCH "build for native cpu architecture" ON)
|
||||
|
||||
option( USE_GUI "don't build netgen with GUI" ON )
|
||||
@ -189,6 +191,10 @@ install(EXPORT netgen-targets DESTINATION ${NG_INSTALL_DIR_CMAKE} COMPONENT netg
|
||||
|
||||
set(CMAKE_MACOSX_RPATH TRUE)
|
||||
set(CMAKE_INSTALL_RPATH "${NG_RPATH_TOKEN};${NG_RPATH_TOKEN}/${NETGEN_RPATH}")
|
||||
if(BUILD_FOR_CONDA)
|
||||
file(RELATIVE_PATH py_rpath "/bin" "/${NG_INSTALL_DIR_LIB}")
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH};${py_rpath}")
|
||||
endif(BUILD_FOR_CONDA)
|
||||
|
||||
include (CheckIncludeFiles)
|
||||
check_include_files (dlfcn.h HAVE_DLFCN_H)
|
||||
@ -236,6 +242,7 @@ include_directories(${ZLIB_INCLUDE_DIRS})
|
||||
#######################################################################
|
||||
if (USE_GUI)
|
||||
find_package(TCL 8.5 REQUIRED)
|
||||
find_package(TclStub 8.5 REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
if(APPLE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework AppKit")
|
||||
@ -244,7 +251,7 @@ if (USE_GUI)
|
||||
endif(APPLE)
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
add_definitions(-DTCL -DOPENGL -DUSE_TOGL_2)
|
||||
add_definitions(-DTCL -DOPENGL -DUSE_TOGL_2 -DUSE_TCL_STUBS -DUSE_TK_STUBS)
|
||||
include_directories(${TCL_INCLUDE_PATH})
|
||||
include_directories(${TK_INCLUDE_PATH})
|
||||
set(LIBTOGL togl)
|
||||
@ -277,7 +284,7 @@ if (USE_PYTHON)
|
||||
endif( PYBIND_INCLUDE_DIR )
|
||||
|
||||
target_include_directories(netgen_python INTERFACE ${PYBIND_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS})
|
||||
if(NOT ${BUILD_FOR_CONDA})
|
||||
if(NOT ${BUILD_FOR_CONDA} OR WIN32)
|
||||
# Don't link python libraries in conda environments
|
||||
target_link_libraries(netgen_python INTERFACE ${PYTHON_LIBRARIES})
|
||||
endif()
|
||||
@ -314,7 +321,7 @@ install(TARGETS netgen_mpi netgen_metis ${NG_INSTALL_DIR})
|
||||
|
||||
#######################################################################
|
||||
if (USE_OCC)
|
||||
find_package(OpenCasCade NAMES OpenCASCADE opencascade REQUIRED)
|
||||
find_package(OpenCascade NAMES OpenCASCADE opencascade REQUIRED CMAKE_FIND_ROOT_PATH_BOTH)
|
||||
add_definitions(-DOCCGEOMETRY)
|
||||
set(OCC_LIBRARIES
|
||||
TKBO
|
||||
@ -352,8 +359,17 @@ if (USE_OCC)
|
||||
)
|
||||
include_directories(${OpenCASCADE_INCLUDE_DIR})
|
||||
if(NOT OpenCASCADE_BUILD_SHARED_LIBS)
|
||||
find_library( FREETYPE NAMES freetype )
|
||||
find_library( FREETYPE NAMES freetype HINTS ${OpenCASCADE_INSTALL_PREFIX}/lib)
|
||||
list(APPEND OCC_LIBRARIES ${FREETYPE})
|
||||
if(UNIX AND NOT APPLE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
list(APPEND OCC_LIBRARIES Threads::Threads)
|
||||
find_package(Fontconfig REQUIRED)
|
||||
list(APPEND OCC_LIBRARIES ${Fontconfig_LIBRARIES})
|
||||
list(PREPEND OCC_LIBRARIES -Wl,--start-group)
|
||||
list(APPEND OCC_LIBRARIES -Wl,--end-group)
|
||||
endif()
|
||||
endif()
|
||||
message(STATUS "OCC DIRS ${OpenCASCADE_INCLUDE_DIR}")
|
||||
endif (USE_OCC)
|
||||
|
@ -42,10 +42,10 @@ set(NETGEN_PYTHON_EXECUTABLE "@PYTHON_EXECUTABLE@")
|
||||
set(NETGEN_PYTHON_INCLUDE_DIRS "@PYTHON_INCLUDE_DIRS@")
|
||||
set(NETGEN_PYTHON_LIBRARIES "@PYTHON_LIBRARIES@")
|
||||
set(NETGEN_TCL_INCLUDE_PATH "@TCL_INCLUDE_PATH@")
|
||||
set(NETGEN_TCL_LIBRARY "@TCL_LIBRARY@")
|
||||
set(NETGEN_TCL_LIBRARY "@TCL_STUB_LIBRARY@")
|
||||
set(NETGEN_TK_DND_LIBRARY "@TK_DND_LIBRARY@")
|
||||
set(NETGEN_TK_INCLUDE_PATH "@TK_INCLUDE_PATH@")
|
||||
set(NETGEN_TK_LIBRARY "@TK_LIBRARY@")
|
||||
set(NETGEN_TK_LIBRARY "@TK_STUB_LIBRARY@")
|
||||
set(NETGEN_X11_X11_LIB "@X11_X11_LIB@")
|
||||
set(NETGEN_X11_Xmu_LIB "@X11_Xmu_LIB@")
|
||||
set(NETGEN_ZLIB_INCLUDE_DIRS "@ZLIB_INCLUDE_DIRS@")
|
||||
|
@ -1,19 +1,58 @@
|
||||
include (ExternalProject)
|
||||
|
||||
option( BUILD_ZLIB "Build and link static version of zlib (usefull for pip binaries)" OFF )
|
||||
option( BUILD_OCC "Build and link static version of occ (usefull for pip binaries)" OFF )
|
||||
set_property (DIRECTORY PROPERTY EP_PREFIX dependencies)
|
||||
|
||||
set (NETGEN_DEPENDENCIES)
|
||||
set (LAPACK_DEPENDENCIES)
|
||||
set (NETGEN_CMAKE_ARGS "" CACHE INTERNAL "")
|
||||
set (SUBPROJECT_CMAKE_ARGS "" CACHE INTERNAL "")
|
||||
set (SUBPROJECT_ARGS
|
||||
LOG_DOWNLOAD ON
|
||||
LOG_BUILD ON
|
||||
LOG_INSTALL ON
|
||||
LOG_CONFIGURE ON
|
||||
LIST_SEPARATOR |
|
||||
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/dependencies
|
||||
)
|
||||
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14.0")
|
||||
set (SUBPROJECT_LOG_SETTINGS
|
||||
${SUBPROJECT_LOG_SETTINGS}
|
||||
LOG_OUTPUT_ON_FAILURE 1
|
||||
LOG_MERGED_STDOUTERR 1
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
set (NETGEN_CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} )
|
||||
|
||||
macro(set_vars VAR_OUT)
|
||||
foreach(varname ${ARGN})
|
||||
if(NOT "${${varname}}" STREQUAL "")
|
||||
string(REPLACE ";" "$<SEMICOLON>" varvalue "${${varname}}" )
|
||||
set(${VAR_OUT} ${${VAR_OUT}};-D${varname}=${varvalue} CACHE INTERNAL "")
|
||||
string(REPLACE ";" "|" varvalue "${${varname}}" )
|
||||
set(${VAR_OUT} "${${VAR_OUT}};-D${varname}=${varvalue}" CACHE INTERNAL "")
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
#######################################################################
|
||||
|
||||
set_vars(SUBPROJECT_CMAKE_ARGS CMAKE_OSX_DEPLOYMENT_TARGET)
|
||||
set_vars(SUBPROJECT_CMAKE_ARGS CMAKE_OSX_SYSROOT)
|
||||
set_vars(SUBPROJECT_CMAKE_ARGS CMAKE_OSX_ARCHITECTURES)
|
||||
set_vars(SUBPROJECT_CMAKE_ARGS CMAKE_C_COMPILER)
|
||||
set_vars(SUBPROJECT_CMAKE_ARGS CMAKE_CXX_COMPILER)
|
||||
set_vars(SUBPROJECT_CMAKE_ARGS CMAKE_BUILD_TYPE)
|
||||
|
||||
set(SUBPROJECT_CMAKE_ARGS "${SUBPROJECT_CMAKE_ARGS};-DCMAKE_POSITION_INDEPENDENT_CODE=ON" CACHE INTERNAL "")
|
||||
|
||||
if(USE_CCACHE)
|
||||
find_program(CCACHE_FOUND NAMES ccache ccache.bat)
|
||||
if(CCACHE_FOUND)
|
||||
set(SUBPROJECT_CMAKE_ARGS "${SUBPROJECT_CMAKE_ARGS};-DCMAKE_CXX_COMPILER_LAUNCHER=${CCACHE_FOUND}" CACHE INTERNAL "")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#######################################################################
|
||||
set (DEPS_DOWNLOAD_URL "https://github.com/NGSolve/ngsolve_dependencies/releases/download/v1.0.0" CACHE STRING INTERNAL)
|
||||
set (OCC_DOWNLOAD_URL_WIN "${DEPS_DOWNLOAD_URL}/occ75_win64.zip" CACHE STRING INTERNAL)
|
||||
@ -22,6 +61,7 @@ set (ZLIB_DOWNLOAD_URL_WIN "${DEPS_DOWNLOAD_URL}/zlib_win64.zip" CACHE STRING IN
|
||||
set (CGNS_DOWNLOAD_URL_WIN "${DEPS_DOWNLOAD_URL}/cgns_win64.zip" CACHE STRING INTERNAL)
|
||||
set (CGNS_DOWNLOAD_URL_MAC "${DEPS_DOWNLOAD_URL}/cgns_mac.zip" CACHE STRING INTERNAL)
|
||||
|
||||
|
||||
if(UNIX)
|
||||
message("Checking for write permissions in install directory...")
|
||||
execute_process(COMMAND mkdir -p ${CMAKE_INSTALL_PREFIX})
|
||||
@ -31,10 +71,94 @@ if(UNIX)
|
||||
endif()
|
||||
endif(UNIX)
|
||||
|
||||
if(NOT WIN32)
|
||||
find_package(ZLIB REQUIRED)
|
||||
set_vars(NETGEN_CMAKE_ARGS ZLIB_INCLUDE_DIRS ZLIB_LIBRARIES)
|
||||
endif(NOT WIN32)
|
||||
if(USE_OCC)
|
||||
if(BUILD_OCC)
|
||||
set(OCC_DIR ${CMAKE_CURRENT_BINARY_DIR}/dependencies/occ)
|
||||
|
||||
ExternalProject_Add(project_freetype
|
||||
URL https://github.com/freetype/freetype/archive/refs/tags/VER-2-11-0.zip
|
||||
URL_MD5 f58ef6a7affb7794c4f125d98e0e6a25
|
||||
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
|
||||
${SUBPROJECT_ARGS}
|
||||
CMAKE_ARGS
|
||||
-DCMAKE_INSTALL_PREFIX=${OCC_DIR}
|
||||
-DBUILD_SHARED_LIBS:BOOL=OFF
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_ZLIB=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_BZip2=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_PNG=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_HarfBuzz=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_BrotliDec=TRUE
|
||||
${SUBPROJECT_CMAKE_ARGS}
|
||||
UPDATE_COMMAND ""
|
||||
)
|
||||
|
||||
ExternalProject_Add(project_occ
|
||||
DEPENDS project_freetype
|
||||
URL https://github.com/Open-Cascade-SAS/OCCT/archive/refs/tags/V7_5_0.zip
|
||||
URL_MD5 a24e6d3cf2d24bf9347d2d4aee9dd80a
|
||||
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
|
||||
${SUBPROJECT_ARGS}
|
||||
CMAKE_ARGS
|
||||
-DCMAKE_INSTALL_PREFIX=${OCC_DIR}
|
||||
-DCMAKE_PREFIX_PATH=${OCC_DIR}
|
||||
-DBUILD_LIBRARY_TYPE:STRING=Static
|
||||
-DBUILD_MODULE_FoundationClasses:BOOL=ON
|
||||
-DBUILD_MODULE_ModelingData:BOOL=ON
|
||||
-DBUILD_MODULE_ModelingAlgorithms:BOOL=ON
|
||||
-DBUILD_MODULE_Visualization:BOOL=ON
|
||||
-DBUILD_MODULE_DataExchange:BOOL=ON
|
||||
-DBUILD_MODULE_ApplicationFramework:BOOL=OFF
|
||||
-DBUILD_MODULE_Draw:BOOL=OFF
|
||||
-DUSE_FREETYPE=OFF
|
||||
${SUBPROJECT_CMAKE_ARGS}
|
||||
UPDATE_COMMAND ""
|
||||
)
|
||||
|
||||
list(APPEND NETGEN_DEPENDENCIES project_occ)
|
||||
set(OpenCascade_ROOT ${OCC_DIR})
|
||||
else(BUILD_OCC)
|
||||
if(WIN32 AND NOT OCC_INCLUDE_DIR AND NOT OpenCASCADE_DIR)
|
||||
# we can download prebuilt occ binaries for windows
|
||||
ExternalProject_Add(win_download_occ
|
||||
${SUBPROJECT_ARGS}
|
||||
URL ${OCC_DOWNLOAD_URL_WIN}
|
||||
UPDATE_COMMAND "" # Disable update
|
||||
BUILD_IN_SOURCE 1
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory . ${CMAKE_INSTALL_PREFIX}
|
||||
)
|
||||
list(APPEND NETGEN_DEPENDENCIES win_download_occ)
|
||||
else()
|
||||
find_package(OpenCascade NAMES OpenCasCade OpenCASCADE opencascade REQUIRED)
|
||||
endif()
|
||||
endif(BUILD_OCC)
|
||||
endif(USE_OCC)
|
||||
|
||||
if(BUILD_ZLIB)
|
||||
set(ZLIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/dependencies/zlib)
|
||||
ExternalProject_Add(project_zlib
|
||||
${SUBPROJECT_ARGS}
|
||||
URL https://github.com/madler/zlib/archive/refs/tags/v1.2.11.zip
|
||||
URL_MD5 9d6a627693163bbbf3f26403a3a0b0b1
|
||||
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
|
||||
CMAKE_ARGS
|
||||
-DCMAKE_INSTALL_PREFIX=${ZLIB_DIR}
|
||||
${SUBPROJECT_CMAKE_ARGS}
|
||||
UPDATE_COMMAND "" # Disable update
|
||||
BUILD_IN_SOURCE 1
|
||||
)
|
||||
|
||||
list(APPEND NETGEN_DEPENDENCIES project_zlib)
|
||||
list(APPEND NETGEN_CMAKE_PREFIX_PATH ${ZLIB_DIR})
|
||||
if(WIN32)
|
||||
# force linking the static library
|
||||
set(ZLIB_INCLUDE_DIRS ${ZLIB_DIR}/include)
|
||||
set(ZLIB_LIBRARIES ${ZLIB_DIR}/lib/zlibstatic.lib)
|
||||
endif(WIN32)
|
||||
else()
|
||||
include(cmake/external_projects/zlib.cmake)
|
||||
endif()
|
||||
|
||||
#######################################################################
|
||||
if (USE_PYTHON)
|
||||
@ -65,27 +189,6 @@ endif (USE_PYTHON)
|
||||
|
||||
#######################################################################
|
||||
|
||||
if(USE_OCC)
|
||||
if(WIN32 AND NOT OCC_INCLUDE_DIR AND NOT OpenCASCADE_DIR)
|
||||
ExternalProject_Add(win_download_occ
|
||||
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/tcl
|
||||
URL ${OCC_DOWNLOAD_URL_WIN}
|
||||
UPDATE_COMMAND "" # Disable update
|
||||
BUILD_IN_SOURCE 1
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory . ${CMAKE_INSTALL_PREFIX}
|
||||
LOG_DOWNLOAD 1
|
||||
)
|
||||
list(APPEND NETGEN_DEPENDENCIES win_download_occ)
|
||||
else()
|
||||
find_package(OpenCasCade NAMES OpenCASCADE opencascade REQUIRED)
|
||||
endif()
|
||||
endif(USE_OCC)
|
||||
|
||||
#######################################################################
|
||||
|
||||
include(cmake/external_projects/zlib.cmake)
|
||||
if(USE_GUI)
|
||||
include(cmake/external_projects/tcltk.cmake)
|
||||
endif(USE_GUI)
|
||||
@ -116,14 +219,10 @@ endif(USE_MPI)
|
||||
#######################################################################
|
||||
# propagate cmake variables to Netgen subproject
|
||||
set_vars( NETGEN_CMAKE_ARGS
|
||||
CMAKE_CXX_COMPILER
|
||||
CMAKE_BUILD_TYPE
|
||||
CMAKE_SHARED_LINKER_FLAGS
|
||||
CMAKE_SHARED_LINKER_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS
|
||||
CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_OSX_DEPLOYMENT_TARGET
|
||||
CMAKE_OSX_SYSROOT
|
||||
|
||||
USE_GUI
|
||||
USE_PYTHON
|
||||
@ -140,7 +239,6 @@ set_vars( NETGEN_CMAKE_ARGS
|
||||
USE_INTERNAL_TCL
|
||||
INSTALL_PROFILES
|
||||
INTEL_MIC
|
||||
CMAKE_PREFIX_PATH
|
||||
CMAKE_INSTALL_PREFIX
|
||||
ENABLE_UNIT_TESTS
|
||||
ENABLE_CPP_CORE_GUIDELINES_CHECK
|
||||
@ -151,7 +249,9 @@ set_vars( NETGEN_CMAKE_ARGS
|
||||
BUILD_STUB_FILES
|
||||
BUILD_FOR_CONDA
|
||||
NG_COMPILE_FLAGS
|
||||
OpenCasCade_DIR
|
||||
OpenCascade_ROOT
|
||||
ZLIB_INCLUDE_DIRS
|
||||
ZLIB_LIBRARIES
|
||||
)
|
||||
|
||||
# propagate all variables set on the command line using cmake -DFOO=BAR
|
||||
@ -161,7 +261,8 @@ foreach(CACHE_VAR ${CACHE_VARS})
|
||||
get_property(CACHE_VAR_HELPSTRING CACHE ${CACHE_VAR} PROPERTY HELPSTRING)
|
||||
if(CACHE_VAR_HELPSTRING STREQUAL "No help, variable specified on the command line.")
|
||||
get_property(CACHE_VAR_TYPE CACHE ${CACHE_VAR} PROPERTY TYPE)
|
||||
set(NETGEN_CMAKE_ARGS ${NETGEN_CMAKE_ARGS};-D${CACHE_VAR}:${CACHE_VAR_TYPE}=${${CACHE_VAR}} CACHE INTERNAL "")
|
||||
string(REPLACE ";" "|" varvalue "${${CACHE_VAR}}" )
|
||||
set(NETGEN_CMAKE_ARGS ${NETGEN_CMAKE_ARGS};-D${CACHE_VAR}:${CACHE_VAR_TYPE}=${varvalue} CACHE INTERNAL "")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
@ -171,19 +272,21 @@ else()
|
||||
set(NETGEN_BUILD_COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/netgen --config ${CMAKE_BUILD_TYPE})
|
||||
endif()
|
||||
|
||||
if(DEFINED ENV{CI} AND WIN32)
|
||||
set(log_output LOG_BUILD ON LOG_MERGED_STDOUTERR ON LOG_OUTPUT_ON_FAILURE ON)
|
||||
endif()
|
||||
|
||||
string(REPLACE ";" "|" NETGEN_CMAKE_PREFIX_PATH_ALT_SEP "${NETGEN_CMAKE_PREFIX_PATH}")
|
||||
ExternalProject_Add (netgen
|
||||
${SUBPROJECT_ARGS}
|
||||
DEPENDS ${NETGEN_DEPENDENCIES}
|
||||
SOURCE_DIR ${PROJECT_SOURCE_DIR}
|
||||
CMAKE_ARGS -DUSE_SUPERBUILD=OFF ${NETGEN_CMAKE_ARGS}
|
||||
CMAKE_ARGS
|
||||
-DUSE_SUPERBUILD=OFF
|
||||
${NETGEN_CMAKE_ARGS}
|
||||
${SUBPROJECT_CMAKE_ARGS}
|
||||
-DCMAKE_PREFIX_PATH=${NETGEN_CMAKE_PREFIX_PATH_ALT_SEP}
|
||||
INSTALL_COMMAND ""
|
||||
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/netgen
|
||||
BUILD_COMMAND ${NETGEN_BUILD_COMMAND}
|
||||
STEP_TARGETS build
|
||||
${log_output}
|
||||
)
|
||||
|
||||
# Check if the git submodules (i.e. pybind11) are up to date
|
||||
|
@ -1,3 +1,68 @@
|
||||
if(UNIX AND NOT APPLE)
|
||||
set (LINUX TRUE)
|
||||
endif()
|
||||
if(LINUX)
|
||||
find_package(TclStub 8.5 REQUIRED)
|
||||
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
|
||||
"import tkinter;print(tkinter.Tcl().eval('info patchlevel').replace('.','-'))"
|
||||
OUTPUT_VARIABLE PYTHON_TCL_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
set(TCL_DIR ${CMAKE_CURRENT_BINARY_DIR}/dependencies/src/project_tcl)
|
||||
set(TK_DIR ${CMAKE_CURRENT_BINARY_DIR}/dependencies/src/project_tk)
|
||||
|
||||
ExternalProject_Add(project_tcl
|
||||
URL "https://github.com/tcltk/tcl/archive/refs/tags/core-${PYTHON_TCL_VERSION}.zip"
|
||||
UPDATE_COMMAND ""
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
${SUBPROJECT_ARGS}
|
||||
DOWNLOAD_DIR download_tcl
|
||||
)
|
||||
ExternalProject_Add(project_tk
|
||||
URL "https://github.com/tcltk/tk/archive/refs/tags/core-${PYTHON_TCL_VERSION}.zip"
|
||||
UPDATE_COMMAND ""
|
||||
CONFIGURE_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
BUILD_COMMAND ${CMAKE_COMMAND} -E copy_directory macosx generic
|
||||
${SUBPROJECT_ARGS}
|
||||
DOWNLOAD_DIR download_tk
|
||||
BUILD_IN_SOURCE 1
|
||||
)
|
||||
|
||||
set(TCL_INCLUDE_PATH ${TCL_DIR}/generic)
|
||||
set(TK_INCLUDE_PATH ${TK_DIR}/generic;${TK_DIR}/xlib;${TK_DIR}/win)
|
||||
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)
|
||||
file(TO_CMAKE_PATH ${PYTHON_PREFIX} PYTHON_PREFIX)
|
||||
|
||||
set(tcl_find_args
|
||||
REQUIRED
|
||||
NO_DEFAULT_PATH
|
||||
NO_PACKAGE_ROOT_PATH
|
||||
NO_CMAKE_PATH
|
||||
NO_CMAKE_ENVIRONMENT_PATH
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
NO_CMAKE_SYSTEM_PATH
|
||||
NO_CMAKE_FIND_ROOT_PATH
|
||||
HINTS ${PYTHON_PREFIX}/lib ${PYTHON_PREFIX}/tcl
|
||||
)
|
||||
find_library(TCL_STUB_LIBRARY NAMES tclstub85 tclstub8.5 tclstub86 tclstub8.6 ${tcl_find_args})
|
||||
find_library(TK_STUB_LIBRARY NAMES tkstub85 tkstub8.5 tkstub86 tkstub8.6 ${tcl_find_args})
|
||||
find_library(TCL_LIBRARY NAMES tcl85 tcl8.5 tcl86 tcl8.6 tcl86t ${tcl_find_args})
|
||||
find_library(TK_LIBRARY NAMES tk85 tk8.5 tk86 tk8.6 tk86t ${tcl_find_args})
|
||||
else()
|
||||
# use system tcl/tk on linux
|
||||
find_package(TclStub REQUIRED)
|
||||
endif()
|
||||
|
||||
else(SKBUILD)
|
||||
if(APPLE)
|
||||
set(tcl_prefix ${CMAKE_INSTALL_PREFIX})
|
||||
# URL "http://sourceforge.net/projects/tcl/files/Tcl/8.6.9/tcl8.6.9-src.tar.gz"
|
||||
@ -10,10 +75,7 @@ if(APPLE)
|
||||
CONFIGURE_COMMAND ../project_tcl/macosx/configure --enable-threads --enable-framework --prefix=${tcl_prefix} --libdir=${tcl_prefix}/Contents/Frameworks --bindir=${tcl_prefix}/Contents/Frameworks/Tcl.framework/bin
|
||||
BUILD_COMMAND make -j4 binaries libraries
|
||||
INSTALL_COMMAND make install-binaries install-headers install-libraries install-private-headers
|
||||
LOG_DOWNLOAD 1
|
||||
LOG_BUILD 1
|
||||
LOG_CONFIGURE 1
|
||||
LOG_INSTALL 1
|
||||
${SUBPROJECT_ARGS}
|
||||
)
|
||||
|
||||
# URL "http://sourceforge.net/projects/tcl/files/Tcl/8.6.9/tk8.6.9.1-src.tar.gz"
|
||||
@ -27,10 +89,7 @@ if(APPLE)
|
||||
CONFIGURE_COMMAND ../project_tk/macosx/configure --enable-aqua=yes --enable-threads --enable-framework --prefix=${tcl_prefix} --libdir=${tcl_prefix}/Contents/Frameworks --bindir=${tcl_prefix}/Contents/Frameworks/Tcl.framework/bin --with-tcl=${tcl_prefix}/Contents/Frameworks/Tcl.framework
|
||||
BUILD_COMMAND make -j4 binaries libraries
|
||||
INSTALL_COMMAND make install-binaries install-headers install-libraries install-private-headers
|
||||
LOG_DOWNLOAD 1
|
||||
LOG_BUILD 1
|
||||
LOG_CONFIGURE 1
|
||||
LOG_INSTALL 1
|
||||
${SUBPROJECT_ARGS}
|
||||
)
|
||||
|
||||
ExternalProject_Add(project_tkdnd
|
||||
@ -45,10 +104,7 @@ if(APPLE)
|
||||
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/Contents/MacOS
|
||||
-DTCL_INCLUDE_PATH=${CMAKE_INSTALL_PREFIX}/Contents/Frameworks/Tcl.framework/Headers
|
||||
-DTK_INCLUDE_PATH=${CMAKE_INSTALL_PREFIX}/Contents/Frameworks/Tk.framework/Headers
|
||||
LOG_DOWNLOAD 1
|
||||
LOG_CONFIGURE 1
|
||||
LOG_BUILD 1
|
||||
LOG_INSTALL 1
|
||||
${SUBPROJECT_ARGS}
|
||||
)
|
||||
|
||||
list(APPEND NETGEN_DEPENDENCIES project_tcl project_tk project_tkdnd)
|
||||
@ -125,13 +181,15 @@ elseif(WIN32)
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory . ${CMAKE_INSTALL_PREFIX}
|
||||
LOG_DOWNLOAD 1
|
||||
${SUBPROJECT_ARGS}
|
||||
)
|
||||
|
||||
set (TK_INCLUDE_PATH ${CMAKE_INSTALL_PREFIX}/include)
|
||||
set (TCL_INCLUDE_PATH ${CMAKE_INSTALL_PREFIX}/include)
|
||||
set (TCL_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/tcl86t.lib)
|
||||
set (TK_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/tk86t.lib)
|
||||
set (TCL_STUB_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/tclstub86.lib)
|
||||
set (TK_STUB_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/tkstub86.lib)
|
||||
|
||||
list(APPEND NETGEN_DEPENDENCIES project_win_tcltk)
|
||||
else(WIN32)
|
||||
@ -148,6 +206,8 @@ else(WIN32)
|
||||
# )
|
||||
# list(APPEND NETGEN_DEPENDENCIES project_tkdnd)
|
||||
endif(APPLE)
|
||||
endif(SKBUILD)
|
||||
endif(LINUX)
|
||||
|
||||
# Propagate settings to Netgen subproject
|
||||
set_vars(NETGEN_CMAKE_ARGS TCL_INCLUDE_PATH TCL_LIBRARY TK_LIBRARY TK_INCLUDE_PATH TCL_TCLSH TK_WISH)
|
||||
set_vars(NETGEN_CMAKE_ARGS TCL_INCLUDE_PATH TCL_STUB_LIBRARY TCL_LIBRARY TK_STUB_LIBRARY TK_LIBRARY TK_INCLUDE_PATH TCL_TCLSH TK_WISH)
|
||||
|
@ -2,8 +2,12 @@ if(NOT BDIR)
|
||||
set(BDIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
find_package(Git REQUIRED)
|
||||
execute_process(COMMAND git describe --tags --match "v[0-9]*" --long --dirty WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} OUTPUT_VARIABLE git_version_string RESULT_VARIABLE status ERROR_QUIET)
|
||||
if(SKBUILD)
|
||||
set(git_version_string ${GIT_NETGEN_VERSION})
|
||||
else(SKBUILD)
|
||||
find_package(Git REQUIRED)
|
||||
execute_process(COMMAND git describe --tags --match "v[0-9]*" --long --dirty WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} OUTPUT_VARIABLE git_version_string RESULT_VARIABLE status ERROR_QUIET)
|
||||
endif(SKBUILD)
|
||||
|
||||
if(status AND NOT status EQUAL 0)
|
||||
if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/../version.txt)
|
||||
@ -61,6 +65,15 @@ else()
|
||||
file(WRITE ${BDIR}/netgen_version.hpp ${new_version_file_string})
|
||||
endif()
|
||||
|
||||
|
||||
set(py_version "${NETGEN_VERSION_MAJOR}.${NETGEN_VERSION_MINOR}.${NETGEN_VERSION_PATCH}")
|
||||
if(${NETGEN_VERSION_TWEAK} GREATER 0)
|
||||
set(py_version "${py_version}.dev${NETGEN_VERSION_TWEAK}")
|
||||
endif()
|
||||
if(NOT SKBUILD)
|
||||
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/python/version.py "__version__ = \"${py_version}\"\n")
|
||||
endif()
|
||||
|
||||
file(GENERATE OUTPUT netgen_config.hpp CONTENT
|
||||
"\
|
||||
#ifndef NETGEN_CONFIG_HPP_INCLUDED___
|
||||
|
@ -29,7 +29,7 @@ endif(USE_PYTHON)
|
||||
if(WIN32)
|
||||
target_compile_options(ngcore PUBLIC /bigobj /MP /W1 /wd4068)
|
||||
get_WIN32_WINNT(ver)
|
||||
target_compile_definitions(ngcore PUBLIC _WIN32_WINNT=${ver} WNT WNT_WINDOW NOMINMAX MSVC_EXPRESS _CRT_SECURE_NO_WARNINGS HAVE_STRUCT_TIMESPEC)
|
||||
target_compile_definitions(ngcore PUBLIC _WIN32_WINNT=${ver} WNT WNT_WINDOW NOMINMAX MSVC_EXPRESS _CRT_SECURE_NO_WARNINGS HAVE_STRUCT_TIMESPEC WIN32)
|
||||
target_link_options(ngcore PUBLIC /ignore:4273 /ignore:4217 /ignore:4049)
|
||||
else(WIN32)
|
||||
target_compile_options(ngcore PRIVATE -fvisibility=hidden)
|
||||
|
@ -20,30 +20,31 @@ if(USE_GUI)
|
||||
../libsrc/occ/occpkg.cpp ../libsrc/occ/vsocc.cpp
|
||||
)
|
||||
|
||||
target_link_libraries( gui PUBLIC nglib )
|
||||
target_link_libraries( gui PRIVATE ${LIBTOGL} ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} ${FFMPEG_LIBRARIES} ${X11_Xmu_LIB} ${X11_X11_LIB} ${OCC_LIBRARIES} )
|
||||
target_link_libraries( gui PRIVATE ${TCL_STUB_LIBRARY} ${TK_STUB_LIBRARY})
|
||||
|
||||
if(NOT BUILD_FOR_CONDA)
|
||||
add_executable(netgen ngappinit.cpp)
|
||||
if(WIN32)
|
||||
target_sources(netgen PRIVATE ../windows/netgen.rc)
|
||||
endif(WIN32)
|
||||
|
||||
target_link_libraries( gui PUBLIC nglib )
|
||||
target_link_libraries( gui PRIVATE ${LIBTOGL} ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} ${FFMPEG_LIBRARIES} ${X11_Xmu_LIB} ${X11_X11_LIB} ${OCC_LIBRARIES} )
|
||||
if(NOT APPLE)
|
||||
target_link_libraries( gui PRIVATE ${TCL_LIBRARY} ${TK_LIBRARY})
|
||||
endif(NOT APPLE)
|
||||
|
||||
target_link_libraries( netgen nglib gui netgen_python ${MPI_mpi_LIBRARY} ${MPI_CXX_LIBRARIES} ${LIBTOGL} ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} ${FFMPEG_LIBRARIES} ${X11_Xmu_LIB} ${X11_X11_LIB} ${OCC_LIBRARIES} ${TK_LIBRARY} ${TCL_LIBRARY})
|
||||
|
||||
if(NOT WIN32)
|
||||
else(WIN32)
|
||||
target_link_libraries( netgen mesh stlvis stl geom2dvis interface geom2d csg stl visual csgvis )
|
||||
target_link_libraries( gui PUBLIC mesh stlvis stl geom2dvis interface geom2d csg stl visual csgvis )
|
||||
endif(NOT WIN32)
|
||||
|
||||
endif(WIN32)
|
||||
target_link_libraries( netgen nglib gui netgen_python ${MPI_mpi_LIBRARY} ${MPI_CXX_LIBRARIES} ${LIBTOGL} ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} ${FFMPEG_LIBRARIES} ${X11_Xmu_LIB} ${X11_X11_LIB} ${OCC_LIBRARIES} ${TK_LIBRARY} ${TCL_LIBRARY})
|
||||
install(TARGETS netgen ${NG_INSTALL_DIR})
|
||||
install(TARGETS gui ${NG_INSTALL_DIR})
|
||||
|
||||
if(APPLE)
|
||||
set_target_properties(netgen PROPERTIES OUTPUT_NAME netgen)
|
||||
endif(APPLE)
|
||||
target_link_libraries( netgen ${PYTHON_LIBRARIES})
|
||||
endif(NOT BUILD_FOR_CONDA)
|
||||
|
||||
if(NOT WIN32)
|
||||
target_link_libraries( gui PUBLIC mesh stlvis stl geom2dvis interface geom2d csg stl visual csgvis )
|
||||
endif(NOT WIN32)
|
||||
|
||||
install(TARGETS gui ${NG_INSTALL_DIR})
|
||||
|
||||
if(WIN32)
|
||||
set_target_properties( gui PROPERTIES OUTPUT_NAME libgui )
|
||||
endif(WIN32)
|
||||
@ -52,14 +53,6 @@ if(USE_GUI)
|
||||
endif(USE_GUI)
|
||||
|
||||
if(USE_PYTHON)
|
||||
if(USE_GUI)
|
||||
if(${BUILD_FOR_CONDA} AND UNIX AND NOT APPLE)
|
||||
target_link_libraries( netgen -Wl,--no-as-needed ${PYTHON_LIBRARIES})
|
||||
elseif()
|
||||
target_link_libraries( netgen ${PYTHON_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_library(ngpy SHARED netgenpy.cpp)
|
||||
target_link_libraries( ngpy PUBLIC nglib PRIVATE "$<BUILD_INTERFACE:netgen_python>" )
|
||||
if(APPLE)
|
||||
|
@ -8,7 +8,7 @@ if(WIN32)
|
||||
add_definitions("-DBUILD_togl -DUNICODE -D_UNICODE -DTOGL_USE_FONTS=0 -DSTDC_HEADERS -DSTDC_HEADER")
|
||||
add_library(togl SHARED togl.c toglProcAddr.c toglStubInit.c)
|
||||
install(TARGETS togl DESTINATION ${NG_INSTALL_DIR} COMPONENT netgen)
|
||||
target_link_libraries(togl ${TCL_LIBRARY} ${TK_LIBRARY})
|
||||
target_link_libraries(togl ${TCL_STUB_LIBRARY} ${TK_STUB_LIBRARY})
|
||||
else(WIN32)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer -Wno-implicit-int")
|
||||
add_definitions("-DPACKAGE_NAME=\"Togl\" -DPACKAGE_TARNAME=\"togl\" -DPACKAGE_VERSION=\"2.1\" -DPACKAGE_STRING=\"Togl\ 2.1\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=0 -DHAVE_LIMITS_H=1 -DHAVE_SYS_PARAM_H=1 -DUSE_THREAD_ALLOC=1 -D_REENTRANT=1 -D_THREAD_SAFE=1 -DTCL_THREADS=1 -DMODULE_SCOPE=extern\ __attribute__\(\(__visibility__\(\"hidden\"\)\)\) -D_LARGEFILE64_SOURCE=1 -DTCL_WIDE_INT_IS_LONG=1 -DUSE_TCL_STUBS=1 -DUSE_TK_STUBS=1 -DAUTOSTEREOD=\"\"")
|
||||
@ -21,7 +21,7 @@ else(WIN32)
|
||||
include_directories(BEFORE "${TK_INCLUDE_PATH}")
|
||||
|
||||
add_library(togl togl.c toglProcAddr.c toglStubInit.c)
|
||||
target_link_libraries(togl -ldl)
|
||||
target_link_libraries(togl ${TCL_STUB_LIBRARY} ${TK_STUB_LIBRARY})
|
||||
endif(WIN32)
|
||||
|
||||
target_link_libraries(togl ${OPENGL_LIBRARIES})
|
||||
|
@ -14,6 +14,15 @@
|
||||
* Currently we support X11, Win32 and Mac OS X only
|
||||
*/
|
||||
|
||||
#ifndef MODULE_SCOPE
|
||||
# ifdef __cplusplus
|
||||
# define MODULE_SCOPE extern "C"
|
||||
# else
|
||||
# define MODULE_SCOPE extern
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#define USE_TOGL_STUB_PROCS
|
||||
#include "togl.h"
|
||||
#include <tkInt.h> // don't need it on osx ???
|
||||
|
@ -17,6 +17,8 @@ extern "C" void Ng_TclCmd(string);
|
||||
// tcl package dynamic load
|
||||
extern "C" int NGCORE_API_EXPORT Gui_Init (Tcl_Interp * interp)
|
||||
{
|
||||
Tcl_InitStubs( interp, TCL_VERSION, 0 );
|
||||
Tk_InitStubs( interp, TK_VERSION, 0 );
|
||||
if (Ng_Init(interp) == TCL_ERROR) {
|
||||
cerr << "Problem in Ng_Init: " << endl;
|
||||
cout << "result = " << Tcl_GetStringResult (interp) << endl;
|
||||
|
@ -3,6 +3,9 @@
|
||||
This file is a modification of tkAppInit.c from the Tcl/Tk package
|
||||
*/
|
||||
|
||||
#undef USE_TCL_STUBS
|
||||
#undef USE_TK_STUBS
|
||||
|
||||
#include <mystdlib.h>
|
||||
#include <inctcl.hpp>
|
||||
#include <meshing.hpp>
|
||||
|
@ -38,7 +38,7 @@ if(USE_OCC AND NOT WIN32)
|
||||
endif(USE_OCC AND NOT WIN32)
|
||||
|
||||
if(USE_PYTHON)
|
||||
target_link_libraries(nglib PRIVATE ${PYTHON_LIBRARIES})
|
||||
target_link_libraries(nglib PRIVATE netgen_python)
|
||||
endif(USE_PYTHON)
|
||||
|
||||
install(TARGETS nglib ${NG_INSTALL_DIR})
|
||||
|
1
python/.gitignore
vendored
Normal file
1
python/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
version.py
|
@ -1,9 +1,10 @@
|
||||
configure_file(__init__.py ${CMAKE_CURRENT_BINARY_DIR}/__init__.py @ONLY)
|
||||
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/__init__.py
|
||||
${CMAKE_CURRENT_BINARY_DIR}/__init__.py __main__.py
|
||||
meshing.py csg.py geom2d.py stl.py gui.py NgOCC.py occ.py read_gmsh.py
|
||||
webgui.py
|
||||
version.py # generated by either cmake or setup.py
|
||||
DESTINATION ${NG_INSTALL_DIR_PYTHON}/${NG_INSTALL_SUFFIX}
|
||||
COMPONENT netgen
|
||||
)
|
||||
|
@ -13,6 +13,8 @@ if sys.platform.startswith('win'):
|
||||
del sys
|
||||
del os
|
||||
|
||||
from .version import __version__
|
||||
|
||||
from . import libngpy
|
||||
|
||||
def Redraw(*args, **kwargs):
|
||||
|
14
python/__main__.py
Normal file
14
python/__main__.py
Normal file
@ -0,0 +1,14 @@
|
||||
import imp, threading
|
||||
|
||||
def handle_arguments():
|
||||
import sys, __main__
|
||||
argv = sys.argv
|
||||
if len(argv)>1 and argv[1].endswith(".py"):
|
||||
with open(argv[1]) as pyfile:
|
||||
imp.load_module('__main__', pyfile, argv[1], (".py", "r", imp.PY_SOURCE))
|
||||
|
||||
def main():
|
||||
from .gui import win
|
||||
th = threading.Thread(target=handle_arguments)
|
||||
th.start()
|
||||
win.tk.mainloop()
|
@ -11,20 +11,11 @@ def StartGUI():
|
||||
win.tk.eval('load "'+netgen._netgen_lib_dir.replace('\\','/')+'/libgui[info sharedlibextension]" gui')
|
||||
win.tk.eval( netgen.libngpy._meshing._ngscript)
|
||||
|
||||
try:
|
||||
from IPython import get_ipython
|
||||
ipython = get_ipython()
|
||||
ipython.magic('gui tk')
|
||||
except:
|
||||
pass
|
||||
|
||||
if not netgen.libngpy._meshing._netgen_executable_started:
|
||||
import os
|
||||
if not "NETGEN_DOCUMENTATION_RST_FORMAT" in os.environ:
|
||||
try:
|
||||
StartGUI()
|
||||
except:
|
||||
pass
|
||||
StartGUI()
|
||||
|
||||
def Snapshot(w,h, filename=None):
|
||||
netgen.Redraw(blocking=True)
|
||||
|
110
setup.py
Normal file
110
setup.py
Normal file
@ -0,0 +1,110 @@
|
||||
import glob
|
||||
import os
|
||||
import sys
|
||||
|
||||
from skbuild import setup
|
||||
import skbuild.cmaker
|
||||
from subprocess import check_output
|
||||
from distutils.sysconfig import get_python_lib;
|
||||
|
||||
setup_requires = []
|
||||
|
||||
def install_filter(cmake_manifest):
|
||||
print(cmake_manifest)
|
||||
return cmake_manifest
|
||||
|
||||
def _patched_parse_manifests(self):
|
||||
paths = \
|
||||
glob.glob(os.path.join(skbuild.cmaker.CMAKE_BUILD_DIR(), "netgen", "install_manifest*.txt"))
|
||||
try:
|
||||
return [self._parse_manifest(path) for path in paths][0]
|
||||
except IndexError:
|
||||
return []
|
||||
|
||||
# we are using the netgen superbuild (to download and build some dependencies)
|
||||
# patch the parse_manifests function to point to the actual netgen cmake project within the superbuild
|
||||
skbuild.cmaker.CMaker._parse_manifests = _patched_parse_manifests
|
||||
|
||||
git_version = check_output(['git', 'describe', '--tags']).decode('utf-8').strip()
|
||||
version = git_version[1:].split('-')
|
||||
if len(version)>2:
|
||||
version = version[:2]
|
||||
version = '.dev'.join(version)
|
||||
|
||||
version_file = os.path.join(os.path.dirname(__file__), "python", "version.py")
|
||||
|
||||
py_install_dir = get_python_lib(1,0,'').replace('\\','/')
|
||||
|
||||
name = "netgen-mesher"
|
||||
arch = None
|
||||
cmake_args = [
|
||||
f'-DGIT_NETGEN_VERSION={git_version}',
|
||||
]
|
||||
|
||||
if 'NETGEN_ARCH' in os.environ:
|
||||
arch = os.environ['NETGEN_ARCH']
|
||||
name += "-"+arch
|
||||
flag = '/'+arch if 'win' in sys.platform else f'-march={arch}'
|
||||
cmake_args += [f'-DNG_COMPILE_FLAGS={flag}']
|
||||
|
||||
if 'NETGEN_CCACHE' in os.environ:
|
||||
cmake_args += [f'-DUSE_CCACHE=ON']
|
||||
|
||||
if 'darwin' in sys.platform:
|
||||
cmake_args += [
|
||||
f'-DNG_INSTALL_DIR_LIB={py_install_dir}/netgen',
|
||||
f'-DNG_INSTALL_DIR_PYTHON={py_install_dir}',
|
||||
f'-DNG_INSTALL_DIR_CMAKE=lib/cmake',
|
||||
f'-DNG_INSTALL_DIR_BIN=bin',
|
||||
]
|
||||
elif 'win' in sys.platform:
|
||||
cmake_args += [
|
||||
'-A Win64',
|
||||
f'-DNG_INSTALL_DIR_BIN={py_install_dir}/netgen',
|
||||
f'-DNG_INSTALL_DIR_LIB=Library/lib',
|
||||
]
|
||||
elif 'linux' in sys.platform:
|
||||
name_dir = name.replace('-','_')
|
||||
cmake_args += [
|
||||
f'-DNG_INSTALL_DIR_LIB={py_install_dir}/{name_dir}.libs',
|
||||
f'-DNG_INSTALL_DIR_BIN=bin',
|
||||
]
|
||||
|
||||
cmake_args += [
|
||||
'-DUSE_SUPERBUILD:BOOL=ON',
|
||||
'-DUSE_CCACHE:BOOL=ON',
|
||||
'-DUSE_GUI=ON',
|
||||
'-DUSE_NATIVE_ARCH=OFF',
|
||||
'-DNG_INSTALL_DIR_INCLUDE=include/netgen',
|
||||
'-DBUILD_ZLIB=ON',
|
||||
'-DBUILD_OCC=ON',
|
||||
'-DUSE_OCC=ON',
|
||||
'-DBUILD_FOR_CONDA=ON',
|
||||
]
|
||||
|
||||
if 'PYDIR' in os.environ:
|
||||
cmake_args += [f'-DCMAKE_PREFIX_PATH={os.environ["PYDIR"]}']
|
||||
|
||||
with open(version_file, "w") as f:
|
||||
f.write(f'__version__ = "{version}"\n')
|
||||
f.write(f'__package_name__ = "{name}"\n')
|
||||
|
||||
setup(
|
||||
name=name,
|
||||
version=version,
|
||||
description="Netgen",
|
||||
author='The Netgen team',
|
||||
license="LGPL2.1",
|
||||
packages=['netgen'],
|
||||
package_dir={'netgen': 'python'},
|
||||
tests_require=['pytest'],
|
||||
include_package_data=True,
|
||||
cmake_process_manifest_hook=install_filter,
|
||||
cmake_args = cmake_args,
|
||||
setup_requires=setup_requires,
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'netgen = netgen.__main__:main',
|
||||
],
|
||||
},
|
||||
)
|
14
tests/build_pip.ps1
Normal file
14
tests/build_pip.ps1
Normal file
@ -0,0 +1,14 @@
|
||||
if (test-path _skbuild) {
|
||||
cmd.exe /c rd /s /q _skbuild
|
||||
}
|
||||
if (test-path dist) {
|
||||
cmd.exe /c rd /s /q dist
|
||||
}
|
||||
|
||||
$env:NETGEN_CCACHE = 1
|
||||
|
||||
$pydir=$args[0]
|
||||
& $pydir\python.exe --version
|
||||
& $pydir\python.exe -m pip install scikit-build wheel numpy twine
|
||||
& $pydir\python setup.py bdist_wheel -G"Visual Studio 16 2019"
|
||||
& $pydir\python -m twine upload --repository testpypi dist\*.whl
|
33
tests/build_pip.sh
Executable file
33
tests/build_pip.sh
Executable file
@ -0,0 +1,33 @@
|
||||
set -e
|
||||
yum -y update
|
||||
yum -y install ninja-build fontconfig-devel tk-devel tcl-devel libXmu-devel mesa-libGLU-devel ccache
|
||||
|
||||
rm -rf wheelhouse
|
||||
export NETGEN_CCACHE=1
|
||||
|
||||
/opt/python/cp39-cp39/bin/python tests/fix_auditwheel_policy.py
|
||||
|
||||
for pyversion in 38 39 310
|
||||
do
|
||||
export PYDIR="/opt/python/cp${pyversion}-cp${pyversion}/bin"
|
||||
echo $PYDIR
|
||||
$PYDIR/pip install -U pytest-check numpy wheel scikit-build
|
||||
|
||||
rm -rf _skbuild
|
||||
$PYDIR/pip wheel --use-feature=in-tree-build .
|
||||
auditwheel repair netgen_mesher*-cp${pyversion}-*.whl
|
||||
rm netgen_mesher-*.whl
|
||||
|
||||
#rm -rf _skbuild
|
||||
#NETGEN_ARCH=avx2 $PYDIR/pip wheel --use-feature=in-tree-build .
|
||||
#auditwheel repair netgen_mesher_avx2*-cp${pyversion}-*.whl
|
||||
#rm netgen_mesher_avx2-*.whl
|
||||
|
||||
$PYDIR/pip install wheelhouse/netgen_mesher*-cp${pyversion}-*.whl
|
||||
$PYDIR/python3 -c 'import netgen'
|
||||
#cd ../tests/pytest
|
||||
#$PYDIR/python3 -m pytest
|
||||
done
|
||||
|
||||
$PYDIR/pip install -U twine
|
||||
$PYDIR/twine upload --repository testpypi wheelhouse/*manylinux*.whl
|
13
tests/build_pip_mac.sh
Executable file
13
tests/build_pip_mac.sh
Executable file
@ -0,0 +1,13 @@
|
||||
set -e
|
||||
rm -rf _skbuild dist
|
||||
|
||||
export PATH=/Applications/CMake.app/Contents/bin:$PATH
|
||||
export NETGEN_CCACHE=1
|
||||
|
||||
export PYDIR=/Library/Frameworks/Python.framework/Versions/$1/bin
|
||||
$PYDIR/python3 --version
|
||||
$PYDIR/pip3 install --user numpy twine scikit-build wheel
|
||||
|
||||
export CMAKE_OSX_ARCHITECTURES='arm64;x86_64'
|
||||
$PYDIR/python3 setup.py bdist_wheel --plat-name macosx-10.14-universal2 -j10
|
||||
$PYDIR/python3 -m twine upload --repository testpypi dist/*.whl
|
26
tests/fix_auditwheel_policy.py
Normal file
26
tests/fix_auditwheel_policy.py
Normal file
@ -0,0 +1,26 @@
|
||||
import json
|
||||
|
||||
policy_file = "/opt/_internal/pipx/venvs/auditwheel/lib/python3.9/site-packages/auditwheel/policy/manylinux-policy.json"
|
||||
data = json.load(open(policy_file))
|
||||
additional_libs = [
|
||||
"libbz2.so.1.0.6",
|
||||
"libfontconfig.so.1.11.1",
|
||||
"libfreetype.so.6.14.0",
|
||||
"libGLU.so.1.3.1",
|
||||
"libpng15.so.15.13.0",
|
||||
"libtcl8.so",
|
||||
"libtk8.so",
|
||||
"libuuid.so.1.3.0",
|
||||
"libz.so.1.2.7",
|
||||
"libXmu.so.6",
|
||||
"libOpenGL.so.0",
|
||||
"libGLdispatch.so.0",
|
||||
"libGLX.so.0",
|
||||
"libGLU.so.1",
|
||||
]
|
||||
|
||||
for entry in data:
|
||||
if 'manylinux' in entry['name']:
|
||||
entry['lib_whitelist'] += additional_libs
|
||||
|
||||
json.dump(data, open(policy_file, 'w'))
|
@ -57,7 +57,7 @@ def test_boundarylayer2(outside, version, capfd):
|
||||
mesh.BoundaryLayer("default", [layersize, layersize], "part", domains="part", outside=outside)
|
||||
assert mesh.ne == should_ne
|
||||
assert not "elements are not matching" in capfd.readouterr().out
|
||||
import netgen.gui
|
||||
# import netgen.gui
|
||||
ngs = pytest.importorskip("ngsolve")
|
||||
ngs.Draw(ngs.Mesh(mesh))
|
||||
mesh = ngs.Mesh(mesh)
|
||||
|
@ -1,11 +0,0 @@
|
||||
import netgen
|
||||
import pytest
|
||||
|
||||
def test_gui():
|
||||
try:
|
||||
from tkinter import Tk
|
||||
win = Tk()
|
||||
except:
|
||||
pytest.skip("can't create a window")
|
||||
import netgen.gui
|
||||
|
Loading…
Reference in New Issue
Block a user