Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/packages/sharedlib-chain/chainhead/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2026 The meson-python developers
#
# SPDX-License-Identifier: MIT
7 changes: 7 additions & 0 deletions tests/packages/sharedlib-chain/chainhead/leaf/leaf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-FileCopyrightText: 2026 The meson-python developers
//
// SPDX-License-Identifier: MIT

int leaf(void) {
return 7;
}
9 changes: 9 additions & 0 deletions tests/packages/sharedlib-chain/chainhead/leaf/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SPDX-FileCopyrightText: 2026 The meson-python developers
#
# SPDX-License-Identifier: MIT

leaf = shared_library(
'leaf', 'leaf.c',
install: true,
install_dir: py.get_install_dir() / 'chainhead/lib',
)
16 changes: 16 additions & 0 deletions tests/packages/sharedlib-chain/chainhead/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# SPDX-FileCopyrightText: 2026 The meson-python developers
#
# SPDX-License-Identifier: MIT

subdir('leaf')
subdir('middle')

py.install_sources('__init__.py', subdir: 'chainhead')

py.extension_module(
'chain', 'module.c',
link_with: middle,
install: true,
subdir: 'chainhead',
install_rpath: '$ORIGIN/lib',
)
10 changes: 10 additions & 0 deletions tests/packages/sharedlib-chain/chainhead/middle/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-FileCopyrightText: 2026 The meson-python developers
#
# SPDX-License-Identifier: MIT

middle = shared_library(
'middle', 'middle.c',
link_with: leaf,
install: true,
install_dir: py.get_install_dir() / 'chainhead/lib',
)
9 changes: 9 additions & 0 deletions tests/packages/sharedlib-chain/chainhead/middle/middle.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-FileCopyrightText: 2026 The meson-python developers
//
// SPDX-License-Identifier: MIT

extern int leaf(void);

int middle(void) {
return leaf() + 1;
}
24 changes: 24 additions & 0 deletions tests/packages/sharedlib-chain/chainhead/module.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-FileCopyrightText: 2026 The meson-python developers
//
// SPDX-License-Identifier: MIT

#include <Python.h>

extern int middle(void);

static PyObject *value(PyObject *self, PyObject *args) {
return PyLong_FromLong(middle());
}

static PyMethodDef methods[] = {
{"value", value, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL},
};

static struct PyModuleDef module = {
PyModuleDef_HEAD_INIT, "chain", NULL, -1, methods,
};

PyMODINIT_FUNC PyInit_chain(void) {
return PyModule_Create(&module);
}
14 changes: 14 additions & 0 deletions tests/packages/sharedlib-chain/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-FileCopyrightText: 2026 The meson-python developers
#
# SPDX-License-Identifier: MIT

project('sharedlib-chain', 'c', version: '1.0.0')

py = import('python').find_installation(pure: false)

# Request RPATH rather than RUNPATH when supported by the linker.
if meson.get_compiler('c').has_link_argument('-Wl,--disable-new-dtags')
add_project_link_arguments('-Wl,--disable-new-dtags', language: 'c')
endif

subdir('chainhead')
7 changes: 7 additions & 0 deletions tests/packages/sharedlib-chain/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: 2026 The meson-python developers
#
# SPDX-License-Identifier: MIT

[build-system]
build-backend = 'mesonpy'
requires = ['meson-python']
17 changes: 17 additions & 0 deletions tests/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,23 @@ def test_rpath_install_precedence(venv, wheel_same_name_sharedlibs, tmp_path):
assert int(output) == 42


@pytest.mark.skipif(MESON_VERSION < (1, 6, 0), reason='meson too old')
@pytest.mark.skipif(sys.platform in {'win32', 'cygwin'}, reason='requires RPATH support')
@pytest.mark.filterwarnings('ignore:translated "install_rpath" argument for ')
def test_rpath_transitive_lookup(venv, wheel_sharedlib_chain, tmp_path):
artifact = wheel.wheelfile.WheelFile(wheel_sharedlib_chain)
artifact.extractall(tmp_path)

origin = '@loader_path' if sys.platform == 'darwin' else '$ORIGIN'
rpath = mesonpy._rpath.get_rpath(tmp_path / 'chainhead' / f'chain{EXT_SUFFIX}')
assert f'{origin}/lib' in rpath

venv.pip('install', wheel_sharedlib_chain)
# RUNPATH cannot supply the extension's search path to its indirect dependency on glibc.
output = venv.python('-c', 'from chainhead import chain; print(chain.value())')
assert int(output) == 8


@pytest.mark.skipif(sys.platform in {'win32', 'cygwin'}, reason='requires executable bit support')
def test_executable_bit(wheel_executable_bit):
artifact = wheel.wheelfile.WheelFile(wheel_executable_bit)
Expand Down
Loading