From dd90ed8d2da4653ace2f5a9a63079cfec6e5dc01 Mon Sep 17 00:00:00 2001 From: Christopher Albert Date: Fri, 12 Dec 2025 18:58:30 +0100 Subject: [PATCH] Fix pip install metadata and pysimple backend deps --- pyproject.toml | 14 +++++--------- python/pysimple/__init__.py | 9 +++++++++ python/pysimple/_backend.py | 9 +++++++++ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index aa572f45..244434fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,22 +1,18 @@ [build-system] -requires = ["scikit-build-core", "numpy", "f90wrap==0.2.16"] +requires = ["scikit-build-core", "numpy", "f90wrap"] build-backend = "scikit_build_core.build" [project] name = "pysimple" version = "1.2.0" -dependencies = ["numpy"] +dependencies = ["numpy", "f90wrap"] classifiers = [ "License :: OSI Approved :: MIT License", ] [tool.scikit-build] -build-dir = "build" build.verbose = true -cmake.define.CMAKE_CACHE_DIR = "build" +build-dir = "_skbuild" wheel.packages = ["python/pysimple"] -wheel.install-dir = "pysimple" -wheel.exclude = [] - -[project.package-data] -pysimple = ["data/*.dat"] +wheel.exclude = ["**/__pycache__/**", "**/*.pyc"] +sdist.include = ["python/pysimple/data/*.dat"] diff --git a/python/pysimple/__init__.py b/python/pysimple/__init__.py index a2de0265..52868164 100644 --- a/python/pysimple/__init__.py +++ b/python/pysimple/__init__.py @@ -22,6 +22,15 @@ try: import simple_backend as _backend except ImportError as exc: + if getattr(exc, "name", None) == "f90wrap": + raise ImportError( + "f90wrap is required to import SIMPLE Python bindings. Install f90wrap." + ) from exc + if getattr(exc, "name", None) == "_simple_backend": + raise ImportError( + "Fortran extension _simple_backend failed to import. " + "Rebuild SIMPLE with Python bindings enabled." + ) from exc raise ImportError( "simple_backend module not found. Build SIMPLE with Python bindings enabled." ) from exc diff --git a/python/pysimple/_backend.py b/python/pysimple/_backend.py index a488d4a8..92031651 100644 --- a/python/pysimple/_backend.py +++ b/python/pysimple/_backend.py @@ -32,6 +32,15 @@ def _load_backend() -> ModuleType: try: _BACKEND = import_module("simple_backend") except ImportError as exc: # pragma: no cover - exercised in test skips + if getattr(exc, "name", None) == "f90wrap": + raise ImportError( + "f90wrap is required to import SIMPLE Python bindings. Install f90wrap." + ) from exc + if getattr(exc, "name", None) == "_simple_backend": + raise ImportError( + "Fortran extension _simple_backend failed to import. " + "Rebuild SIMPLE with Python bindings enabled." + ) from exc raise ImportError( "simple_backend module not found. Build SIMPLE with Python bindings enabled." ) from exc