Skip to content

Commit

Permalink
Avoid assuming there’s a PATH variable defined
Browse files Browse the repository at this point in the history
This is helpful in restricted environments, and this is the only place where `mx --version` breaks at the moment.

Signed-off-by: Stefan Marr <[email protected]>
  • Loading branch information
smarr committed May 3, 2024
1 parent 6caac1b commit 9fcffdd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/mx/_impl/mx_proftool.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,9 @@ def demangled_name(self, short_class_names: bool = False):


def _which(executable):
if 'PATH' not in os.environ:
return None

for path in os.environ['PATH'].split(os.pathsep):
f = os.path.join(path.strip('"'), executable)
if os.path.isfile(f) and os.access(f, os.X_OK):
Expand Down

0 comments on commit 9fcffdd

Please sign in to comment.