From ad1db9a705805e1ecbbec16fd078384bf33fef64 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 23 Nov 2026 12:05:10 -0600 Subject: [PATCH] PYTHON-6286 Make setup_uv.py Python 3.6 compatible --- .evergreen/scripts/setup_uv.py | 5 ++--- .evergreen/scripts/test_setup_uv.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.evergreen/scripts/setup_uv.py b/.evergreen/scripts/setup_uv.py index a7d3832a7a..277ee52b86 100755 --- a/.evergreen/scripts/setup_uv.py +++ b/.evergreen/scripts/setup_uv.py @@ -10,11 +10,10 @@ elsewhere on PATH may be invisible to later steps, so setup never accepts it as-is. -This runs under the host's system python3, which may be older than our minimum supported version. +This runs under the host's system python3, which may be as old as Python 3.6 (RHEL 8). +Keep it free of __future__ imports and other 3.7+ syntax. test_setup_uv.py checks this. """ -from __future__ import annotations - import os import re import shlex diff --git a/.evergreen/scripts/test_setup_uv.py b/.evergreen/scripts/test_setup_uv.py index d16052e481..47fafd1a92 100644 --- a/.evergreen/scripts/test_setup_uv.py +++ b/.evergreen/scripts/test_setup_uv.py @@ -10,6 +10,7 @@ from __future__ import annotations +import ast import importlib.util import os import shutil @@ -521,3 +522,17 @@ def test_main_pinned_self_overwrite_runs_from_copy(tmp_path, project): assert proc.returncode == 0, proc.stderr assert (bin_dir / "uv").exists() assert f"installed-from=uv{PIN}\n" in log.read_text() + + +def test_setup_uv_supports_python_36(): + """setup_uv.py runs under the host's system python3, 3.6 on RHEL8 (PYTHON-6286).""" + # feature_version checks grammar only; it does not validate __future__ + # feature names, so scan for those imports explicitly. + tree = ast.parse(SETUP_UV.read_text(), filename=str(SETUP_UV), feature_version=(3, 6)) + futures = [ + alias.name + for node in ast.walk(tree) + if isinstance(node, ast.ImportFrom) and node.module == "__future__" + for alias in node.names + ] + assert not futures, f"Python 3.6 rejects these __future__ imports: {futures}"