pythonPackages.virtualenv: 16.7.9 -> 20.0.21 fix #66366
This commit is contained in:
parent
cac4473b97
commit
dc80e0724c
2 changed files with 32 additions and 71 deletions
|
@ -1,25 +1,48 @@
|
|||
{ buildPythonPackage
|
||||
, fetchPypi
|
||||
, lib
|
||||
, recursivePthLoader
|
||||
, stdenv
|
||||
, pythonOlder
|
||||
, isPy27
|
||||
, appdirs
|
||||
, contextlib2
|
||||
, distlib
|
||||
, filelock
|
||||
, importlib-metadata
|
||||
, importlib-resources
|
||||
, pathlib2
|
||||
, setuptools_scm
|
||||
, six
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "virtualenv";
|
||||
version = "16.7.9";
|
||||
version = "20.0.21";
|
||||
|
||||
src = fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "0d62c70883c0342d59c11d0ddac0d954d0431321a41ab20851facf2b222598f3";
|
||||
sha256 = "1kxnxxwa25ghlkpyrxa8pi49v87b7ps2gyla7d1h6kbz9sfn45m1";
|
||||
|
||||
};
|
||||
|
||||
# Doubt this is needed - FRidh 2017-07-07
|
||||
pythonPath = [ recursivePthLoader ];
|
||||
nativeBuildInputs = [
|
||||
setuptools_scm
|
||||
];
|
||||
|
||||
patches = [ ./virtualenv-change-prefix.patch ];
|
||||
|
||||
# Tarball doesn't contain tests
|
||||
doCheck = false;
|
||||
propagatedBuildInputs = [
|
||||
appdirs
|
||||
distlib
|
||||
filelock
|
||||
six
|
||||
] ++ lib.optionals isPy27 [
|
||||
contextlib2
|
||||
] ++ lib.optionals (isPy27 && !stdenv.hostPlatform.isWindows) [
|
||||
pathlib2
|
||||
] ++ lib.optionals (pythonOlder "3.7") [
|
||||
importlib-resources
|
||||
] ++ lib.optionals (pythonOlder "3.8") [
|
||||
importlib-metadata
|
||||
];
|
||||
|
||||
meta = {
|
||||
description = "A tool to create isolated Python environments";
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
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 bcf3225..3530997 100755
|
||||
--- a/virtualenv.py
|
||||
+++ b/virtualenv.py
|
||||
@@ -1163,20 +1163,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", VERSION, "site-packages"),
|
||||
- os.path.join(sys.prefix, "Extras", "lib", "python"),
|
||||
- os.path.join("~", "Library", "Python", VERSION, "site-packages"),
|
||||
- # Python 2.6 no-frameworks
|
||||
- os.path.join("~", ".local", "lib", "python", VERSION, "site-packages"),
|
||||
- # System Python 2.7 on OSX Mountain Lion
|
||||
- os.path.join("~", "Library", "Python", VERSION, "lib", "python", "site-packages"),
|
||||
- )
|
||||
- )
|
||||
+ prefixes = ["/nix/store", sys.prefix]
|
||||
|
||||
if hasattr(sys, "real_prefix"):
|
||||
prefixes.append(sys.real_prefix)
|
||||
@@ -1199,6 +1186,8 @@ def change_prefix(filename, dst_prefix):
|
||||
if src_prefix != os.sep: # sys.prefix == "/"
|
||||
assert relative_path[0] == os.sep
|
||||
relative_path = relative_path[1:]
|
||||
+ if src_prefix == "/nix/store":
|
||||
+ relative_path = "/".join(relative_path.split("/")[1:])
|
||||
return join(dst_prefix, relative_path)
|
||||
assert False, "Filename {} does not start with any of these prefixes: {}".format(filename, prefixes)
|
||||
|
||||
@@ -1375,6 +1364,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:
|
Loading…
Reference in a new issue