diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2015-01-04 22:44:28 -0500 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2015-01-04 22:44:28 -0500 |
| commit | 3b68368e30aa51d4a7f96053501c604a8cb6fe42 (patch) | |
| tree | ff5caaac51c0c401bb7490899ad07068fec1730d | |
| parent | 0ad48553589fc68faeb7a5fc2f76da128249ac86 (diff) | |
| download | python-setuptools-git-3b68368e30aa51d4a7f96053501c604a8cb6fe42.tar.gz | |
Change the way string values are interpreted from build.executable - now they must be quoted or otherwise escaped suitable for parsing by shlex.split.
| -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() |
