Skip to content

Commit

Permalink
don't ask for patchelf if ninja is available and the project is pure
Browse files Browse the repository at this point in the history
Signed-off-by: Filipe Laíns <[email protected]>
  • Loading branch information
FFY00 committed Nov 18, 2022
1 parent 47f3ba6 commit 9d47743
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
10 changes: 9 additions & 1 deletion mesonpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,15 @@ def get_requires_for_build_wheel(
# we may need patchelf
if not shutil.which('patchelf'):
# patchelf not already accessible on the system
dependencies.append(_depstr.patchelf)
if _env_ninja_command() is not None:
# we have ninja available, so we can run Meson and check if the project needs patchelf
with _project(config_settings) as project:
if not project.is_pure:
dependencies.append(_depstr.patchelf)
else:
# we can't check if the project needs patchelf, so always add it
# XXX: wait for https://github.com/mesonbuild/meson/pull/10779
dependencies.append(_depstr.patchelf)

This comment has been minimized.

Copy link
@dnicolodi

dnicolodi Nov 18, 2022

Member

The check for patchelf was conditional to be running on Linux before. I think we should preserve that.

This comment has been minimized.

Copy link
@FFY00

FFY00 Nov 18, 2022

Author Member

That's already up there 😛

This comment has been minimized.

Copy link
@dnicolodi

dnicolodi Nov 18, 2022

Member

Ah, sorry, it was outside the context of the change shown by GitHub.


return dependencies

Expand Down
13 changes: 10 additions & 3 deletions tests/test_pep517.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,17 @@ def run(cmd: List[str], *args: object, **kwargs: object) -> subprocess.Completed
monkeypatch.setattr(subprocess, 'run', run)

expected = {mesonpy._depstr.wheel}
if system_patchelf is None and sys.platform.startswith('linux'):
expected |= {mesonpy._depstr.patchelf}
if ninja is None or [int(x) for x in ninja.split('.')] < [1, 8, 2]:

ninja_available = ninja is not None and [int(x) for x in ninja.split('.')] >= [1, 8, 2]

if not ninja_available:
expected |= {mesonpy._depstr.ninja}

if (
system_patchelf is None and sys.platform.startswith('linux')
and (not ninja_available or (ninja_available and package != 'pure'))
):
expected |= {mesonpy._depstr.patchelf}

with cd_package(package):
assert set(mesonpy.get_requires_for_build_wheel()) == expected

0 comments on commit 9d47743

Please sign in to comment.