Skip to content

Commit d8c9b3c

Browse files
authored
fix Python tasks on distros with too-old Python (part 2) (#1252)
1 parent 7f0c876 commit d8c9b3c

2 files changed

Lines changed: 15 additions & 25 deletions

File tree

‎bindings/python/.evergreen/integ-test.sh‎

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,15 @@ MONGOCRYPT_DIR="$MONGOCRYPT_DIR"
1111
CRYPT_SHARED_DIR="$DRIVERS_TOOLS"
1212
MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
1313

14-
# Use the latest toolchain Python.
14+
# Use the latest toolchain Python, if any qualifies.
1515
PYTHON=$(find_pythons | tail -1)
16-
if [ -z "$PYTHON" ]; then
17-
echo "No Python interpreter found!"
18-
exit 1
19-
fi
2016

21-
# pymongo (unreleased master) requires Python 3.11+. Some distros (e.g.
22-
# rhel82) only provide older interpreters, so provision one with uv.
23-
if ! "$PYTHON" -c 'import sys; sys.exit(sys.version_info < (3, 11))'; then
24-
if ! command -v uv >/dev/null 2>&1; then
25-
"$PYTHON" -m pip install --user uv
26-
fi
17+
# pymongo (unreleased master) requires Python 3.11+ (PYTHON-6138). Some
18+
# distros (e.g. rhel82) only provide older interpreters, or none at all
19+
# now that find_pythons requires 3.11+, so provision one with uv.
20+
if [ -z "$PYTHON" ] || ! "$PYTHON" -c 'import sys; sys.exit(sys.version_info < (3, 11))'; then
21+
. "${DRIVERS_TOOLS}/.evergreen/ensure-uv.sh"
22+
ensure_uv
2723
uv python install 3.11
2824
PYTHON=$(uv python find 3.11)
2925
echo "Using uv-provisioned Python: $PYTHON"
@@ -36,18 +32,8 @@ else
3632
fi
3733
export PYMONGOCRYPT_LIB
3834

39-
# PyMongo master requires Python 3.11+ (PYTHON-6138), but the newest
40-
# interpreter on some distros is the MongoDB toolchain Python 3.10 (e.g.
41-
# rhel-82-arm64). Provision a modern interpreter with uv in that case.
42-
if "$PYTHON" -c 'import sys; sys.exit(0 if sys.version_info >= (3, 11) else 1)'; then
43-
createvirtualenv $PYTHON .venv
44-
else
45-
. "${DRIVERS_TOOLS}/.evergreen/ensure-uv.sh"
46-
ensure_uv
47-
uv python install 3.13
48-
uv venv --seed --python 3.13 .venv
49-
. .venv/bin/activate
50-
fi
35+
# $PYTHON is guaranteed to be Python 3.11+ at this point.
36+
createvirtualenv $PYTHON .venv
5137
pip install -e .
5238
pip install uv
5339
pushd $PYMONGO_DIR

‎bindings/python/.evergreen/test.sh‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ ensure_uv || exit 1
2121
# Discover the toolchain pythons to test against.
2222
PYTHONS=($(find_pythons))
2323
if [ ${#PYTHONS[@]} -eq 0 ]; then
24-
echo "No Python interpreters found to test with!"
25-
exit 1
24+
# No Python 3.11+ interpreter exists on this distro (e.g. rhel-82-arm64's
25+
# toolchain tops out at 3.10): provision one with uv. ensure_uv has
26+
# already run above.
27+
uv python install 3.11
28+
PYTHONS=($(uv python find 3.11))
29+
echo "Provisioned Python 3.11 with uv: ${PYTHONS[*]}"
2630
fi
2731
echo "Testing with pythons: ${PYTHONS[*]}"
2832

0 commit comments

Comments
 (0)