Skip to content

Commit 31bfd31

Browse files
committed
ENH: do not add ninja to the build dependencies if $NINJA is set
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.
1 parent d491766 commit 31bfd31

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

mesonpy/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ def _env_ninja_command(*, version: str = _NINJA_REQUIRED_VERSION) -> Optional[st
11441144
Returns the path to ninja, or None if no ninja found.
11451145
"""
11461146
required_version = tuple(int(v) for v in version.split('.'))
1147-
env_ninja = os.environ.get('NINJA', None)
1147+
env_ninja = os.environ.get('NINJA')
11481148
ninja_candidates = [env_ninja] if env_ninja else ['ninja', 'ninja-build', 'samu']
11491149
for ninja in ninja_candidates:
11501150
ninja_path = shutil.which(ninja)
@@ -1179,7 +1179,9 @@ def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
11791179
def get_requires_for_build_sdist(
11801180
config_settings: Optional[Dict[str, str]] = None,
11811181
) -> List[str]:
1182-
return [_depstr.ninja] if _env_ninja_command() is None else []
1182+
if os.environ.get('NINJA') is None and _env_ninja_command() is None:
1183+
return [_depstr.ninja]
1184+
return []
11831185

11841186

11851187
@_pyproject_hook
@@ -1200,7 +1202,7 @@ def get_requires_for_build_wheel(
12001202
) -> List[str]:
12011203
dependencies = []
12021204

1203-
if _env_ninja_command() is None:
1205+
if os.environ.get('NINJA') is None and _env_ninja_command() is None:
12041206
dependencies.append(_depstr.ninja)
12051207

12061208
if sys.platform.startswith('linux'):

0 commit comments

Comments
 (0)