Skip to content

Commit

Permalink
Create proxies for pip, wheel, etc. to get around problems with long …
Browse files Browse the repository at this point in the history
…paths and spaces in paths
  • Loading branch information
HaraldNordgren committed Jan 9, 2017
1 parent c1ef9e2 commit 9593971
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import pkgutil
import tempfile
import textwrap
import stat
from distutils.util import strtobool
from os.path import join

Expand Down Expand Up @@ -904,6 +905,30 @@ def space_path2url(p):
logger.end_progress()


def create_proxies(py_executable, bin_dir):
scripts = glob.glob(os.path.join(bin_dir, "pip*"))
scripts += glob.glob(os.path.join(bin_dir, "easy_install*"))
scripts += glob.glob(os.path.join(bin_dir, "wheel*"))

for script in scripts:
head, tail = os.path.split(script)
hidden_destination = os.path.join(head, '.' + tail)
os.rename(script, hidden_destination)
with open(script, "w") as script_proxy:
text = "#!/usr/bin/env sh"
text += "\n'%s' '%s' $@" % (
py_executable,
hidden_destination,
)
script_proxy.write(text)

os.chmod(script, os.stat(script).st_mode | stat.S_IEXEC)
os.chmod(
hidden_destination,
os.stat(hidden_destination).st_mode & ~stat.S_IEXEC
)


def create_environment(home_dir, site_packages=False, clear=False,
unzip_setuptools=False,
prompt=None, search_dirs=None, download=False,
Expand Down Expand Up @@ -945,6 +970,11 @@ def create_environment(home_dir, site_packages=False, clear=False,
download=download,
)

create_proxies(
py_executable=py_executable,
bin_dir=bin_dir
)

install_activate(home_dir, bin_dir, prompt)

install_python_config(home_dir, bin_dir, prompt)
Expand Down

0 comments on commit 9593971

Please sign in to comment.