diff options
author | Bernát Gábor <bgabor8@bloomberg.net> | 2019-05-01 05:53:17 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-01 05:53:17 -0400 |
commit | 18147f4c5af75caf40c3c2f95a0907da2db83deb (patch) | |
tree | 402dacc7a4f0ba3002d5eb432f87eae47cbf9dc1 | |
parent | 7a2edd942602a4ad9b0efd16b8f92e3d7b16f4be (diff) | |
download | tox-git-18147f4c5af75caf40c3c2f95a0907da2db83deb.tar.gz |
add no download (#1283)
-rw-r--r-- | docs/changelog/448.feature.rst | 3 | ||||
-rw-r--r-- | setup.cfg | 2 | ||||
-rw-r--r-- | src/tox/config/__init__.py | 8 | ||||
-rw-r--r-- | src/tox/venv.py | 3 | ||||
-rw-r--r-- | tests/conftest.py | 3 | ||||
-rw-r--r-- | tests/unit/test_venv.py | 25 | ||||
-rw-r--r-- | tox.ini | 1 |
7 files changed, 39 insertions, 6 deletions
diff --git a/docs/changelog/448.feature.rst b/docs/changelog/448.feature.rst new file mode 100644 index 00000000..02d87e13 --- /dev/null +++ b/docs/changelog/448.feature.rst @@ -0,0 +1,3 @@ +Virtual environments created now no longer upgrade pip/wheel/setuptools to the latest version. Instead the start +packages after virtualenv creation now is whatever virtualenv has bundled in. This allows faster virtualenv +creation and builds that are easier to reproduce. @@ -42,7 +42,7 @@ install_requires = pluggy >= 0.3.0, <1 py >= 1.4.17, <2 six >= 1.0.0, <2 - virtualenv >= 1.11.2 + virtualenv >= 14.0.0 toml >=0.9.4 filelock >= 3.0.0, <4 diff --git a/src/tox/config/__init__.py b/src/tox/config/__init__.py index adfa81fb..574dc952 100644 --- a/src/tox/config/__init__.py +++ b/src/tox/config/__init__.py @@ -750,6 +750,14 @@ def tox_addoption(parser): ) parser.add_testenv_attribute( + "download", + type="bool", + default=False, + help="download the latest pip, setuptools and wheel when creating the virtual" + "environment (default is to use the one bundled in virtualenv)", + ) + + parser.add_testenv_attribute( name="alwayscopy", type="bool", default=False, diff --git a/src/tox/venv.py b/src/tox/venv.py index 22e7e7ae..1f786043 100644 --- a/src/tox/venv.py +++ b/src/tox/venv.py @@ -646,7 +646,6 @@ def prepend_shebang_interpreter(args): return args -NO_DOWNLOAD = False _SKIP_VENV_CREATION = os.environ.get("_TOX_SKIP_ENV_CREATION_TEST", False) == "1" @@ -658,7 +657,7 @@ def tox_testenv_create(venv, action): args.append("--system-site-packages") if venv.envconfig.alwayscopy: args.append("--always-copy") - if NO_DOWNLOAD: + if not venv.envconfig.download: args.append("--no-download") # add interpreter explicitly, to prevent using default (virtualenv.ini) args.extend(["--python", str(config_interpreter)]) diff --git a/tests/conftest.py b/tests/conftest.py index cf0821a1..ec59f4a1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,7 +2,4 @@ # TODO move fixtures here and only keep helper functions/classes in the plugin # TODO _pytest_helpers might be a better name than _pytestplugin then? # noinspection PyUnresolvedReferences -import tox.venv from tox._pytestplugin import * # noqa - -tox.venv.NO_DOWNLOAD = True diff --git a/tests/unit/test_venv.py b/tests/unit/test_venv.py index da6298e4..18dafb88 100644 --- a/tests/unit/test_venv.py +++ b/tests/unit/test_venv.py @@ -1052,3 +1052,28 @@ def test_tox_testenv_interpret_shebang_long_example(tmpdir): ] assert args == expected + base_args + + +@pytest.mark.parametrize("download", [True, False, None]) +def test_create_download(mocksession, newconfig, download): + config = newconfig( + [], + """\ + [testenv:env] + {} + """.format( + "download={}".format(download) if download else "" + ), + ) + mocksession.new_config(config) + venv = mocksession.getvenv("env") + with mocksession.newaction(venv.name, "getenv") as action: + tox_testenv_create(action=action, venv=venv) + pcalls = mocksession._pcalls + assert len(pcalls) >= 1 + args = pcalls[0].args + if download is True: + assert "--no-download" not in map(str, args) + else: + assert "--no-download" in map(str, args) + mocksession._clearmocks() @@ -18,6 +18,7 @@ skip_missing_interpreters = true description = run the tests with pytest under {basepython} setenv = PIP_DISABLE_VERSION_CHECK = 1 COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}/.coverage.{envname}} + VIRTUALENV_NO_DOWNLOAD = 1 passenv = http_proxy https_proxy no_proxy SSL_CERT_FILE PYTEST_* deps = extras = testing |