Skip to content

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

Merged
uranusjr merged 1 commit intopypa:mainfrom
minrk:build_env_isolation
Sep 26, 2022
Merged

Fix build isolation on Pythons where purelib/platlib aren't enough#11466
uranusjr merged 1 commit intopypa:mainfrom
minrk:build_env_isolation

Conversation

@minrk
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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