-
Notifications
You must be signed in to change notification settings - Fork 533
ENH: Add _cmd_prefix class variable to CommandLine #2379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@satra If you want to have a look at this to make sure it's what you were thinking, that'd be great. |
in general this looks good. |
@satra Testing found what I think you were thinking of, which was a |
830e744
to
d0defe3
Compare
d0defe3
to
f8472df
Compare
nipype/interfaces/base/core.py
Outdated
@@ -987,14 +988,26 @@ def _run_interface(self, runtime, correct_return_codes=(0, )): | |||
|
|||
# which $cmd | |||
executable_name = self.cmd.split()[0] | |||
cmd_path = which(executable_name, env=runtime.environ) | |||
|
|||
prefix_parts = self._cmd_prefix.split() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah - so this is where spaces in the prefix would break this. also in the line above (for executable name), it assumes that self.cmd is not a full path with spaces.
perhaps this may help:
if os.path.isdir(self._cmd_prefix):
executable_name = self._cmd_prefix + self.cmd
elif os.path.isfile(self._cmd_prefix):
executable_name = self._cmd_prefix
else:
prefix = ''
for part in self._cmd_prefix.split():
prefix = prefix + part
if os.path.isfile(prefix):
executable_name = prefix
break
else:
raise ValueError('{} does not contain a valid path'.format(self._cmd_prefix))
cmd_path = which(executable_name, env=runtime.environ)
@satra I opted to go with |
cb5b2d9
to
2d3028c
Compare
This is ready, as far as I'm concerned. |
@satra This is the only thing left to review for 1.0. |
This PR adds a
_cmd_prefix
which is a string that is prepended (with no space) to the command. This will permit users to add installation-specific prefixes, whether they be installation directories that are not in the path or idiosyncratic names that have been chosen by a package manager.The idea is that users could do something like:
or
Fixes #1415.
cc @satra @TheChymera