diff --git a/Applications/Python/OpenGeoSys/__init__.py b/Applications/Python/OpenGeoSys/__init__.py index 120592366f06d61dbaba07ce46e3ec3562b01fb8..d4b704a8f3ec10d5244177ad1f225b1c07cac5ec 100644 --- a/Applications/Python/OpenGeoSys/__init__.py +++ b/Applications/Python/OpenGeoSys/__init__.py @@ -1,17 +1,8 @@ import os +import platform import subprocess import sys -try: - from .lib64._cli import * -except ImportError: - try: - from .lib._cli import * - except ImportError: - print("ERROR: could not import OpenGeoSys Python module!") - -OGS_BIN_DIR = os.path.join(os.path.join(os.path.dirname(__file__), "bin")) - binaries_list = [ "addDataToRaster", "AddElementQuality", @@ -75,11 +66,26 @@ binaries_list = [ "Vtu2Grid", ] +if "PEP517_BUILD_BACKEND" not in os.environ: + if platform.system() == "Windows": + os.add_dll_directory(os.path.join(os.path.dirname(__file__), "bin")) + from .lib._cli import * + else: + try: + from .lib64._cli import * + except ImportError: + try: + from .lib._cli import * + except ImportError: + print("ERROR: could not import OpenGeoSys Python module!") + + OGS_BIN_DIR = os.path.join(os.path.join(os.path.dirname(__file__), "bin")) + -def _program(name, args): - return subprocess.call([os.path.join(OGS_BIN_DIR, name)] + args) + def _program(name, args): + return subprocess.call([os.path.join(OGS_BIN_DIR, name)] + args) -FUNC_TEMPLATE = """def {0}(): raise SystemExit(_program("{0}", sys.argv[1:]))""" -for f in binaries_list: - exec(FUNC_TEMPLATE.format(f)) + FUNC_TEMPLATE = """def {0}(): raise SystemExit(_program("{0}", sys.argv[1:]))""" + for f in binaries_list: + exec(FUNC_TEMPLATE.format(f)) diff --git a/CMakePresets.json b/CMakePresets.json index 5eabcc4085b15ed9c72ade76d6e07a7c8fb35f9f..500fcc838502512b03c6266dee746240162bd3f4 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -202,6 +202,23 @@ "OGS_USE_PIP": "OFF", "OGS_USE_MFRONT": "ON", "BUILD_SHARED_LIBS": "ON" + }, + "condition": { + "type": "notEquals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + } + }, + { + "name": "wheel-win", + "inherits": "wheel", + "cacheVariables": { + "OGS_USE_MFRONT": "OFF" + }, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" } } ], @@ -290,6 +307,10 @@ { "name": "wheel", "configurePreset": "wheel" + }, + { + "name": "wheel-win", + "configurePreset": "wheel-win" } ], "testPresets": [ diff --git a/pyproject.toml b/pyproject.toml index 69021cbd4a17c56ed81979db02a499a199195c70..768f363e6815ac910f62d95b8748f7e1308c377d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,10 @@ [build-system] requires = [ "setuptools>=42", - "scikit-build>=0.15.0", + "scikit-build @ git+https://github.com/bilke/scikit-build/@disable-cmake-install-check#egg=scikit-build ; platform_system == 'Windows'", + "scikit-build>=0.15.0 ; platform_system != 'Windows'", "cmake>=3.22", - "ninja; platform_system!='Windows'", + "ninja ; platform_system != 'Windows'", ] build-backend = "setuptools.build_meta" @@ -17,6 +18,7 @@ build = "cp3*" skip = "*musllinux*" test-extras = "test" test-command = "pytest {project}/Tests/Python" +# test-command = "" build-verbosity = "1" [tool.cibuildwheel.linux] @@ -26,3 +28,6 @@ environment-pass = ["OGS_VERSION"] [tool.cibuildwheel.macos] skip = ["cp36-*", "cp37-*", "cp38-*x86_64"] + +[tool.cibuildwheel.windows] +skip = ["cp36-*", "cp37-*"] diff --git a/setup.py b/setup.py index 2cb3ad792f569497951b99ba0a00fdddf8033c7e..e5a8c44f2da9e4282ce36657ce2ba110e7eae600 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ def get_version(): git_version = os.environ["OGS_VERSION"] else: git_version = subprocess.run( - ["git describe --tags"], + ["git", "describe", "--tags"], capture_output=True, text=True, shell=True, @@ -32,13 +32,18 @@ def get_version(): return git_version -sys.path.append("Applications/Python") +sys.path.append(os.path.join("Applications", "Python")) from OpenGeoSys import binaries_list console_scripts = [] for b in binaries_list: console_scripts.append(f"{b}=OpenGeoSys:{b}") +import platform +cmake_preset = "wheel" +if platform.system() == "Windows": + cmake_preset += "-win" + setup( name="OpenGeoSys", version=get_version(), @@ -49,7 +54,7 @@ setup( package_dir={"": "Applications/Python"}, cmake_install_dir="Applications/Python/OpenGeoSys", extras_require={"test": ["pytest"]}, - cmake_args=["--preset wheel", "-B ."], + cmake_args=[f"--preset {cmake_preset}", "-B ."], python_requires=">=3.6", entry_points={"console_scripts": console_scripts}, )