Skip to content

Commit

Permalink
Change PyInfo cache versioning mechanism
Browse files Browse the repository at this point in the history
This reverts some changes introduced in pypa#2809
  • Loading branch information
robsdedude committed Jan 17, 2025
1 parent caf03a2 commit c877ecd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/virtualenv/app_data/via_disk_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def extract(self, path, to_folder):

@property
def py_info_at(self):
return self.lock / "py_info" / "1"
return self.lock / "py_info" / "2"

def py_info(self, path):
return PyInfoStoreDisk(self.py_info_at, path)
Expand Down
11 changes: 2 additions & 9 deletions src/virtualenv/discovery/cached_py_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
_CACHE = OrderedDict()
_CACHE[Path(sys.executable)] = PythonInfo()
LOGGER = logging.getLogger(__name__)
_CACHE_FILE_VERSION = 1


def from_exe(cls, app_data, exe, env=None, raise_on_error=True, ignore_cache=False): # noqa: FBT002, PLR0913
Expand Down Expand Up @@ -65,13 +64,8 @@ def _get_via_file_cache(cls, app_data, path, exe, env):
with py_info_store.locked():
if py_info_store.exists(): # if exists and matches load
data = py_info_store.read()
of_path, of_st_mtime, of_content, version = (
data["path"],
data["st_mtime"],
data["content"],
data.get("version"),
)
if of_path == path_text and of_st_mtime == path_modified and version == _CACHE_FILE_VERSION:
of_path, of_st_mtime, of_content = data["path"], data["st_mtime"], data["content"]
if of_path == path_text and of_st_mtime == path_modified:
py_info = cls._from_dict(of_content.copy())
sys_exe = py_info.system_executable
if sys_exe is not None and not os.path.exists(sys_exe):
Expand All @@ -86,7 +80,6 @@ def _get_via_file_cache(cls, app_data, path, exe, env):
"st_mtime": path_modified,
"path": path_text,
"content": py_info._to_dict(), # noqa: SLF001
"version": _CACHE_FILE_VERSION,
}
py_info_store.write(data)
else:
Expand Down

0 comments on commit c877ecd

Please sign in to comment.