Skip to content

Commit

Permalink
fix: make stale Python check opt-in again
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii committed Feb 26, 2024
1 parent b3a4c37 commit 152bb3d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion nox/virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,17 @@ def _check_reused_environment_type(self) -> bool:
return False

def _check_reused_environment_interpreter(self) -> bool:
"""Check if reused environment interpreter is the same."""
"""
Check if reused environment interpreter is the same. Currently only checks if
NOX_ENABLE_STALENESS_CHECK is set in the environment. See
* https://github.com/wntrblm/nox/issues/449#issuecomment-860030890
* https://github.com/wntrblm/nox/issues/441
* https://github.com/pypa/virtualenv/issues/2130
"""
if not os.environ.get("NOX_ENABLE_STALENESS_CHECK", ""):
return True

original = self._read_base_prefix_from_pyvenv_cfg()
program = (
"import sys; sys.stdout.write(getattr(sys, 'real_prefix', sys.base_prefix))"
Expand Down
3 changes: 2 additions & 1 deletion tests/test_virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@ def test_create_reuse_oldstyle_virtualenv_environment(make_one):


@pytest.mark.skipif(IS_WINDOWS, reason="Avoid 'No pyvenv.cfg file' error on Windows.")
def test_inner_functions_reusing_venv(make_one):
def test_inner_functions_reusing_venv(make_one, monkeypatch):
monkeypatch.setenv("NOX_ENABLE_STALENESS_CHECK", "1")
venv, location = make_one(reuse_existing=True)
venv.create()

Expand Down

0 comments on commit 152bb3d

Please sign in to comment.