Skip to content

Commit

Permalink
For PIP_RUN_RETENTION_STRATEGY, renamed 'ephemeral' to 'destroy' (ref #…
Browse files Browse the repository at this point in the history
…85). Update docs to reflect rename.
  • Loading branch information
jaraco committed Oct 1, 2023
1 parent 571cd6d commit 04df401
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 21 deletions.
35 changes: 17 additions & 18 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -347,27 +347,26 @@ For specifics, see `pip_run.run()
Environment Persistence
=======================

``pip-run`` honors the ``PIP_RUN_MODE`` variable. If unset or
set to ``ephemeral``, dependencies are installed to an ephemeral
temporary directory on each invocation (and deleted after).
Setting this variable to ``persist`` will instead create or re-use
a directory in the user's cache, only installing the dependencies if
the directory doesn't already exist. A separate cache is maintained
for each combination of requirements specified.

``persist`` mode can greatly improve startup performance at the
expense of staleness and accumulated cruft.

Without ``PIP_RUN_MODE=persist`` (or with ``=ephemeral``), ``pip-run`` will
re-install dependencies every time a script runs, silently adding to the
startup time while dependencies are installed into an ephemeral environment,
depending on how many dependencies there are and whether the dependencies have
been previously downloaded to the local pip cache. Use ``pip-run -v ...`` to
see the installation activity.
``pip-run`` honors the ``PIP_RUN_RETENTION_STRATEGY`` variable. If unset or
set to ``destroy``, dependencies are installed to a temporary directory on
each invocation (and deleted after). Setting this variable to ``persist`` will
instead create or re-use a directory in the user's cache, only installing the
dependencies if the directory doesn't already exist. A separate cache is
maintained for each combination of requirements specified.

``persist`` strategy can greatly improve startup performance at the expense of
staleness and accumulated cruft.

Without ``PIP_RUN_RETENTION_STRATEGY=persist`` (or with ``=destroy``),
``pip-run`` will re-install dependencies every time a script runs, silently
adding to the startup time while dependencies are installed into an ephemeral
environment, depending on how many dependencies there are and whether the
dependencies have been previously downloaded to the local pip cache. Use
``pip-run -v ...`` to see the installation activity.

The location of the cache can be revealed with this command::

py -c 'import importlib; print(importlib.import_module("pip_run.mode.persist").paths.user_cache_path)'
py -c 'import importlib; print(importlib.import_module("pip_run.retention.persist").paths.user_cache_path)'


Limitations
Expand Down
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Paths:
monkeypatch_session.setattr(pip_run.retention.persist, 'paths', Paths)


@pytest.fixture(params=['persist', 'ephemeral'])
@pytest.fixture(params=['persist', 'destroy'])
def retention_strategy(monkeypatch, request):
monkeypatch.setenv('PIP_RUN_RETENTION_STRATEGY', request.param)

Expand Down
4 changes: 2 additions & 2 deletions pip_run/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ def _mode_compat():
'PIP_RUN_MODE is deprecated. Use PIP_RUN_RETENTION_STRATEGY instead.',
DeprecationWarning,
)
return mode
return mode.replace('ephemeral', 'destroy')


def retention_strategy():
strategy = (
os.environ.get('PIP_RUN_RETENTION_STRATEGY') or _mode_compat() or 'ephemeral'
os.environ.get('PIP_RUN_RETENTION_STRATEGY') or _mode_compat() or 'destroy'
)
return importlib.import_module(f'.retention.{strategy}', package=__package__)

Expand Down
File renamed without changes.

0 comments on commit 04df401

Please sign in to comment.