Invoke python -m venv
from a different working directory
#1698
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.
When
python -m venv
is run, it invokesensurepip
to install pip after creating the virtual environment.However, the
ensurepip
module in older Python versions didn't correctly run its Python subprocesses in isolated mode, meaning that the working directory is added tosys.path
. This can cause issues if the app's build directory contains files/directories that shadow expected package names (such as abrotli
directory).For example:
The best fix is for apps to upgrade to newer Python patch versions (3.8.14+, 3.9.14+, 3.10.6+), since they include the upstream
ensurepip
fix as well as many other bug and security fixes.However, to ensure venv creation still works on these older Python versions, as a workaround we can run the
python -m venv
command from a different working directory (as an alternative to isolated mode).Fixes #1697.
GUS-W-17215816.