diff options
-rwxr-xr-x | setuptools/command/easy_install.py | 9 | ||||
-rw-r--r-- | setuptools/tests/test_easy_install.py | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 54a3bc3a..340b1fac 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1882,15 +1882,16 @@ class CommandSpec(list): @classmethod def from_environment(cls): - return cls.from_string(cls._sys_executable()) + return cls.from_string('"' + cls._sys_executable() + '"') @classmethod def from_string(cls, string): """ - Construct a command spec from a simple string, assumed to represent - the full name to an executable. + Construct a command spec from a simple string representing a command + line parseable by shlex.split. """ - return JythonCommandSpec.from_string(string) or cls([string]) + items = shlex.split(string) + return JythonCommandSpec.from_string(string) or cls(items) def install_options(self, script_text): self.options = shlex.split(self._extract_options(script_text)) diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index e1f06788..a3d5b0a9 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -505,3 +505,12 @@ class TestCommandSpec: cmd = CommandSpec.from_environment() assert len(cmd) == 1 assert cmd.as_header().startswith('#!"') + + def test_from_simple_string_uses_shlex(self): + """ + In order to support `executable = /usr/bin/env my-python`, make sure + from_param invokes shlex on that input. + """ + cmd = CommandSpec.from_param('/usr/bin/env my-python') + assert len(cmd) == 2 + assert '"' not in cmd.as_header() |