Skip to content

Commit 55b8cca

Browse files
committed
mesonpy: only pull patchelf if needed
Also move to the patchelf package instead of patchelf-wrapper as the it's functionality is no longer needed and patchelf is better maintained. Fixed #52 Signed-off-by: Filipe Laíns <[email protected]>
1 parent 86313a4 commit 55b8cca

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

mesonpy/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
class _depstr:
5555
ninja = 'ninja >= 1.10.0'
56-
patchelf_wrapper = 'patchelf-wrapper'
56+
patchelf = 'patchelf >= 0.11.0'
5757
wheel = 'wheel >= 0.36.0' # noqa: F811
5858

5959

@@ -778,7 +778,10 @@ def get_requires_for_build_wheel(
778778
dependencies = [_depstr.wheel, _depstr.ninja]
779779
with _project(config_settings) as project:
780780
if not project.is_pure and platform.system() == 'Linux':
781-
dependencies.append(_depstr.patchelf_wrapper)
781+
# we may need patchelf
782+
if not shutil.which('patchelf'): # XXX: This is slightly dangerous.
783+
# patchelf not already acessible on the system
784+
dependencies.append(_depstr.patchelf)
782785
return dependencies
783786

784787

tests/test_pep517.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,26 @@
1010

1111

1212
if platform.system() == 'Linux':
13-
VENDORING_DEPS = {mesonpy._depstr.patchelf_wrapper}
13+
VENDORING_DEPS = {mesonpy._depstr.patchelf}
1414
else:
1515
VENDORING_DEPS = set()
1616

1717

1818
@pytest.mark.parametrize(
19-
('package', 'expected'),
19+
('package', 'system_patchelf', 'expected'),
2020
[
21-
('pure', set()), # pure and no PEP 621
22-
('library', VENDORING_DEPS), # not pure and not PEP 621
21+
('pure', True, set()), # pure and system patchelf
22+
('library', True, set()), # not pure and system patchelf
23+
('pure', False, set()), # pure and no system patchelf
24+
('library', False, VENDORING_DEPS), # not pure and no system patchelf
2325
]
2426
)
25-
def test_get_requires_for_build_wheel(package, expected):
27+
def test_get_requires_for_build_wheel(mocker, package, expected, system_patchelf):
28+
mock = mocker.patch('shutil.which', return_value=system_patchelf)
29+
30+
if mock.called: # sanity check for the future if we add another usage
31+
mock.assert_called_once_with('patchelf')
32+
2633
with cd_package(package):
2734
assert set(mesonpy.get_requires_for_build_wheel()) == expected | {
2835
mesonpy._depstr.wheel,

0 commit comments

Comments
 (0)