Merge pull request #6935 from radarhere/path

Do not raise an error if os.environ does not contain PATH
This commit is contained in:
Andrew Murray 2023-03-13 00:19:38 +11:00 committed by GitHub
commit 5b3d39c116
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -242,7 +242,9 @@ def _find_include_dir(self, dirname, include):
return subdir return subdir
def _cmd_exists(cmd): def _cmd_exists(cmd: str) -> bool:
if "PATH" not in os.environ:
return False
return any( return any(
os.access(os.path.join(path, cmd), os.X_OK) os.access(os.path.join(path, cmd), os.X_OK)
for path in os.environ["PATH"].split(os.pathsep) for path in os.environ["PATH"].split(os.pathsep)