Skip to content

Commit 6d2673b

Browse files
committed
perf(venv): skip the distutils shim on Python 3.10+
Stop materializing and importing the virtualenv distutils shim for Python 3.10+, where pip and setuptools already ignore the affected install configuration. Keep the shim for Python 3.9 and move the rules_py-specific PATH setup into the existing venv .pth so console scripts remain discoverable. Match the upstream changes: pypa/virtualenv#3184 astral-sh/uv#20222
1 parent c752dd3 commit 6d2673b

12 files changed

Lines changed: 43 additions & 64 deletions

File tree

e2e/cases/cross-repo-610/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
for p in site.PREFIXES:
1313
print(" -", p)
1414

15-
# The virtualenv module should have already been loaded at interpreter startup
16-
assert "_virtualenv" in sys.modules
15+
# Python 3.10+ does not need the distutils startup shim.
16+
assert "_virtualenv" not in sys.modules
1717

1818
# Note that we can't assume that a `.runfiles` tree has been created as CI may
1919
# use a different layout.

e2e/cases/interpreter-features-tkinter/snapshots/amd64_layers_listing.yaml

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/cases/oci/py_image_layer/snapshots/my_app_layers_fp_listing.yaml

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/cases/oci/py_image_layer/snapshots/my_app_layers_listing.yaml

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/cases/oci/py_image_layer/snapshots/my_app_layers_multi_listing.yaml

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/cases/oci/py_venv_image_layer/snapshots/my_app_amd64_layers_listing.yaml

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/cases/oci/py_venv_image_layer/snapshots/my_app_arm64_layers_listing.yaml

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/cases/uv-deps-650/crossbuild/snapshots/app_amd64_layers_listing.yaml

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/cases/uv-deps-650/crossbuild/snapshots/app_arm64_layers_listing.yaml

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

py/private/py_venv/templates/_virtualenv.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@ class _Distribution(Protocol):
1818
def get_option_dict(self, command: str) -> MutableMapping[str, Tuple[str, str]]: ...
1919

2020

21-
# Make wheel-declared console scripts reachable via `subprocess.run("name", ...)`.
22-
# Use dirname(sys.executable) so this works on Windows too, where the scripts
23-
# dir is `Scripts/` rather than `bin/`.
24-
_venv_bin = os.path.dirname(sys.executable)
25-
if _venv_bin not in os.environ.get("PATH", "").split(os.pathsep):
26-
os.environ["PATH"] = _venv_bin + os.pathsep + os.environ.get("PATH", "")
27-
del _venv_bin
28-
2921
VIRTUALENV_PATCH_FILE = os.path.join(__file__)
3022

3123

0 commit comments

Comments
 (0)