diff options
author | Frederik Rietdijk <fridh@fridh.nl> | 2017-07-07 17:57:30 +0200 |
---|---|---|
committer | Frederik Rietdijk <fridh@fridh.nl> | 2017-07-07 17:59:32 +0200 |
commit | fbbf5e79c3f0ccfe8f320891e648c7e7a6ef4337 (patch) | |
tree | 23406ec3d16d7fa840b100613aaeb6d54cd0f5d6 /pkgs/development/python-modules/virtualenv | |
parent | ea5b2df8659f5f2dace90f56a616c5f7793c7112 (diff) | |
download | nixlib-fbbf5e79c3f0ccfe8f320891e648c7e7a6ef4337.tar nixlib-fbbf5e79c3f0ccfe8f320891e648c7e7a6ef4337.tar.gz nixlib-fbbf5e79c3f0ccfe8f320891e648c7e7a6ef4337.tar.bz2 nixlib-fbbf5e79c3f0ccfe8f320891e648c7e7a6ef4337.tar.lz nixlib-fbbf5e79c3f0ccfe8f320891e648c7e7a6ef4337.tar.xz nixlib-fbbf5e79c3f0ccfe8f320891e648c7e7a6ef4337.tar.zst nixlib-fbbf5e79c3f0ccfe8f320891e648c7e7a6ef4337.zip |
python.pkgs.virtualenv: move to separate expression
Diffstat (limited to 'pkgs/development/python-modules/virtualenv')
-rw-r--r-- | pkgs/development/python-modules/virtualenv/default.nix | 31 | ||||
-rw-r--r-- | pkgs/development/python-modules/virtualenv/virtualenv-change-prefix.patch | 59 |
2 files changed, 90 insertions, 0 deletions
diff --git a/pkgs/development/python-modules/virtualenv/default.nix b/pkgs/development/python-modules/virtualenv/default.nix new file mode 100644 index 000000000000..f6d3a747ee48 --- /dev/null +++ b/pkgs/development/python-modules/virtualenv/default.nix @@ -0,0 +1,31 @@ +{ buildPythonPackage +, fetchPypi +, lib +, recursivePthLoader +}: + +buildPythonPackage rec { + pname = "virtualenv"; + version = "15.0.3"; + name = "${pname}-${version}"; + + src = fetchPypi { + inherit pname version; + sha256 = "6d9c760d3fc5fa0894b0f99b9de82a4647e1164f0b700a7f99055034bf548b1d"; + }; + + # 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/pkgs/development/python-modules/virtualenv/virtualenv-change-prefix.patch b/pkgs/development/python-modules/virtualenv/virtualenv-change-prefix.patch new file mode 100644 index 000000000000..958187f982fe --- /dev/null +++ b/pkgs/development/python-modules/virtualenv/virtualenv-change-prefix.patch @@ -0,0 +1,59 @@ +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/virtualenv.py b/virtualenv.py +index d3e76a7..cb307fa 100755 +--- a/virtualenv.py ++++ b/virtualenv.py +@@ -1051,17 +1051,7 @@ def path_locations(home_dir): + + + 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) +@@ -1078,6 +1068,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 %s does not start with any of these prefixes: %s" % \ + (filename, prefixes) +@@ -1190,6 +1182,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: |