From ebd73d83f887103e28b74a1937d0ceb5a03c1ebf Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Wed, 11 Sep 2024 14:41:42 -0500 Subject: [PATCH] Allow explicitly requesting an system interpreter version in `check_system_python` (#7306) Needed for #7300 --- .github/workflows/ci.yml | 2 +- scripts/check_system_python.py | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9fb218abf..034c384d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/scripts/check_system_python.py b/scripts/check_system_python.py index acbed031f..cbed51605 100755 --- a/scripts/check_system_python.py +++ b/scripts/check_system_python.py @@ -47,12 +47,18 @@ if __name__ == "__main__": 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: @@ -69,7 +75,8 @@ if __name__ == "__main__": 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, ) @@ -94,7 +101,9 @@ if __name__ == "__main__": # 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, )