Skip to content

Commit

Permalink
ENH: do not add ninja to the build dependencies if $NINJA is set
Browse files Browse the repository at this point in the history
Do not add the ninja Python package to the wheel or sdist build
dependencies if the user requested to use a particular ninja
executable via the $NINJA environment variable.

Fixes #316.
  • Loading branch information
dnicolodi committed Mar 1, 2023
1 parent d491766 commit 31bfd31
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions mesonpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ def _env_ninja_command(*, version: str = _NINJA_REQUIRED_VERSION) -> Optional[st
Returns the path to ninja, or None if no ninja found.
"""
required_version = tuple(int(v) for v in version.split('.'))
env_ninja = os.environ.get('NINJA', None)
env_ninja = os.environ.get('NINJA')
ninja_candidates = [env_ninja] if env_ninja else ['ninja', 'ninja-build', 'samu']
for ninja in ninja_candidates:
ninja_path = shutil.which(ninja)
Expand Down Expand Up @@ -1179,7 +1179,9 @@ def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
def get_requires_for_build_sdist(
config_settings: Optional[Dict[str, str]] = None,
) -> List[str]:
return [_depstr.ninja] if _env_ninja_command() is None else []
if os.environ.get('NINJA') is None and _env_ninja_command() is None:
return [_depstr.ninja]
return []


@_pyproject_hook
Expand All @@ -1200,7 +1202,7 @@ def get_requires_for_build_wheel(
) -> List[str]:
dependencies = []

if _env_ninja_command() is None:
if os.environ.get('NINJA') is None and _env_ninja_command() is None:
dependencies.append(_depstr.ninja)

if sys.platform.startswith('linux'):
Expand Down

0 comments on commit 31bfd31

Please sign in to comment.