about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/virtualenv
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-01-07 02:18:36 +0000
committerAlyssa Ross <hi@alyssa.is>2019-01-07 02:18:47 +0000
commit36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2 (patch)
treeb3faaf573407b32aa645237a4d16b82778a39a92 /nixpkgs/pkgs/development/python-modules/virtualenv
parent4e31070265257dc67d120c27e0f75c2344fdfa9a (diff)
parentabf060725d7614bd3b9f96764262dfbc2f9c2199 (diff)
downloadnixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.gz
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.bz2
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.lz
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.xz
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.tar.zst
nixlib-36f56d99fa0a0765c9f1de4a5f17a9b05830c3f2.zip
Add 'nixpkgs/' from commit 'abf060725d7614bd3b9f96764262dfbc2f9c2199'
git-subtree-dir: nixpkgs
git-subtree-mainline: 4e31070265257dc67d120c27e0f75c2344fdfa9a
git-subtree-split: abf060725d7614bd3b9f96764262dfbc2f9c2199
Diffstat (limited to 'nixpkgs/pkgs/development/python-modules/virtualenv')
-rw-r--r--nixpkgs/pkgs/development/python-modules/virtualenv/default.nix30
-rw-r--r--nixpkgs/pkgs/development/python-modules/virtualenv/virtualenv-change-prefix.patch62
2 files changed, 92 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/python-modules/virtualenv/default.nix b/nixpkgs/pkgs/development/python-modules/virtualenv/default.nix
new file mode 100644
index 000000000000..5a39407ed2f8
--- /dev/null
+++ b/nixpkgs/pkgs/development/python-modules/virtualenv/default.nix
@@ -0,0 +1,30 @@
+{ buildPythonPackage
+, fetchPypi
+, lib
+, recursivePthLoader
+}:
+
+buildPythonPackage rec {
+  pname = "virtualenv";
+  version = "16.1.0";
+
+  src = fetchPypi {
+    inherit pname version;
+    sha256 = "f899fafcd92e1150f40c8215328be38ff24b519cd95357fa6e78e006c7638208";
+  };
+
+  # Doubt this is needed - FRidh 2017-07-07
+  pythonPath = [ recursivePthLoader ];
+
+  patches = [ ./virtualenv-change-prefix.patch ];
+
+  # Tarball doesn't contain tests
+  doCheck = false;
+
+  meta = {
+    description = "A tool to create isolated Python environments";
+    homepage = http://www.virtualenv.org;
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ goibhniu ];
+  };
+}
\ No newline at end of file
diff --git a/nixpkgs/pkgs/development/python-modules/virtualenv/virtualenv-change-prefix.patch b/nixpkgs/pkgs/development/python-modules/virtualenv/virtualenv-change-prefix.patch
new file mode 100644
index 000000000000..2c121c83d498
--- /dev/null
+++ b/nixpkgs/pkgs/development/python-modules/virtualenv/virtualenv-change-prefix.patch
@@ -0,0 +1,62 @@
+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.
+
+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.
+
+
+diff --git a/src/virtualenv.py b/src/virtualenv.py
+index 4b57cde..afda73f 100755
+--- a/src/virtualenv.py
++++ b/src/virtualenv.py
+@@ -1071,20 +1071,7 @@ def path_locations(home_dir, dry_run=False):
+ 
+ 
+ def change_prefix(filename, dst_prefix):
+-    prefixes = [sys.prefix]
+-
+-    if is_darwin:
+-        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"),
+-            )
+-        )
++    prefixes = ["/nix/store", sys.prefix]
+ 
+     if hasattr(sys, "real_prefix"):
+         prefixes.append(sys.real_prefix)
+@@ -1107,6 +1094,8 @@ def change_prefix(filename, dst_prefix):
+             if src_prefix != os.sep:  # sys.prefix == "/"
+                 assert relpath[0] == os.sep
+                 relpath = relpath[1:]
++                if src_prefix == "/nix/store":
++                    relpath = "/".join(relpath.split("/")[1:])
+             return join(dst_prefix, relpath)
+     assert False, "Filename {} does not start with any of these prefixes: {}".format(filename, prefixes)
+ 
+@@ -1233,6 +1222,11 @@ def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, sy
+     site_filename_dst = change_prefix(site_filename, home_dir)
+     site_dir = os.path.dirname(site_filename_dst)
+     writefile(site_filename_dst, SITE_PY)
++    wrapper_path = join(prefix, "lib", py_version, "site-packages")
++    writefile(
++        join(site_dir, 'sitecustomize.py',),
++        "import sys; sys.path.append('%s')" % wrapper_path
++    )
+     writefile(join(site_dir, "orig-prefix.txt"), prefix)
+     site_packages_filename = join(site_dir, "no-global-site-packages.txt")
+     if not site_packages: