Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cac4473b9783
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2de446e0b896
Choose a head ref
  • 2 commits
  • 4 files changed
  • 2 contributors

Commits on May 23, 2020

  1. Copy the full SHA
    dc80e07 View commit details
  2. python.tests: also test virtualenv

    Test whether creating a virtualenv functions.
    FRidh committed May 23, 2020
    Copy the full SHA
    2de446e View commit details
18 changes: 18 additions & 0 deletions pkgs/development/interpreters/python/tests.nix
Original file line number Diff line number Diff line change
@@ -9,13 +9,28 @@ let
envs = let
inherit python;
pythonEnv = python.withPackages(ps: with ps; [ ]);
pythonVirtualEnv = python.withPackages(ps: with ps; [ virtualenv ]);
in {
# Plain Python interpreter
plain = rec {
env = python;
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";
};
};

3 changes: 2 additions & 1 deletion pkgs/development/interpreters/python/tests/test_python.py
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
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 @@ def test_site_prefix(self):

@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)
41 changes: 32 additions & 9 deletions pkgs/development/python-modules/virtualenv/default.nix
Original file line number Diff line number Diff line change
@@ -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 ];
};

patches = [ ./virtualenv-change-prefix.patch ];
nativeBuildInputs = [
setuptools_scm
];

# 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";

This file was deleted.