Skip to content

Commit

Permalink
Make app data override variable public (#1559)
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile committed Feb 10, 2020
1 parent 710c81a commit 8c2985c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/changelog/1559.feature.rst
@@ -0,0 +1 @@
Allow virtualenv's app data cache to be overridden by ``VIRTUALENV_OVERRIDE_APP_DATA`` - by :user:`asottile`.
2 changes: 2 additions & 0 deletions docs/user_guide.rst
Expand Up @@ -127,6 +127,8 @@ main seed mechanism available:
we can just link into the virtual environments install directory we can achieve speedups of shaving the initial
1 minutes 10 seconds down to just 8 seconds in case of copy, or ``0.8`` seconds in case symlinks are available -
this is on Windows, Linux/macOS with symlinks this can be as low as ``100ms`` from 3+ seconds).
To override the filesystem location of the seed cache, one can use the
``VIRTUALENV_OVERRIDE_APP_DATA`` environment variable.

Activators
----------
Expand Down
2 changes: 1 addition & 1 deletion src/virtualenv/dirs.py
Expand Up @@ -18,7 +18,7 @@ def default_data_dir():


def _get_default_data_folder():
key = str("_VIRTUALENV_OVERRIDE_APP_DATA")
key = str("VIRTUALENV_OVERRIDE_APP_DATA")
if key in os.environ:
folder = os.environ[key]
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_zipapp.py
Expand Up @@ -69,7 +69,7 @@ def zipapp_test_env(tmp_path_factory):
@pytest.fixture()
def call_zipapp(zipapp, monkeypatch, tmp_path, zipapp_test_env):
def _run(*args):
monkeypatch.setenv(str("_VIRTUALENV_OVERRIDE_APP_DATA"), str(tmp_path / "app_data"))
monkeypatch.setenv(str("VIRTUALENV_OVERRIDE_APP_DATA"), str(tmp_path / "app_data"))
cmd = [str(zipapp_test_env), str(zipapp), "-vv", six.ensure_text(str(tmp_path / "env"))] + list(args)
subprocess.check_call(cmd)

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/create/test_creator.py
Expand Up @@ -281,7 +281,7 @@ def test_cross_major(cross_python, coverage_env, tmp_path, current_fastest):


def test_create_parallel(tmp_path, monkeypatch):
monkeypatch.setenv(str("_VIRTUALENV_OVERRIDE_APP_DATA"), str(tmp_path))
monkeypatch.setenv(str("VIRTUALENV_OVERRIDE_APP_DATA"), str(tmp_path))

def create(count):
subprocess.check_call([sys.executable, "-m", "virtualenv", str(tmp_path / "venv{}".format(count))])
Expand Down

0 comments on commit 8c2985c

Please sign in to comment.