From 421c1ecb0e1dacb1326d0983ab0df5723a1842b4 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Mon, 5 Feb 2024 10:02:39 +0100 Subject: [PATCH] Pyodide build fixes --- CMakeLists.txt | 5 ++++- cmake/SuperBuild.cmake | 4 +++- python/__init__.py | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index af8ec308..4fb7c7dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,12 +87,15 @@ 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 Development.Module) - find_package(Python3 COMPONENTS Interpreter Development.Embed) + if(NOT EMSCRIPTEN) + find_package(Python3 COMPONENTS Interpreter Development.Embed) + endif() else() find_package(Python3 REQUIRED COMPONENTS Interpreter Development) endif() if(NOT CMAKE_CROSSCOMPILING) + find_package(Python3 REQUIRED COMPONENTS Interpreter) execute_process(COMMAND ${Python3_EXECUTABLE} -c "import os.path, sysconfig;print(os.path.relpath(sysconfig.get_path('platlib'), sysconfig.get_path('data')))" OUTPUT_VARIABLE PYTHON_PACKAGES_INSTALL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) file(TO_CMAKE_PATH ${PYTHON_PACKAGES_INSTALL_DIR} PYTHON_PACKAGES_INSTALL_DIR) endif(NOT CMAKE_CROSSCOMPILING) diff --git a/cmake/SuperBuild.cmake b/cmake/SuperBuild.cmake index 8be32bf8..58406f0b 100644 --- a/cmake/SuperBuild.cmake +++ b/cmake/SuperBuild.cmake @@ -184,7 +184,9 @@ if (USE_PYTHON) endif( PYBIND_INCLUDE_DIR ) if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.18) find_package(Python3 COMPONENTS Interpreter Development.Module) - find_package(Python3 COMPONENTS Interpreter Development.Embed) + if(NOT EMSCRIPTEN) + find_package(Python3 COMPONENTS Interpreter Development.Embed) + endif() else() find_package(Python3 REQUIRED COMPONENTS Interpreter Development) endif() diff --git a/python/__init__.py b/python/__init__.py index ce5e3529..4f71b212 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -41,6 +41,7 @@ if sys.platform.startswith('win'): del sys del os +from pyngcore import Timer from . import libngpy from netgen.libngpy._meshing import _Redraw @@ -48,7 +49,6 @@ from netgen.libngpy._meshing import _Redraw def Redraw(*args, **kwargs): return _Redraw(*args, **kwargs) -from pyngcore import Timer def TimeFunction(func, name=None): name = name or func.__qualname__ timer = Timer(name)