diff --git a/bindings/python/.evergreen/integ-test.sh b/bindings/python/.evergreen/integ-test.sh index c666807be..17311e29f 100755 --- a/bindings/python/.evergreen/integ-test.sh +++ b/bindings/python/.evergreen/integ-test.sh @@ -11,19 +11,15 @@ MONGOCRYPT_DIR="$MONGOCRYPT_DIR" CRYPT_SHARED_DIR="$DRIVERS_TOOLS" MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin" -# Use the latest toolchain Python. +# Use the latest toolchain Python, if any qualifies. PYTHON=$(find_pythons | tail -1) -if [ -z "$PYTHON" ]; then - echo "No Python interpreter found!" - exit 1 -fi -# pymongo (unreleased master) requires Python 3.11+. Some distros (e.g. -# rhel82) only provide older interpreters, so provision one with uv. -if ! "$PYTHON" -c 'import sys; sys.exit(sys.version_info < (3, 11))'; then - if ! command -v uv >/dev/null 2>&1; then - "$PYTHON" -m pip install --user uv - fi +# pymongo (unreleased master) requires Python 3.11+ (PYTHON-6138). Some +# distros (e.g. rhel82) only provide older interpreters, or none at all +# now that find_pythons requires 3.11+, so provision one with uv. +if [ -z "$PYTHON" ] || ! "$PYTHON" -c 'import sys; sys.exit(sys.version_info < (3, 11))'; then + . "${DRIVERS_TOOLS}/.evergreen/ensure-uv.sh" + ensure_uv uv python install 3.11 PYTHON=$(uv python find 3.11) echo "Using uv-provisioned Python: $PYTHON" @@ -36,18 +32,8 @@ else fi export PYMONGOCRYPT_LIB -# PyMongo master requires Python 3.11+ (PYTHON-6138), but the newest -# interpreter on some distros is the MongoDB toolchain Python 3.10 (e.g. -# rhel-82-arm64). Provision a modern interpreter with uv in that case. -if "$PYTHON" -c 'import sys; sys.exit(0 if sys.version_info >= (3, 11) else 1)'; then - createvirtualenv $PYTHON .venv -else - . "${DRIVERS_TOOLS}/.evergreen/ensure-uv.sh" - ensure_uv - uv python install 3.13 - uv venv --seed --python 3.13 .venv - . .venv/bin/activate -fi +# $PYTHON is guaranteed to be Python 3.11+ at this point. +createvirtualenv $PYTHON .venv pip install -e . pip install uv pushd $PYMONGO_DIR diff --git a/bindings/python/.evergreen/test.sh b/bindings/python/.evergreen/test.sh index b3953ddf5..601018f28 100755 --- a/bindings/python/.evergreen/test.sh +++ b/bindings/python/.evergreen/test.sh @@ -21,8 +21,12 @@ ensure_uv || exit 1 # Discover the toolchain pythons to test against. PYTHONS=($(find_pythons)) if [ ${#PYTHONS[@]} -eq 0 ]; then - echo "No Python interpreters found to test with!" - exit 1 + # No Python 3.11+ interpreter exists on this distro (e.g. rhel-82-arm64's + # toolchain tops out at 3.10): provision one with uv. ensure_uv has + # already run above. + uv python install 3.11 + PYTHONS=($(uv python find 3.11)) + echo "Provisioned Python 3.11 with uv: ${PYTHONS[*]}" fi echo "Testing with pythons: ${PYTHONS[*]}"