Skip to content

Commit b8c9a6c

Browse files
committed
RF: Pass environment paths to shutil.which()
filemanip.which() took an env dict, used just for an alternative PATH.
1 parent 24bfac5 commit b8c9a6c

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

nipype/interfaces/ants/segmentation.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,9 @@ def _run_interface(self, runtime, correct_return_codes=(0,)):
996996
if ants_path is None:
997997
# Check for antsRegistration, which is under bin/ (the $ANTSPATH) instead of
998998
# checking for antsBrainExtraction.sh which is under script/
999-
cmd_path = shutil.which("antsRegistration", env=runtime.environ)
999+
cmd_path = shutil.which(
1000+
"antsRegistration", path=runtime.environ.get("PATH")
1001+
)
10001002
if not cmd_path:
10011003
raise RuntimeError(
10021004
'The environment variable $ANTSPATH is not defined in host "%s", '

nipype/interfaces/base/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ def version_from_command(self, flag="-v", cmd=None):
703703
cmd = self.cmd.split()[0]
704704

705705
env = dict(os.environ)
706-
if shutil.which(cmd, env=env):
706+
if shutil.which(cmd):
707707
out_environ = self._get_environ()
708708
env.update(out_environ)
709709
proc = sp.Popen(
@@ -748,7 +748,7 @@ def _run_interface(self, runtime, correct_return_codes=(0,)):
748748

749749
# which $cmd
750750
executable_name = shlex.split(self._cmd_prefix + self.cmd)[0]
751-
cmd_path = shutil.which(executable_name, env=runtime.environ)
751+
cmd_path = shutil.which(executable_name, path=runtime.environ.get("PATH"))
752752

753753
if cmd_path is None:
754754
raise IOError(

0 commit comments

Comments
 (0)