2014-04-18 18:08:49 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								Without this patch `virtualenv --python=python2.7 .` fails with an
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								error because it notices that the python readline.so is not in the
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								same path as python2.7. I assume this is to avoid copying the wrong
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								file on systems where it is possible to find incompatible libraries by
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								accident. Adding "/nix/store" to the prefix fixes this problem.
							 | 
						
					
						
							
								
									
										
										
										
											2012-05-19 23:15:50 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-18 18:08:49 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								A sitecustomize.py is created in the virtualenv which makes libraries
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								from the python specified by the --python argument available to the
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								virtualenv. For example, this makes readline and sqlite3 available
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								when a wrapped python is specified. If no --python argument is passed,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								it will only add the path to the python used when building
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								`virtualenv`, which is the unwrapped python, so sqlite3 won't be
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								available.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-14 15:53:32 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								diff --git a/virtualenv.py b/virtualenv.py
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								index bcf3225..3530997 100755
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								--- a/virtualenv.py
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+++ b/virtualenv.py
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								@@ -1163,20 +1163,7 @@ def path_locations(home_dir, dry_run=False):
							 | 
						
					
						
							
								
									
										
										
										
											2012-05-19 23:15:50 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 def change_prefix(filename, dst_prefix):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-    prefixes = [sys.prefix]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-14 15:53:32 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-    if IS_DARWIN:
							 | 
						
					
						
							
								
									
										
										
										
											2018-11-04 17:15:39 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								-        prefixes.extend(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-            (
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-                os.path.join("/Library/Python", sys.version[:3], "site-packages"),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-                os.path.join(sys.prefix, "Extras", "lib", "python"),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-                os.path.join("~", "Library", "Python", sys.version[:3], "site-packages"),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-                # Python 2.6 no-frameworks
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-                os.path.join("~", ".local", "lib", "python", sys.version[:3], "site-packages"),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-                # System Python 2.7 on OSX Mountain Lion
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-                os.path.join("~", "Library", "Python", sys.version[:3], "lib", "python", "site-packages"),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-            )
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								-        )
							 | 
						
					
						
							
								
									
										
										
										
											2012-05-19 23:15:50 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    prefixes = ["/nix/store", sys.prefix]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2018-11-04 17:15:39 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     if hasattr(sys, "real_prefix"):
							 | 
						
					
						
							
								
									
										
										
										
											2012-05-19 23:15:50 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         prefixes.append(sys.real_prefix)
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-14 15:53:32 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -1199,6 +1186,8 @@ def change_prefix(filename, dst_prefix):
							 | 
						
					
						
							
								
									
										
										
										
											2018-11-04 17:15:39 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								             if src_prefix != os.sep:  # sys.prefix == "/"
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-14 15:53:32 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                 assert relative_path[0] == os.sep
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                 relative_path = relative_path[1:]
							 | 
						
					
						
							
								
									
										
										
										
											2013-01-17 00:18:02 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                if src_prefix == "/nix/store":
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-14 15:53:32 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+                    relative_path = "/".join(relative_path.split("/")[1:])
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								             return join(dst_prefix, relative_path)
							 | 
						
					
						
							
								
									
										
										
										
											2018-11-04 17:15:39 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     assert False, "Filename {} does not start with any of these prefixes: {}".format(filename, prefixes)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 
							 | 
						
					
						
							
								
									
										
										
										
											2019-02-14 15:53:32 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								@@ -1375,6 +1364,11 @@ def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, sy
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-18 18:08:49 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     site_filename_dst = change_prefix(site_filename, home_dir)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     site_dir = os.path.dirname(site_filename_dst)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     writefile(site_filename_dst, SITE_PY)
							 | 
						
					
						
							
								
									
										
										
										
											2019-03-13 18:58:52 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    wrapper_path = join(prefix, "lib", PY_VERSION, "site-packages")
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-18 18:08:49 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								+    writefile(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        join(site_dir, 'sitecustomize.py',),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+        "import sys; sys.path.append('%s')" % wrapper_path
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								+    )
							 | 
						
					
						
							
								
									
										
										
										
											2018-11-04 17:15:39 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     writefile(join(site_dir, "orig-prefix.txt"), prefix)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     site_packages_filename = join(site_dir, "no-global-site-packages.txt")
							 | 
						
					
						
							
								
									
										
										
										
											2014-04-18 18:08:49 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     if not site_packages:
							 |