From 56ef466dccdd97271a977736c26e81a47ef8ec56 Mon Sep 17 00:00:00 2001 From: DK96-OS <69859316+DK96-OS@users.noreply.github.com> Date: Fri, 17 Jan 2025 12:29:18 -0500 Subject: [PATCH 1/4] Merge pull request #2826 from DK96-OS/cli-precedence-2285 Simplify Solution to --python command-line flag precedence --- src/virtualenv/discovery/builtin.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/virtualenv/discovery/builtin.py b/src/virtualenv/discovery/builtin.py index a4c621715..0b0d26b5d 100644 --- a/src/virtualenv/discovery/builtin.py +++ b/src/virtualenv/discovery/builtin.py @@ -3,7 +3,6 @@ import logging import os import sys -from collections import deque from contextlib import suppress from pathlib import Path from typing import TYPE_CHECKING @@ -23,7 +22,7 @@ class Builtin(Discover): - python_spec: Sequence[str] | deque[str] + python_spec: Sequence[str] app_data: AppData try_first_with: Sequence[str] @@ -31,8 +30,7 @@ def __init__(self, options) -> None: super().__init__(options) self.python_spec = options.python or [sys.executable] if self._env.get("VIRTUALENV_PYTHON"): - self.python_spec = deque(self.python_spec) - self.python_spec.rotate(-1) + self.python_spec = self.python_spec[1:] + self.python_spec[:1] # Rotate the list self.app_data = options.app_data self.try_first_with = options.try_first_with From fd0dc85b3b81f0c554c8fc3ecc8e62ee28b38f75 Mon Sep 17 00:00:00 2001 From: Robsdedude Date: Fri, 17 Jan 2025 18:29:31 +0100 Subject: [PATCH 2/4] Change PyInfo cache versioning mechanism (#2827) --- src/virtualenv/app_data/via_disk_folder.py | 2 +- src/virtualenv/discovery/cached_py_info.py | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/virtualenv/app_data/via_disk_folder.py b/src/virtualenv/app_data/via_disk_folder.py index 98cf2886b..1c98a90da 100644 --- a/src/virtualenv/app_data/via_disk_folder.py +++ b/src/virtualenv/app_data/via_disk_folder.py @@ -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) diff --git a/src/virtualenv/discovery/cached_py_info.py b/src/virtualenv/discovery/cached_py_info.py index d0b65676b..4f3ee5e90 100644 --- a/src/virtualenv/discovery/cached_py_info.py +++ b/src/virtualenv/discovery/cached_py_info.py @@ -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 @@ -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): @@ -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: From 61bee9fddf2a17d656a6c43645c4544b2eed7df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Fri, 17 Jan 2025 09:30:58 -0800 Subject: [PATCH 3/4] Add changelog for PyInfo fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bernát Gábor --- docs/changelog/2827.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/changelog/2827.bugfix.rst diff --git a/docs/changelog/2827.bugfix.rst b/docs/changelog/2827.bugfix.rst new file mode 100644 index 000000000..8584d8e14 --- /dev/null +++ b/docs/changelog/2827.bugfix.rst @@ -0,0 +1 @@ +Fix PyInfo cache incompatbility warnings - by :user:`robsdedude`. From e07c0c370e136b16d249aaee30fb4c293041bdcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Fri, 17 Jan 2025 09:31:18 -0800 Subject: [PATCH 4/4] release 20.29.1 --- docs/changelog.rst | 7 +++++++ docs/changelog/2827.bugfix.rst | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) delete mode 100644 docs/changelog/2827.bugfix.rst diff --git a/docs/changelog.rst b/docs/changelog.rst index 19c1b222b..c0aa85e79 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -5,6 +5,13 @@ Release History .. towncrier release notes start +v20.29.1 (2025-01-17) +--------------------- + +Bugfixes - 20.29.1 +~~~~~~~~~~~~~~~~~~ +- Fix PyInfo cache incompatbility warnings - by :user:`robsdedude`. (:issue:`2827`) + v20.29.0 (2025-01-15) --------------------- diff --git a/docs/changelog/2827.bugfix.rst b/docs/changelog/2827.bugfix.rst deleted file mode 100644 index 8584d8e14..000000000 --- a/docs/changelog/2827.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fix PyInfo cache incompatbility warnings - by :user:`robsdedude`.