Skip to content

Conversation

@esafak
Copy link
Contributor

@esafak esafak commented Aug 1, 2025

The cache for PythonInfo is now invalidated if the PythonInfo class changes. I achieved this by hashing the py_info.py file and storing the hash in the cache. When loading from the cache, the hash is recomputed and compared with the stored hash. If they don't match, the cache is invalidated.

Fixes #2467

  • ran the linter to address style issues (tox -e fix)
  • wrote descriptive pull request text
  • ensured there are test(s) validating the fix
  • added news fragment in docs/changelog folder
  • updated/extended the documentation

The cache for PythonInfo is now invalidated if the PythonInfo class
changes. I achieved this by hashing the py_info.py file and storing the hash in the cache. When loading from the cache, the hash is recomputed and compared with the stored hash. If they don't match, the cache is invalidated.

Fixes pypa#2647

Signed-off-by: Emre Şafak <3928300+esafak@users.noreply.github.com>
gaborbernat
gaborbernat previously approved these changes Aug 1, 2025
@gaborbernat
Copy link
Contributor

            # 6. Assert that _run_subprocess was called again
>           assert spy.call_count == 2
E           assert 3 == 2
E            +  where 3 = <function _run_subprocess at 0x1031e74c0>.call_count

Seems this is a valid error, you'll need to fix it.

@gaborbernat gaborbernat marked this pull request as draft August 1, 2025 19:45
* Add `encoding="utf-8"` to `subprocess.run` calls in
  `tests/unit/discovery/test_discovery.py` for consistent text handling.
* Update assertion in `tests/unit/discovery/py_info/test_py_info.py` to handle potential multiple calls on Homebrew installations.
* Ensure consistent text encoding across subprocess executions in discovery tests.

Signed-off-by: Emre Şafak <3928300+esafak@users.noreply.github.com>
Signed-off-by: Emre Şafak <3928300+esafak@users.noreply.github.com>
@esafak
Copy link
Contributor Author

esafak commented Aug 1, 2025

That linter rule is dumb. It will be happier if I completely remove the comment leaving everybody in the dark. Should I remove it?

esafak added 2 commits August 1, 2025 16:47
Signed-off-by: Emre Şafak <3928300+esafak@users.noreply.github.com>
Signed-off-by: Emre Şafak <3928300+esafak@users.noreply.github.com>
@esafak esafak requested a review from gaborbernat August 1, 2025 21:42
@esafak esafak marked this pull request as ready for review August 1, 2025 21:42
@gaborbernat
Copy link
Contributor

@esafak you need to fix the pre commit check 😊

Signed-off-by: Emre Şafak <3928300+esafak@users.noreply.github.com>
@gaborbernat gaborbernat enabled auto-merge (squash) August 1, 2025 23:08
@gaborbernat gaborbernat merged commit 31eb8b9 into pypa:main Aug 1, 2025
42 checks passed
@esafak esafak deleted the fix/2467-cache-invalidation branch August 1, 2025 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cache is not invalidated if PythonInfo is changed

2 participants