Skip to content

Commit e57b68d

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 47171d7 commit e57b68d

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
@@ -3,14 +3,6 @@
33
import os
44
import sys
55

6-
# Make wheel-declared console scripts reachable via `subprocess.run("name", ...)`.
7-
# Use dirname(sys.executable) so this works on Windows too, where the scripts
8-
# dir is `Scripts/` rather than `bin/`.
9-
_venv_bin = os.path.dirname(sys.executable)
10-
if _venv_bin not in os.environ.get("PATH", "").split(os.pathsep):
11-
os.environ["PATH"] = _venv_bin + os.pathsep + os.environ.get("PATH", "")
12-
del _venv_bin
13-
146
VIRTUALENV_PATCH_FILE = os.path.join(__file__)
157

168

0 commit comments

Comments
 (0)