Skip to content

Commit

Permalink
Fix creation of entry points when path contains spaces
Browse files Browse the repository at this point in the history
Before this patch:

```console
$ virtualenv --version
virtualenv 20.0.6.dev5+g9201422 from /usr/users/ga002/soranzon/software/nsoranzo_virtualenv/.venv/local/lib/python2.7/site-packages/virtualenv/__init__.pyc
$ virtualenv 'foo bar'
created virtual environment CPython2.7.17.final.0-64 in 403ms
  creator CPython2Posix(dest=/usr/users/ga002/soranzon/software/nsoranzo_virtualenv/foo bar, clear=False, global=False)
  seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=/usr/users/ga002/soranzon/.local/share/virtualenv/seed-v1)
  activators PythonActivator,CShellActivator,FishActivator,PowerShellActivator,BashActivator
$ head -n 3 foo\ bar/bin/pip
#!/bin/sh
'''exec' /usr/users/ga002/soranzon/software/nsoranzo_virtualenv/foo bar/bin/python "$0" "$@"
' '''
$ ./foo\ bar/bin/pip
./foo bar/bin/pip: 2: exec: /usr/users/ga002/soranzon/software/nsoranzo_virtualenv/foo: not found
```

After this patch:

```console
$ virtualenv 'foo bar'
created virtual environment CPython2.7.17.final.0-64 in 336ms
  creator CPython2Posix(dest=/usr/users/ga002/soranzon/software/nsoranzo_virtualenv/foo bar, clear=False, global=False)
  seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=/usr/users/ga002/soranzon/.local/share/virtualenv/seed-v1)
  activators PythonActivator,CShellActivator,FishActivator,PowerShellActivator,BashActivator
$ head -n 3 foo\ bar/bin/pip
#!/bin/sh
'''exec' "/usr/users/ga002/soranzon/software/nsoranzo_virtualenv/foo bar/bin/python" "$0" "$@"
' '''
$ ./foo\ bar/bin/pip

Usage:
  pip <command> [options]
...
```
  • Loading branch information
nsoranzo committed Feb 25, 2020
1 parent 9201422 commit fed246e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/changelog/1660.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix creation of entry points when path contains spaces - by :user:`nsoranzo`.
4 changes: 2 additions & 2 deletions src/virtualenv/seed/via_app_data/pip_install/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ def _console_scripts(self):

def _create_console_entry_point(self, name, value, to_folder, version_info):
result = []
from distlib.scripts import ScriptMaker
from distlib.scripts import _enquote_executable, ScriptMaker

maker = ScriptMaker(None, str(to_folder))
maker.clobber = True # overwrite
maker.variants = {""}
maker.set_mode = True # ensure they are executable
maker.executable = str(self._creator.exe)
maker.executable = _enquote_executable(str(self._creator.exe))
specification = "{} = {}".format(name, value)
with self.patch_distlib_correct_variants(version_info, maker):
new_files = maker.make(specification)
Expand Down

0 comments on commit fed246e

Please sign in to comment.