Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build isolation on Pythons where purelib/platlib aren't enough #11466

Merged
merged 1 commit into from
Sep 26, 2022

Conversation

minrk
Copy link
Contributor

@minrk minrk commented Sep 23, 2022

use site.getsitepackages() where available instead of just purelib/platlib, which is sometimes insufficient on e.g. System Pythons for Debian/macOS.

handle virtualenv < 20 overwriting site.py without getsitepackages() by preserving current behavior. I think the cases where this fix is needed and site.py is overwritten are mutually exclusive, so this should be okay. At the very least, it should be an improvement in all cases where behavior is changed.

I don't know how to write a great test, since it needs to actually run against system Python on Mac or Debian outside a virtualenv in order to directly test this. As it is, the added test only assumes that site.getsitepackages() is right to remove and then removed, which is a bit tautological.

closes #6264

@minrk
Copy link
Contributor Author

minrk commented Sep 23, 2022

If it helps, this gist: https://gist.github.com/minrk/6d73fc9159448f1f83f8a6d5c2b2dfac has a regression test on ubuntu:22.04 that fails with pip 22.2.2, and works with this PR.

use site.getsitepackages() where available
instead of just purelib/platlib,
which is often insufficient on e.g. System Pythons for Debian/macOS

handle virtualenv < 20 overwriting site.py without getsitepackages() by preserving current behavior.
@uranusjr uranusjr merged commit 0a21080 into pypa:main Sep 26, 2022
@minrk minrk deleted the build_env_isolation branch September 26, 2022 07:51
@pradyunsg
Copy link
Member

Thanks @minrk! ^>^

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

virtualenv with --system-site-packages breaks pip's build isolation
3 participants