From 79be9af1a91f12de25fa69a0461bad05c95d7973 Mon Sep 17 00:00:00 2001 From: sjoudaki Date: Tue, 24 Mar 2026 23:33:48 +0100 Subject: [PATCH 1/2] Fix pyproject.toml to pin build dependencies for pip isolated builds --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 79fe21f..7bda715 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,12 @@ [build-system] requires = [ - "setuptools>=42", + "setuptools>=42,<65", "wheel", - "f90wrap>=0.2.6", + "numpy<1.26", + "f90wrap<0.3", "setuptools_scm[toml]>=3.4" ] build-backend = "setuptools.build_meta" [tool.setuptools_scm] -write_to = "f90wrap_pyhmcode/pyhmcode/version.py" \ No newline at end of file From 9eb8cf88a96a918aa7a4bb2f7d84c23fb0ab74da Mon Sep 17 00:00:00 2001 From: sjoudaki Date: Wed, 25 Mar 2026 04:21:33 +0100 Subject: [PATCH 2/2] Fix pyhmcode packaging and mac-os import in conda envs --- pyproject.toml | 1 + setup.py | 31 +++++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7bda715..3db7955 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,3 +10,4 @@ requires = [ build-backend = "setuptools.build_meta" [tool.setuptools_scm] +write_to = "f90wrap_pyhmcode/pyhmcode/version.py" diff --git a/setup.py b/setup.py index b02a73c..d3baf43 100644 --- a/setup.py +++ b/setup.py @@ -20,10 +20,32 @@ long_description = f.read() def compile_library(env): + env = dict(env) subprocess.check_call(["make", "f90wrap"], env=env, cwd=HERE) - LIB = glob.glob("f90wrap_pyhmcode/_pyhmcode*.so") - shutil.copy(LIB[0], "f90wrap_pyhmcode/pyhmcode/",) + lib = glob.glob(os.path.join(HERE, "f90wrap_pyhmcode", "_pyhmcode*.so"))[0] + + if sys.platform == "darwin": + try: + out = subprocess.check_output(["otool", "-l", lib], text=True) + lines = out.splitlines() + rpaths = [] + for i, line in enumerate(lines): + if line.strip() == "cmd LC_RPATH" and i + 2 < len(lines): + path_line = lines[i + 2].strip() + if path_line.startswith("path "): + rpaths.append(path_line.split("path ", 1)[1].rsplit(" (offset", 1)[0]) + + seen = set() + for rp in rpaths: + if rp in seen: + subprocess.check_call(["install_name_tool", "-delete_rpath", rp, lib]) + else: + seen.add(rp) + except Exception as e: + print(f"Warning: failed to deduplicate rpaths for {lib}: {e}") + + shutil.copy(lib, "f90wrap_pyhmcode/pyhmcode/") def copy_utils(): # There's probably some setuptools magic that could do this cleaner @@ -99,10 +121,11 @@ def run(self): "Operating System :: OS Independent",], package_dir= {"": "f90wrap_pyhmcode/"}, packages= ["pyhmcode"], - package_data= {"pyhmcode": ["_pyhmcode*.so"]}, + package_data= {"pyhmcode": ["_pyhmcode*.so", "version.py"]}, + include_package_data=True, # ext_modules = [Extension('pyhmcode._pyhmcode', [])], install_requires= ["numpy", - "f90wrap"], + "f90wrap<0.3"], cmdclass= {"install": install, "develop": develop, "build_py": build,