Skip to content

Commit

Permalink
Allow explicitly requesting an system interpreter version in `check_s…
Browse files Browse the repository at this point in the history
…ystem_python` (#7306)

Needed for #7300
  • Loading branch information
zanieb authored Sep 11, 2024
1 parent bb0fb8e commit ebd73d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ jobs:
run: echo $(which python)

- name: "Validate global Python install"
run: py -3.13 ./scripts/check_system_python.py --uv ./uv.exe
run: py -3.13 ./scripts/check_system_python.py --uv ./uv.exe --python 3.13

system-test-choco:
timeout-minutes: 10
Expand Down
13 changes: 11 additions & 2 deletions scripts/check_system_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,18 @@ def install_package(*, uv: str, package: str):
action="store_true",
help="Set if the Python installation has an EXTERNALLY-MANAGED marker.",
)
parser.add_argument(
"--python",
required=False,
help="Set if the system Python version must be explicitly specified, e.g., for prereleases.",
)
args = parser.parse_args()

uv: str = os.path.abspath(args.uv) if args.uv else "uv"
allow_externally_managed = (
["--break-system-packages"] if args.externally_managed else []
)
python = ["--python", args.python] if args.python else []

# Create a temporary directory.
with tempfile.TemporaryDirectory() as temp_dir:
Expand All @@ -69,7 +75,8 @@ def install_package(*, uv: str, package: str):
logging.info("Installing the package `pylint`.")
subprocess.run(
[uv, "pip", "install", "pylint", "--system", "--verbose"]
+ allow_externally_managed,
+ allow_externally_managed
+ python,
cwd=temp_dir,
check=True,
)
Expand All @@ -94,7 +101,9 @@ def install_package(*, uv: str, package: str):
# Uninstall the package (`pylint`).
logging.info("Uninstalling the package `pylint`.")
subprocess.run(
[uv, "pip", "uninstall", "pylint", "--system"] + allow_externally_managed,
[uv, "pip", "uninstall", "pylint", "--system"]
+ allow_externally_managed
+ python,
cwd=temp_dir,
check=True,
)
Expand Down

0 comments on commit ebd73d8

Please sign in to comment.