Skip to content

Commit e1a38a6

Browse files
committed
TST: extend local lib test to verify Windows support
1 parent 900b5cf commit e1a38a6

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# SPDX-FileCopyrightText: 2025 The meson-python developers
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
import os
6+
import sys
7+
8+
9+
_path = os.path.join(os.path.dirname(__file__), '..', '.link_against_local_lib.mesonpy.libs')
10+
if os.name == 'nt':
11+
os.add_dll_directory(_path)
12+
elif sys.platform == 'cygwin':
13+
os.environ['PATH'] = os.pathsep.join((os.environ['PATH'], _path))
14+
del _path
15+
16+
17+
from ._example import example_sum # noqa: E402
18+
19+
20+
__all__ = ['example_sum']

tests/packages/link-against-local-lib/meson.build

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ project('link-against-local-lib', 'c', version: '1.0.0')
66

77
subdir('lib')
88

9-
py = import('python').find_installation()
9+
py = import('python').find_installation(pure: false)
10+
11+
py.install_sources(
12+
'__init__.py',
13+
subdir: 'example',
14+
)
1015

1116
py.extension_module(
12-
'example',
17+
'_example',
1318
'examplemod.c',
1419
link_with: example_lib,
1520
link_args: ['-Wl,-rpath,custom-rpath'],
1621
install: true,
22+
subdir: 'example',
1723
)

tests/packages/link-against-local-lib/pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
[build-system]
66
build-backend = 'mesonpy'
77
requires = ['meson-python']
8+
9+
[tool.meson-python]
10+
allow-windows-internal-shared-libs = true

tests/test_wheel.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ def test_contents(package_library, wheel_library):
172172
}
173173

174174

175-
@pytest.mark.skipif(sys.platform not in {'linux', 'darwin', 'sunos5'}, reason='Not supported on this platform')
176175
def test_local_lib(venv, wheel_link_against_local_lib):
177176
venv.pip('install', wheel_link_against_local_lib)
178177
output = venv.python('-c', 'import example; print(example.example_sum(1, 2))')
@@ -200,9 +199,9 @@ def test_rpath(wheel_link_against_local_lib, tmp_path):
200199
artifact.extractall(tmp_path)
201200

202201
origin = {'linux': '$ORIGIN', 'darwin': '@loader_path', 'sunos5': '$ORIGIN'}[sys.platform]
203-
expected = {f'{origin}/.link_against_local_lib.mesonpy.libs', 'custom-rpath',}
202+
expected = {f'{origin}/../.link_against_local_lib.mesonpy.libs', 'custom-rpath',}
204203

205-
rpath = set(mesonpy._rpath._get_rpath(tmp_path / f'example{EXT_SUFFIX}'))
204+
rpath = set(mesonpy._rpath._get_rpath(tmp_path / 'example' / f'_example{EXT_SUFFIX}'))
206205
# Verify that rpath is a superset of the expected one: linking to
207206
# the Python runtime may require additional rpath entries.
208207
assert rpath >= expected

0 commit comments

Comments
 (0)