Merge master into staging-next
This commit is contained in:
@@ -53,6 +53,10 @@ in with passthru; stdenv.mkDerivation rec {
|
||||
|
||||
hardeningDisable = optional stdenv.isi686 "pic";
|
||||
|
||||
# Remove bootstrap python from closure
|
||||
dontPatchShebangs = true;
|
||||
disallowedReferences = [ python ];
|
||||
|
||||
C_INCLUDE_PATH = makeSearchPathOutput "dev" "include" buildInputs;
|
||||
LIBRARY_PATH = makeLibraryPath buildInputs;
|
||||
LD_LIBRARY_PATH = makeLibraryPath (filter (x : x.outPath != stdenv.cc.libc.outPath or "") buildInputs);
|
||||
|
||||
@@ -9,6 +9,7 @@ let
|
||||
envs = let
|
||||
inherit python;
|
||||
pythonEnv = python.withPackages(ps: with ps; [ ]);
|
||||
pythonVirtualEnv = python.withPackages(ps: with ps; [ virtualenv ]);
|
||||
in {
|
||||
# Plain Python interpreter
|
||||
plain = rec {
|
||||
@@ -16,6 +17,20 @@ let
|
||||
interpreter = env.interpreter;
|
||||
is_venv = "False";
|
||||
is_nixenv = "False";
|
||||
is_virtualenv = "False";
|
||||
};
|
||||
} // lib.optionalAttrs (python.isPy3k && !python.isPyPy) {
|
||||
# Use virtualenv from a Nix env.
|
||||
# Does not function with Python 2
|
||||
# ValueError: source and destination is the same /nix/store/38kz3j1a87cq5y59k5w7k9yk4cqgc5b2-python-2.7.18/lib/python2.7/os.py
|
||||
nixenv-virtualenv = rec {
|
||||
env = runCommand "${python.name}-virtualenv" {} ''
|
||||
${pythonVirtualEnv.interpreter} -m virtualenv $out
|
||||
'';
|
||||
interpreter = "${env}/bin/${python.executable}";
|
||||
is_venv = "False";
|
||||
is_nixenv = "True";
|
||||
is_virtualenv = "True";
|
||||
};
|
||||
} // lib.optionalAttrs (python.implementation != "graal") {
|
||||
# Python Nix environment (python.buildEnv)
|
||||
@@ -24,6 +39,7 @@ let
|
||||
interpreter = env.interpreter;
|
||||
is_venv = "False";
|
||||
is_nixenv = "True";
|
||||
is_virtualenv = "True";
|
||||
};
|
||||
} // lib.optionalAttrs (python.isPy3k && (!python.isPyPy)) rec {
|
||||
# Venv built using plain Python
|
||||
@@ -36,6 +52,7 @@ let
|
||||
interpreter = "${env}/bin/${python.executable}";
|
||||
is_venv = "True";
|
||||
is_nixenv = "False";
|
||||
is_virtualenv = "True";
|
||||
};
|
||||
|
||||
} // lib.optionalAttrs (python.pythonAtLeast "3.8") {
|
||||
@@ -49,6 +66,7 @@ let
|
||||
interpreter = "${env}/bin/${pythonEnv.executable}";
|
||||
is_venv = "True";
|
||||
is_nixenv = "True";
|
||||
is_virtualenv = "True";
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ ENV = "@env@"
|
||||
INTERPRETER = "@interpreter@"
|
||||
PYTHON_VERSION = "@pythonVersion@"
|
||||
|
||||
IS_VIRTUALENV = @is_virtualenv@
|
||||
IS_VENV = @is_venv@
|
||||
IS_NIXENV = @is_nixenv@
|
||||
IS_PYPY = platform.python_implementation() == "PyPy"
|
||||
@@ -37,7 +38,7 @@ class TestCasePython(unittest.TestCase):
|
||||
|
||||
@unittest.skipIf(IS_PYPY or sys.version_info.major==2, "Python 2 does not have base_prefix")
|
||||
def test_base_prefix(self):
|
||||
if IS_VENV or IS_NIXENV:
|
||||
if IS_VENV or IS_NIXENV or IS_VIRTUALENV:
|
||||
self.assertNotEqual(sys.prefix, sys.base_prefix)
|
||||
else:
|
||||
self.assertEqual(sys.prefix, sys.base_prefix)
|
||||
|
||||
Reference in New Issue
Block a user