Repository navigation
workflows: Restore the dependency cache before creating the virtual environment - #1062
Merged
Merged
Conversation
- Restore the cache before creating the Python virtual environment, and create the environment only when the cache was not restored. - The cache is restored by extracting an archive over the workspace, so restoring it over the virtual environment that the preceding step had just created merged the cached Pip installation with the one that `python -m venv` bootstraps, instead of replacing it. - The merge was harmless only while both Pip versions laid out their internal modules the same way. Pip 26.2 turned module `pip/_internal/build_env.py` into a package of the same name, so the directory left behind by the Pip that `python -m venv` bootstraps, 26.2.1 as of the current interpreters of `actions/setup-python`, now shadows the module of the Pip that this project pins, 26.0.1, and every Pip invocation in the virtual environment fails with `ImportError: cannot import name 'get_runnable_pip' from 'pip._internal.utils.misc'`. - Every job that got a cache hit was affected, which is why the `Build` job started failing on `develop` without any change to the Python build.
jtrobles-cdd
force-pushed
the
bugfix/ci-virtualenv-cache-restore-order
branch
from
September 10, 2026 17:32
021d65a to
50d9081
Compare
|
Merged
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.



The
Buildjob of theCIworkflow fails atmake python-pip-installwithImportError: cannot import name 'get_runnable_pip' from 'pip._internal.utils.misc', in every job that gets a cache hit. Nothing merged intodevelopcaused it: the last run ofdevelopthat missed the cache passed, and the very next run, which hit the cache that run had just saved, failed.Cause
Buildjob creates the virtual environment and only then restores the cache into it, andactions/cacherestores by extracting an archive over the workspace, so the cached Pip installation gets merged with the onepython -m venvbootstraps instead of replacing it.pip/_internal/build_env.pyinto a package of the same name, and movedget_runnable_pip()out ofpip/_internal/utils/misc.py.actions/setup-pythoncurrently installs bootstrap Pip 26.2.1, while this project pins 26.0.1, so thebuild_env/package of 26.2.1 survives the merge and shadows thebuild_env.pymodule of 26.0.1. Pip 26.0.1 then loads thebuild_env.installermodule of 26.2.1, which importsget_runnable_pipfrom autils.miscthat no longer provides it.Testjob is unaffected because it restores the cache into a checkout that holds no virtual environment.Not Bumping Pip Instead
dependabot/pip/pip-26.2fails inmake python-deps-sync-checkbecause pip-tools 7.5.3 importsstdlib_pkgsfrompip._internal.utils.compat, which Pip 26.2 removed.Verification
pip/_internal/build_env.pyandpip/_internal/build_env/are both present afterwards, and extracting the same archive into a directory holding no virtual environment yields a working Pip..github/workflows/ci.yaml, so the first run of this branch reuses the cache saved bydevelopand therefore exercises the cache hit that was failing, rather than the cache miss that already passed.