Skip to content

Commit 3c8e208

Browse files
BLD: Exclude .so in meson build (to avoid conflicts in local testing); adjust absolute rpaths in nox environment setup
1 parent 647cda9 commit 3c8e208

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

meson.build

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fortranobject_c = f2py_inc_dir / 'fortranobject.c'
4848
# ---- HDF5 dependencies
4949
hdf5_c = dependency('hdf5', required : true)
5050
hdf5f = declare_dependency(link_args : ['-lhdf5_fortran'], dependencies : [hdf5_c])
51-
hdf5f_hl = declare_dependency(link_args : ['-lhdf5hl_fortran'], dependencies : [hdf5_c])
51+
hdf5f_hl = declare_dependency(link_args : ['-lhdf5_hl_fortran'], dependencies : [hdf5_c])
5252

5353
# Optional: OpenMP
5454
# omp_dep = dependency('openmp', required : false)
@@ -110,9 +110,19 @@ configure_file(
110110
install_subdir(
111111
'mapflpy',
112112
install_dir : py.get_install_dir(),
113+
exclude_directories : ['fortran'],
113114
exclude_files: [
114115
'_version.py.in',
115116
'__pycache__',
116117
'*.pyc',
117118
]
118119
)
120+
121+
# Install mapflpy/fortran/__init__.py separately, so that the install_subdir
122+
# above can exclude the entire fortran/ directory. Without this exclusion,
123+
# any compiled .so left in the source tree (e.g. from a dev install) would
124+
# be bundled into every wheel produced by "python -m build".
125+
install_data(
126+
'mapflpy/fortran/__init__.py',
127+
install_dir : py.get_install_dir() / 'mapflpy' / 'fortran',
128+
)

noxfile.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,17 @@ def _build_env(session: nox.Session) -> Path:
7070
*pyproject["tool"][PROJECT_NAME].get("conda", []),
7171
channel="conda-forge"
7272
)
73-
session.env.update(_darwin_sdk_env())
73+
env_dir = Path(session.env_dir).resolve()
74+
lib_dir = str(env_dir / "lib")
75+
# Override CONDA_PREFIX so conda-forge gfortran's spec file uses this env's
76+
# lib dir for its implicit library search paths, not the active outer env.
77+
env = {"CONDA_PREFIX": str(env_dir)}
78+
env.update(_darwin_sdk_env())
79+
if platform.system() == "Darwin":
80+
# Also pass an explicit rpath so delocate-wheel can bundle deps even
81+
# when meson would otherwise embed a @loader_path-relative path.
82+
env["LDFLAGS"] = (env.get("LDFLAGS", "") + f" -Wl,-rpath,{lib_dir}").strip()
83+
session.env.update(env)
7484

7585

7686
def _dist_env(session: nox.Session) -> Path:

0 commit comments

Comments
 (0)