summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncan Buck <dncnbuck@gmail.com>2019-10-21 17:10:43 +0200
committerBernát Gábor <bgabor8@bloomberg.net>2019-10-21 16:10:43 +0100
commitf836ce3723221ffbfc0e4d73effc0ed56f6050ac (patch)
tree7b0c065aa8c834a4359f9c080742c55b42d16ac5
parent36e345eaf69d2db0d590176833df08dccbb3eaa0 (diff)
downloadvirtualenv-f836ce3723221ffbfc0e4d73effc0ed56f6050ac.tar.gz
bugfix: allow create env with no-pip (#1430)
* bugfix: allow create env with no-pip * add changelog * add rst backticks
-rw-r--r--docs/changelog/1430.bugfix.rst1
-rw-r--r--tests/test_virtualenv.py17
-rwxr-xr-xvirtualenv.py2
3 files changed, 19 insertions, 1 deletions
diff --git a/docs/changelog/1430.bugfix.rst b/docs/changelog/1430.bugfix.rst
new file mode 100644
index 0000000..31d3352
--- /dev/null
+++ b/docs/changelog/1430.bugfix.rst
@@ -0,0 +1 @@
+* fix virtualenv creation when ``--no-pip`` argument used.
diff --git a/tests/test_virtualenv.py b/tests/test_virtualenv.py
index da55118..620c0cb 100644
--- a/tests/test_virtualenv.py
+++ b/tests/test_virtualenv.py
@@ -628,6 +628,23 @@ def test_create_environment_from_venv(tmpdir):
assert out.strip() == getattr(sys, "real_prefix", sys.prefix)
+@pytest.mark.skipif(std_venv is None, reason="needs standard venv module")
+def test_create_environment_from_venv_no_pip(tmpdir):
+ std_venv_dir = str(tmpdir / "stdvenv")
+ ve_venv_dir = str(tmpdir / "vevenv")
+ home_dir, lib_dir, inc_dir, bin_dir = virtualenv.path_locations(ve_venv_dir)
+ builder = std_venv.EnvBuilder()
+ ctx = builder.ensure_directories(std_venv_dir)
+ builder.create_configuration(ctx)
+ builder.setup_python(ctx)
+ builder.setup_scripts(ctx)
+ subprocess.check_call([ctx.env_exe, virtualenv.__file__, "--no-pip", ve_venv_dir])
+ ve_exe = os.path.join(bin_dir, "python")
+ out = subprocess.check_output([ve_exe, "-c", "import sys; print(sys.real_prefix)"], universal_newlines=True)
+ # Test against real_prefix if present - we might be running the test from a virtualenv (e.g. tox).
+ assert out.strip() == getattr(sys, "real_prefix", sys.prefix)
+
+
def test_create_environment_with_old_pip(tmpdir):
old = Path(__file__).parent / "old-wheels"
old_pip = old / "pip-9.0.1-py2.py3-none-any.whl"
diff --git a/virtualenv.py b/virtualenv.py
index 692957f..bc2024d 100755
--- a/virtualenv.py
+++ b/virtualenv.py
@@ -1086,7 +1086,7 @@ def _install_wheel_with_search_dir(download, project_names, py_executable, searc
)
).encode("utf8")
- if sys.version_info[0:2] == (3, 4):
+ if sys.version_info[0:2] == (3, 4) and "pip" in project_names:
at = project_names.index("pip")
project_names[at] = "pip<19.2"