Skip to content

Commit 5c6013c

Browse files
committed
TOOLS-4102 Use mise to manage our Python install
This also adds a `requirements.txt` file with the Python packages we need.
1 parent f5d92f4 commit 5c6013c

5 files changed

Lines changed: 20 additions & 47 deletions

File tree

common.yml

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -491,28 +491,9 @@ functions:
491491
# The aws_e2e_assume_role script requires python3 with boto3.
492492
# Set up or use an existing python virtualenv for boto3.
493493
venv='venv'
494-
venvNonWindows () { . "$venv"/bin/activate; python3 -m pip install boto3; }
495-
venvWindows () { . "$venv"/Scripts/activate; pip install boto3; }
496-
497-
# default to python3 inside mongodbtoolchain
498-
PATH=/opt/mongodbtoolchain/v3/bin/:$PATH
499-
500-
if [ -f "$venv"/bin/activate ]; then
501-
echo 'activating existing virtualenv'
502-
venvNonWindows
503-
elif [ -f "$venv"/Scripts/activate ]; then
504-
echo 'activating existing virtualenv'
505-
venvWindows
506-
elif virtualenv "$venv" || python -m virtualenv "$venv"; then
507-
echo 'creating new virtualenv'
508-
if [ -f "$venv"/bin/activate ]; then
509-
echo 'activating new virtualenv'
510-
venvNonWindows
511-
elif [ -f "$venv"/Scripts/activate ]; then
512-
echo 'activating new virtualenv'
513-
venvWindows
514-
fi
515-
fi
494+
mise exec python -- python3 -m venv "$venv"
495+
. "$venv"/bin/activate
496+
pip install boto3
516497
517498
pip list
518499
@@ -528,8 +509,9 @@ functions:
528509
set -v
529510
set -e
530511
512+
# There's no need to use mise here, since this will work with any version of Python.
531513
jsonkey () { python -c "import sys, json; sys.stdout.write(json.load(sys.stdin)['$1'])" < creds.json; }
532-
urlencode () { python -c "import sys, urllib as ul; sys.stdout.write(ul.quote_plus('$1'))"; }
514+
urlencode () { python -c "import sys, urllib.parse as ul; sys.stdout.write(ul.quote_plus('$1'))"; }
533515
534516
USER=$(jsonkey AccessKeyId)
535517
USER=$(urlencode $USER)
@@ -655,8 +637,6 @@ pre:
655637
- command: expansions.update
656638
params:
657639
updates:
658-
- key: python
659-
value: "/opt/mongodbtoolchain/v4/bin/python3"
660640
- key: resmoke_dir
661641
value: "src/resmoke"
662642
- key: resmoke_venv_dir

mise.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ node = "22.22.0"
1919
"npm:prettier" = "3.4.2"
2020
"npm:github-codeowners" = "0.2.1"
2121

22+
# Python
23+
python = "3.12.9"
24+
2225
[settings.node]
2326
# We turn off GPG verification for node because it has been flaky in CI, and also requires a local
2427
# GPG public key.

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
boto3
2+
pymongo==3.12.1
3+
pywin32; sys_platform == "win32"
4+
pyyaml

scripts/run_native_cert_ssl.sh

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,7 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
1515
sudo security add-trusted-cert -d -k /Library/Keychains/System.keychain jstests/libs/trusted-ca.pem
1616
fi
1717

18-
PATH=/opt/mongodbtoolchain/v3/bin/:$PATH
19-
python="python3"
20-
if [ "Windows_NT" = "$OS" ]; then
21-
python="py.exe -3"
22-
fi
23-
$python -m venv venv
24-
pip3 install pymongo==3.12.1 pyyaml
25-
if [ "Windows_NT" = "$OS" ]; then
26-
pip3 install pywin32
27-
fi
28-
$python buildscripts/resmoke.py --suite=native_cert_ssl --continueOnFailure --log=buildlogger --reportFile=../../report.json ${resmoke_args} --excludeWithAnyTags="${excludes}"
18+
mise exec python -- python3 -m venv venv
19+
. venv/bin/activate
20+
pip install -r ../../requirements.txt
21+
python3 buildscripts/resmoke.py --suite=native_cert_ssl --continueOnFailure --log=buildlogger --reportFile=../../report.json ${resmoke_args} --excludeWithAnyTags="${excludes}"

scripts/run_qa.sh

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,7 @@ mv bin/* test/qa-tests/
99
cd test/qa-tests
1010
chmod 400 jstests/libs/key*
1111

12-
PATH=/opt/mongodbtoolchain/v3/bin/:$PATH
13-
python="python3"
14-
if [ "Windows_NT" = "$OS" ]; then
15-
python="py.exe -3"
16-
fi
17-
$python -m venv venv
18-
pip3 install pymongo==3.12.1 pyyaml
19-
if [ "Windows_NT" = "$OS" ]; then
20-
pip3 install pywin32
21-
fi
22-
$python buildscripts/resmoke.py --suite=${resmoke_suite} --continueOnFailure --log=buildlogger --reportFile=../../report.json ${resmoke_args} --excludeWithAnyTags="${excludes}"
12+
mise exec python -- python3 -m venv venv
13+
. venv/bin/activate
14+
pip install -r ../../requirements.txt
15+
python3 buildscripts/resmoke.py --suite=${resmoke_suite} --continueOnFailure --log=buildlogger --reportFile=../../report.json ${resmoke_args} --excludeWithAnyTags="${excludes}"

0 commit comments

Comments
 (0)