Update mini-installed addon Python dependencies on Update click - #2487
Open
dsblank wants to merge 2 commits into
Open
Update mini-installed addon Python dependencies on Update click#2487dsblank wants to merge 2 commits into
dsblank wants to merge 2 commits into
Conversation
Previously, clicking Update on an addon only refreshed the addon's own code; a Python module dependency already mini-installed via the PyPI wheel installer or pip was never checked against a newer release, so it could go stale indefinitely. install_package() gains an upgrade mode that compares the installed version against the newest release on PyPI and reinstalls when out of date, removing the old dist-info first so it cannot shadow the new one. The Update button now runs dependency installation in this mode before refreshing the addon code, and the pip subprocess path passes --upgrade for the same effect on source/snap installs.
The CI runner has tomli already installed (pulled in transitively by build tooling), so install_package()'s own already-importable guard was swallowing the tests' setup calls before anything reached the target directory, leaving it empty and failing both assertions. Seed the fixtures with a new _force_extract() helper that downloads and extracts a specific version directly, bypassing that guard the same way TestDownloadExtractE2E already does. Since the test target sits at sys.path[0], the seeded copy shadows any real installation found later on sys.path regardless of environment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[I'm going to call this a bug fix, because if a pip-installed package needs to be updated, you'd have to find it, delete it, uninstall the addon, and re-install. This PR does require that the addon itself be updated too, but then can update the pip-installed package. -Doug]
Summary
install_package()ingramps/gen/utils/pypi.pygains anupgrademode: it looks up the newest version on PyPI, and if the installed copy is older, removes the olddist-info/files (only when they live under the target mini-install directory, never touching system/venv installs) and reinstalls.--upgradefor the same effect on source/snap installs.Known limitation
The Update button's visibility is still driven only by the addon's own code version (
_vvsvingramps/gui/plug/_windows.py), not by whether a declared Python dependency has a newer release on PyPI. So this only refreshes a stale dependency as a side effect of clicking Update for some other reason (e.g. the addon's own version was bumped) — it does not yet surface "this addon's Python dependency is outdated" as its own condition. Keeping that out of scope for this PR to keep it simple; a follow-up could have the addon row check itsrmpackages against PyPI independently.Test plan
python3 -m unittest gramps.gen.utils.test.pypi_test -v(200 tests, existing coverage)python3 -m unittest gramps.gen.utils.test.pypi_e2e_test -v(14 tests, including 2 new upgrade-mode tests against real PyPI)black --checkon all changed filesmypyon all changed files🤖 Generated with Claude Code