Skip to content

Commit 756bbaa

Browse files
committed
TST: test RPATH entries added via flags in $LDFLAGS environment variable
1 parent 8c4c8e6 commit 756bbaa

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_wheel.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,22 @@ def test_sharedlib_in_package_rpath(wheel_sharedlib_in_package, tmp_path):
199199
assert rpath == set()
200200

201201

202+
@pytest.mark.skipif(sys.platform in {'win32', 'cygwin'}, reason='requires RPATH support')
203+
def test_sharedlib_in_package_rpath_ldflags(package_sharedlib_in_package, tmp_path, monkeypatch):
204+
origin = '@loader_path' if sys.platform == 'darwin' else '$ORIGIN'
205+
extra_rpath = {f'{origin}/test-ldflags', '/usr/lib/test-ldflags'}
206+
ldflags = ' '.join(f'-Wl,-rpath,{p}' for p in extra_rpath)
207+
monkeypatch.setenv('LDFLAGS', ldflags)
208+
209+
filename = mesonpy.build_wheel(tmp_path)
210+
artifact = wheel.wheelfile.WheelFile(tmp_path / filename)
211+
artifact.extractall(tmp_path)
212+
213+
for path in f'_example{EXT_SUFFIX}', f'liblib{LIB_SUFFIX}', f'sub/libsublib{LIB_SUFFIX}':
214+
rpath = set(mesonpy._rpath._get_rpath(tmp_path / 'mypkg' / path))
215+
assert extra_rpath <= rpath
216+
217+
202218
def test_sharedlib_in_package(venv, wheel_sharedlib_in_package):
203219
venv.pip('install', wheel_sharedlib_in_package)
204220
output = venv.python('-c', 'import mypkg; print(mypkg.prodsum(2, 3, 4))')

0 commit comments

Comments
 (0)