diff --git a/news/3905.bugfix b/news/3905.bugfix index 0c0c822192a8945f78bc843d7043702b81bf648c..a719866fc9aea08efb2898fdc0032e89e17f457e 100644 --- a/news/3905.bugfix +++ b/news/3905.bugfix @@ -1,8 +1 @@ -Changed rules on where pip version lock file selfcheck.json is stored. - -Previously, the lock file was either stored at ``USER_CACHE``/selfcheck.json, -or for vitual enviorments it is stored at ``sys.prefix``\pip-selfcheck.json - -Now regardless of whether the user is in a virtual environment, the lock file -is stored either in selfcheck.json in the path specified in cache-dir in -pip.conf, or if none is specified it is stored at``USER_CACHE``/selfcheck.json +Adjust path to selfcheck.json - remove virtualenv specific path and honor cache-dir in pip.conf diff --git a/src/pip/_internal/utils/outdated.py b/src/pip/_internal/utils/outdated.py index 1a1f70eec90925f84ef1e7d62ab919651c9c6f28..d7246da55d94e94080169190598f393812707643 100644 --- a/src/pip/_internal/utils/outdated.py +++ b/src/pip/_internal/utils/outdated.py @@ -11,7 +11,6 @@ from pip._vendor.packaging import version as packaging_version from pip._internal.compat import WINDOWS from pip._internal.index import PackageFinder -from pip._internal.locations import USER_CACHE_DIR, running_under_virtualenv from pip._internal.utils.filesystem import check_path_owner from pip._internal.utils.misc import ensure_dir, get_installed_version @@ -21,7 +20,7 @@ SELFCHECK_DATE_FMT = "%Y-%m-%dT%H:%M:%SZ" logger = logging.getLogger(__name__) -class GlobalSelfCheckState(object): +class SelfCheckState(object): def __init__(self, cache_dir): self.statefile_path = os.path.join(cache_dir, "selfcheck.json") @@ -74,7 +73,7 @@ def pip_version_check(session, options): pypi_version = None try: - state = GlobalSelfCheckState(cache_dir=options.cache_dir) + state = SelfCheckState(cache_dir=options.cache_dir) current_time = datetime.datetime.utcnow() # Determine if we need to refresh the state diff --git a/tests/unit/test_unit_outdated.py b/tests/unit/test_unit_outdated.py index cd765ef11c60ab0925a9ff8e25ace7f093d1bc7f..e1f45777b6b4e577ca1b50d40723570033ec261e 100644 --- a/tests/unit/test_unit_outdated.py +++ b/tests/unit/test_unit_outdated.py @@ -74,7 +74,7 @@ def test_pip_version_check(monkeypatch, stored_time, installed_ver, new_ver, save=pretend.call_recorder(lambda v, t: None), ) monkeypatch.setattr( - outdated, 'GlobalSelfCheckState', lambda **kw: fake_state + outdated, 'SelfCheckState', lambda **kw: fake_state ) with freezegun.freeze_time( @@ -137,7 +137,7 @@ def test_global_state(monkeypatch, tmpdir): monkeypatch.setattr(outdated, 'USER_CACHE_DIR', cache_dir) monkeypatch.setattr(sys, 'prefix', tmpdir / 'pip_prefix') - state = outdated.GlobalSelfCheckState(cache_dir=cache_dir) + state = outdated.SelfCheckState(cache_dir=cache_dir) state.save('2.0', datetime.datetime.utcnow()) expected_path = cache_dir / 'selfcheck.json'