Skip to content

Commit 81d56af

Browse files
committed
ENH: support shared libraries inside packages
This drops the use of staged installs with `--destdir` in favor of using `--prefix` for the install location. The problem is that RPATHs in extension modules end up pointing to what Meson thinks is the final install location (i.e., inside the prefix) rather than to the staging directory. `--destdir` seems meant for packaging, as an actual staging area, while for `spin` the final install directory is `build-install` (by default), there is no intent to later put this package into `/usr` or `C:\`. Hence using `--prefix` seems like the correct thing to do. The one test change here is to a test that was incorrect. `meson setup --prefix` expects an absolute path, and `/foobar` isn't a path that exists or can be created. Addresses the issue discussed in PR 238 - the `spin build` behavior before this change cannot be made to work for SciPy, because the internal shared library in `scipy.special` keeps breaking. It should also address the problem discussed in issue spin#176.
1 parent 794cabf commit 81d56af

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

spin/cmds/meson.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,6 @@ def _check_coverage_tool_installation(coverage_type: GcovReportFormat, build_dir
231231
)
232232

233233

234-
if sys.platform.startswith("win"):
235-
DEFAULT_PREFIX = "C:/"
236-
else:
237-
DEFAULT_PREFIX = "/usr"
238-
239234
build_dir_option = click.option(
240235
"-C",
241236
"--build-dir",
@@ -266,10 +261,10 @@ def _check_coverage_tool_installation(coverage_type: GcovReportFormat, build_dir
266261
)
267262
@click.option(
268263
"--prefix",
269-
help="The build prefix, passed directly to meson.",
264+
help="The build prefix as an absolute path, passed directly to meson.",
270265
type=str,
271266
metavar="PREFIX",
272-
default=DEFAULT_PREFIX,
267+
default='',
273268
)
274269
@click.argument("meson_args", nargs=-1)
275270
@build_dir_option
@@ -320,6 +315,9 @@ def build(
320315
install_dir = _get_install_dir(build_dir)
321316
abs_install_dir = os.path.abspath(install_dir)
322317

318+
if not prefix:
319+
prefix = abs_install_dir
320+
323321
cfg = get_config()
324322
distname = cfg.get("project.name", None)
325323
if distname and _is_editable_install_of_same_source(distname):
@@ -385,10 +383,6 @@ def build(
385383
"--only-changed",
386384
"-C",
387385
build_dir,
388-
"--destdir",
389-
install_dir
390-
if os.path.isabs(install_dir)
391-
else os.path.relpath(abs_install_dir, abs_build_dir),
392386
]
393387
+ list(meson_install_args),
394388
output=(not quiet) and verbose,

spin/tests/test_build_cmds.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ def test_debug_builds(example_pkg):
3838

3939
def test_prefix_builds(example_pkg):
4040
"""does spin build --prefix create a build-install directory with the correct structure?"""
41-
spin("build", "--prefix=/foobar/")
41+
prefix = Path('.').resolve() / 'build-install' / 'foobar'
42+
spin("build", f"--prefix={prefix}")
4243
assert (Path("build-install") / Path("foobar")).exists()
4344

4445

0 commit comments

Comments
 (0)