You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ensurepip bootstrap breaks out of isolated environment #90355
A change in behavior was made to the ensurepip module in Python 3.8.7 that causes bootstrapping to break out of an isolated environment. This is relevant to the assumption made in the venv module, which ran ensurepip as a sub-process with the -I flag environment isolation to force installation in the virtual environment directory.
In Python <= 3.8.6, ensurepip ran the bootstrap within the current interpreter, so the environment remained isolated. But in Python >= 3.8.7 it creates a second subprocess without the -I flag, and the un-isolated environment appears to be restored for pip. This would then allow a search of any additional paths, and prevent installation of pip and setuptools from being installed in the venv environment directory if they are found somewhere else.
As stated in the issue, this should be rebased onto main and once accepted and merged there it can be backported. Probably a new PR is easiest.
Should the pull request be to "main", or to "3.11"?
Also, the "cpython-cla-bot" now marks that the CLA is not signed again. I have signed it and previously "the-knights-who-say-ni" had marked it as signed.
Activity
kcdodd commentedon Dec 29, 2021
A change in behavior was made to the
ensurepipmodule in Python 3.8.7 that causes bootstrapping to break out of an isolated environment. This is relevant to the assumption made in thevenvmodule, which ran ensurepip as a sub-process with the-Iflag environment isolation to force installation in the virtual environment directory.In Python <= 3.8.6, ensurepip ran the bootstrap within the current interpreter, so the environment remained isolated. But in Python >= 3.8.7 it creates a second subprocess without the
-Iflag, and the un-isolated environment appears to be restored for pip. This would then allow a search of any additional paths, and prevent installation of pip and setuptools from being installed in the venv environment directory if they are found somewhere else.merwok commentedon Feb 3, 2022
Thanks for the report and PR.
The workflow would be to merge a fix to the main branch for 3.11, then there’s a bot that makes backports for active branches (3.10 and 3.9).
More info: https://devguide.python.org/
gvanrossum commentedon May 16, 2022
@kcdodd Pleas follow instructions here.
kcdodd commentedon May 16, 2022
@gvanrossum
Should the pull request be to "main", or to "3.11"?
Also, the "cpython-cla-bot" now marks that the CLA is not signed again. I have signed it and previously "the-knights-who-say-ni" had marked it as signed.
gvanrossum commentedon May 16, 2022
It should be main (that comment was written when 3.11==main, but now 3.11b1 was released and 3.12==main until next year). I'll look into the CLA bot.
pythongh-90355: Add isolated flag if currently isolated (pythonGH-92857)
gh-90355: Add isolated flag if currently isolated (GH-92857)
pythongh-90355: Add isolated flag if currently isolated (pythonGH-92857)
[3.9] pythongh-90355: Add isolated flag if currently isolated (python…
[3.8] pythongh-90355: Add isolated flag if currently isolated (python…
gh-90355: Add isolated flag if currently isolated (GH-92857) (GH-94568)
gh-90355: Add isolated flag if currently isolated (GH-92857) (GH-94569)
[3.9] gh-90355: Add isolated flag if currently isolated (GH-92857) (G…
[3.8] gh-90355: Add isolated flag if currently isolated (GH-92857) (G…
ambv commentedon Jul 5, 2022
This is now fixed in 3.8 - 3.12. Thanks, Carter! ✨ 🍰 ✨