diff options
| -rwxr-xr-x | setuptools/command/easy_install.py | 9 | ||||
| -rw-r--r-- | setuptools/tests/test_easy_install.py | 6 |
2 files changed, 12 insertions, 3 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index fb953dbb..54a3bc3a 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1859,8 +1859,11 @@ class CommandSpec(list): """ options = [] - _default = os.path.normpath(sys.executable) - launcher = os.environ.get('__PYVENV_LAUNCHER__', _default) + + @classmethod + def _sys_executable(cls): + _default = os.path.normpath(sys.executable) + return os.environ.get('__PYVENV_LAUNCHER__', _default) @classmethod def from_param(cls, param): @@ -1879,7 +1882,7 @@ class CommandSpec(list): @classmethod def from_environment(cls): - return cls.from_string(cls.launcher) + return cls.from_string(cls._sys_executable()) @classmethod def from_string(cls, string): diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 3a8ddbfb..e1f06788 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -499,3 +499,9 @@ class TestCommandSpec: cmd = CommandSpec(['python']) cmd_new = CommandSpec.from_param(cmd) assert cmd is cmd_new + + def test_from_environment_with_spaces_in_executable(self): + with mock.patch('sys.executable', TestScriptHeader.exe_with_spaces): + cmd = CommandSpec.from_environment() + assert len(cmd) == 1 + assert cmd.as_header().startswith('#!"') |
