@@ -1,62 +0,0 @@
1−Without this patch `virtualenv --python=python2.7 .` fails with an
2−error because it notices that the python readline.so is not in the
3−same path as python2.7. I assume this is to avoid copying the wrong
4−file on systems where it is possible to find incompatible libraries by
5−accident. Adding "/nix/store" to the prefix fixes this problem.
6−
7−A sitecustomize.py is created in the virtualenv which makes libraries
8−from the python specified by the --python argument available to the
9−virtualenv. For example, this makes readline and sqlite3 available
10−when a wrapped python is specified. If no --python argument is passed,
11−it will only add the path to the python used when building
12−`virtualenv`, which is the unwrapped python, so sqlite3 won't be
13−available.
14−
15−
16−diff --git a/virtualenv.py b/virtualenv.py
17−index bcf3225..3530997 100755
18−--- a/virtualenv.py
19−+++ b/virtualenv.py
20−@@ -1163,20 +1163,7 @@ def path_locations(home_dir, dry_run=False):
21−
22−
23− def change_prefix(filename, dst_prefix):
24−- prefixes = [sys.prefix]
25−-
26−- if IS_DARWIN:
27−- prefixes.extend(
28−- (
29−- os.path.join("/Library/Python", VERSION, "site-packages"),
30−- os.path.join(sys.prefix, "Extras", "lib", "python"),
31−- os.path.join("~", "Library", "Python", VERSION, "site-packages"),
32−- # Python 2.6 no-frameworks
33−- os.path.join("~", ".local", "lib", "python", VERSION, "site-packages"),
34−- # System Python 2.7 on OSX Mountain Lion
35−- os.path.join("~", "Library", "Python", VERSION, "lib", "python", "site-packages"),
36−- )
37−- )
38−+ prefixes = ["/nix/store", sys.prefix]
39−
40− if hasattr(sys, "real_prefix"):
41− prefixes.append(sys.real_prefix)
42−@@ -1199,6 +1186,8 @@ def change_prefix(filename, dst_prefix):
43− if src_prefix != os.sep: # sys.prefix == "/"
44− assert relative_path[0] == os.sep
45− relative_path = relative_path[1:]
46−+ if src_prefix == "/nix/store":
47−+ relative_path = "/".join(relative_path.split("/")[1:])
48− return join(dst_prefix, relative_path)
49− assert False, "Filename {} does not start with any of these prefixes: {}".format(filename, prefixes)
50−
51−@@ -1375,6 +1364,11 @@ def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, sy
52− site_filename_dst = change_prefix(site_filename, home_dir)
53− site_dir = os.path.dirname(site_filename_dst)
54− writefile(site_filename_dst, SITE_PY)
55−+ wrapper_path = join(prefix, "lib", PY_VERSION, "site-packages")
56−+ writefile(
57−+ join(site_dir, 'sitecustomize.py',),
58−+ "import sys; sys.path.append('%s')" % wrapper_path
59−+ )
60− writefile(join(site_dir, "orig-prefix.txt"), prefix)
61− site_packages_filename = join(site_dir, "no-global-site-packages.txt")
62− if not site_packages: