Skip to content

Commit fde50f8

Browse files
rgommersdnicolodi
authored andcommitted
TST: check installation RPATH precedence with competing shared libraries
1 parent 3274183 commit fde50f8

11 files changed

Lines changed: 114 additions & 0 deletions

File tree

‎tests/conftest.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ def __init__(self, source_dir, build_dir, meson_args=None, editable_verbose=None
223223
# in the wild thus we should make sure it keeps working.
224224
'link-against-local-lib',
225225
'sharedlib-in-package',
226+
'same-name-sharedlibs',
226227

227228
}:
228229
if meson_args is None:
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SPDX-FileCopyrightText: 2026 The meson-python developers
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
project('same-name-sharedlibs', 'c', version: '1.0.0')
6+
7+
py = import('python').find_installation(pure: false)
8+
9+
subdir('same_name')
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SPDX-FileCopyrightText: 2026 The meson-python developers
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
[build-system]
6+
build-backend = 'mesonpy'
7+
requires = ['meson-python']
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-FileCopyrightText: 2026 The meson-python developers
2+
#
3+
# SPDX-License-Identifier: MIT
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// SPDX-FileCopyrightText: 2026 The meson-python developers
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
int choice(void) {
6+
return 7;
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SPDX-FileCopyrightText: 2026 The meson-python developers
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
shared_library(
6+
'choice', 'choice.c',
7+
install: true,
8+
install_dir: py.get_install_dir() / 'same_name/competing',
9+
)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# SPDX-FileCopyrightText: 2026 The meson-python developers
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
subdir('competing')
6+
subdir('private')
7+
8+
py.install_sources('__init__.py', subdir: 'same_name')
9+
10+
origin = build_machine.system() == 'darwin' ? '@loader_path' : '$ORIGIN'
11+
12+
# Simulate an external library whose runtime path is supplied through linker
13+
# flags (for example, -Wl,-rpath,... in LDFLAGS). Keep that library inside this
14+
# fixture to make the test self-contained. The requested private installation
15+
# path must take precedence over this preserved competing path.
16+
py.extension_module(
17+
'choice', 'module.c',
18+
link_with: private,
19+
link_args: f'-Wl,-rpath,@origin@/competing',
20+
install: true,
21+
subdir: 'same_name',
22+
install_rpath: '$ORIGIN/private',
23+
)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// SPDX-FileCopyrightText: 2026 The meson-python developers
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
#include <Python.h>
6+
7+
extern int choice(void);
8+
9+
static PyObject *value(PyObject *self, PyObject *args) {
10+
return PyLong_FromLong(choice());
11+
}
12+
13+
static PyMethodDef methods[] = {
14+
{"value", value, METH_NOARGS, NULL},
15+
{NULL, NULL, 0, NULL},
16+
};
17+
18+
static struct PyModuleDef module = {
19+
PyModuleDef_HEAD_INIT, "choice", NULL, -1, methods,
20+
};
21+
22+
PyMODINIT_FUNC PyInit_choice(void) {
23+
return PyModule_Create(&module);
24+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// SPDX-FileCopyrightText: 2026 The meson-python developers
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
int choice(void) {
6+
return 42;
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SPDX-FileCopyrightText: 2026 The meson-python developers
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
private = shared_library(
6+
'choice', 'choice.c',
7+
install: true,
8+
install_dir: py.get_install_dir() / 'same_name/private',
9+
)

0 commit comments

Comments
 (0)