Skip to content

Commit 124a57f

Browse files
committed
TST: test RPATH entries added via flags in $LDFLAGS environment variable
1 parent 530bb2f commit 124a57f

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
@@ -198,6 +198,22 @@ def test_sharedlib_in_package_rpath(wheel_sharedlib_in_package, tmp_path):
198198
assert rpath == set()
199199

200200

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

0 commit comments

Comments
 (0)