@@ -37,8 +37,7 @@ export PIP_QUIET=1 # Quiet by default
37
37
export PIP_PREFER_BINARY=1 # Prefer binary dists by default
38
38
39
39
set +x
40
- python -c " import sys; sys.exit(sys.prefix == sys.base_prefix)" || (echo " Not inside a virtual env!" ; exit 1)
41
- PYTHON_IMPL=$( python -c " import platform; print(platform.python_implementation())" )
40
+ PYTHON_IMPL=$( uv run python -c " import platform; print(platform.python_implementation())" )
42
41
43
42
# Try to source local Drivers Secrets
44
43
if [ -f ./secrets-export.sh ]; then
48
47
echo " Not sourcing secrets"
49
48
fi
50
49
51
- # Ensure C extensions have compiled.
50
+ # Start compiling the args we'll pass to uv.
51
+ # Run in an isolated environment so as not to pollute the base venv.
52
+ UV_ARGS=(" --isolated --extra test" )
53
+
54
+ # Ensure C extensions if applicable.
52
55
if [ -z " ${NO_EXT:- } " ] && [ " $PYTHON_IMPL " = " CPython" ]; then
53
- python tools/fail_if_no_c.py
56
+ uv run tools/fail_if_no_c.py
54
57
fi
55
58
56
59
if [ " $AUTH " != " noauth" ]; then
@@ -77,7 +80,7 @@ if [ "$AUTH" != "noauth" ]; then
77
80
fi
78
81
79
82
if [ -n " $TEST_ENTERPRISE_AUTH " ]; then
80
- python -m pip install ' .[ gssapi] '
83
+ UV_ARGS+=( " --extra gssapi" )
81
84
if [ " Windows_NT" = " $OS " ]; then
82
85
echo " Setting GSSAPI_PASS"
83
86
export GSSAPI_PASS=${SASL_PASS}
@@ -118,24 +121,26 @@ if [ "$SSL" != "nossl" ]; then
118
121
fi
119
122
120
123
if [ " $COMPRESSORS " = " snappy" ]; then
121
- python -m pip install ' .[ snappy] '
124
+ UV_ARGS+=( " --extra snappy" )
122
125
elif [ " $COMPRESSORS " = " zstd" ]; then
123
- python -m pip install zstandard
126
+ UV_ARGS+=( " --extra zstandard" )
124
127
fi
125
128
126
129
# PyOpenSSL test setup.
127
130
if [ -n " $TEST_PYOPENSSL " ]; then
128
- python -m pip install ' .[ ocsp] '
131
+ UV_ARGS+=( " --extra ocsp" )
129
132
fi
130
133
131
134
if [ -n " $TEST_ENCRYPTION " ] || [ -n " $TEST_FLE_AZURE_AUTO " ] || [ -n " $TEST_FLE_GCP_AUTO " ]; then
132
- # Check for libmongocrypt checkout .
135
+ # Check for libmongocrypt download .
133
136
if [ ! -d " libmongocrypt" ]; then
134
137
echo " Run encryption setup first!"
135
138
exit 1
136
139
fi
137
140
138
- python -m pip install ' .[encryption]'
141
+ UV_ARGS+=(" --extra encryption" )
142
+ # TODO: Test with 'pip install pymongocrypt'
143
+ UV_ARGS+=(" --group pymongocrypt_source" )
139
144
140
145
# Use the nocrypto build to avoid dependency issues with older windows/python versions.
141
146
BASE=$( pwd) /libmongocrypt/nocrypto
@@ -155,21 +160,17 @@ if [ -n "$TEST_ENCRYPTION" ] || [ -n "$TEST_FLE_AZURE_AUTO" ] || [ -n "$TEST_FLE
155
160
exit 1
156
161
fi
157
162
export PYMONGOCRYPT_LIB
158
-
159
- # TODO: Test with 'pip install pymongocrypt'
160
- if [ ! -d " libmongocrypt_git" ]; then
161
- git clone https://github.com/mongodb/libmongocrypt.git libmongocrypt_git
162
- fi
163
- python -m pip install -U setuptools
164
- python -m pip install ./libmongocrypt_git/bindings/python
165
- python -c " import pymongocrypt; print('pymongocrypt version: '+pymongocrypt.__version__)"
166
- python -c " import pymongocrypt; print('libmongocrypt version: '+pymongocrypt.libmongocrypt_version())"
167
- # PATH is updated by PREPARE_SHELL for access to mongocryptd.
163
+ # Ensure pymongocrypt is working properly.
164
+ # shellcheck disable=SC2048
165
+ uv run ${UV_ARGS[*]} python -c " import pymongocrypt; print('pymongocrypt version: '+pymongocrypt.__version__)"
166
+ # shellcheck disable=SC2048
167
+ uv run ${UV_ARGS[*]} python -c " import pymongocrypt; print('libmongocrypt version: '+pymongocrypt.libmongocrypt_version())"
168
+ # PATH is updated by configure-env.sh for access to mongocryptd.
168
169
fi
169
170
170
171
if [ -n " $TEST_ENCRYPTION " ]; then
171
172
if [ -n " $TEST_ENCRYPTION_PYOPENSSL " ]; then
172
- python -m pip install ' .[ ocsp] '
173
+ UV_ARGS+=( " --extra ocsp" )
173
174
fi
174
175
175
176
if [ -n " $TEST_CRYPT_SHARED " ]; then
@@ -214,31 +215,31 @@ if [ -n "$TEST_ATLAS" ]; then
214
215
fi
215
216
216
217
if [ -n " $TEST_OCSP " ]; then
217
- python -m pip install " .[ ocsp] "
218
+ UV_ARGS+=( " --extra ocsp" )
218
219
TEST_SUITES=" ocsp"
219
220
fi
220
221
221
222
if [ -n " $TEST_AUTH_AWS " ]; then
222
- python -m pip install " .[ aws] "
223
+ UV_ARGS+=( " --extra aws" )
223
224
TEST_SUITES=" auth_aws"
224
225
fi
225
226
226
227
if [ -n " $TEST_AUTH_OIDC " ]; then
227
- python -m pip install " .[ aws] "
228
+ UV_ARGS+=( " --extra aws" )
228
229
TEST_SUITES=" auth_oidc"
229
230
fi
230
231
231
232
if [ -n " $PERF_TEST " ]; then
232
- python -m pip install simplejson
233
+ UV_ARGS+=( " --group perf " )
233
234
start_time=$( date +%s)
234
235
TEST_SUITES=" perf"
235
236
# PYTHON-4769 Run perf_test.py directly otherwise pytest's test collection negatively
236
237
# affects the benchmark results.
237
238
TEST_ARGS=" test/performance/perf_test.py $TEST_ARGS "
238
239
fi
239
240
240
- echo " Running $AUTH tests over $SSL with python $( which python) "
241
- python -c ' import sys; print(sys.version)'
241
+ echo " Running $AUTH tests over $SSL with python $( uv python find ) "
242
+ uv run python -c ' import sys; print(sys.version)'
242
243
243
244
244
245
# Run the tests, and store the results in Evergreen compatible XUnit XML
@@ -249,27 +250,30 @@ python -c 'import sys; print(sys.version)'
249
250
if [ -n " $COVERAGE " ] && [ " $PYTHON_IMPL " = " CPython" ]; then
250
251
# Keep in sync with combine-coverage.sh.
251
252
# coverage >=5 is needed for relative_files=true.
252
- python -m pip install pytest-cov " coverage>=5,<=7.5 "
253
+ UV_ARGS+=( " --group coverage" )
253
254
TEST_ARGS=" $TEST_ARGS --cov"
254
255
fi
255
256
256
257
if [ -n " $GREEN_FRAMEWORK " ]; then
257
- python -m pip install $GREEN_FRAMEWORK
258
+ UV_ARGS+=( " --group $GREEN_FRAMEWORK " )
258
259
fi
259
260
260
261
# Show the installed packages
261
- PIP_QUIET=0 python -m pip list
262
+ # shellcheck disable=SC2048
263
+ PIP_QUIET=0 uv run ${UV_ARGS[*]} --with pip pip list
262
264
263
265
if [ -z " $GREEN_FRAMEWORK " ]; then
264
266
# Use --capture=tee-sys so pytest prints test output inline:
265
267
# https://docs.pytest.org/en/stable/how-to/capture-stdout-stderr.html
266
- if [ -z " $TEST_SUITES " ]; then
267
- python -m pytest -v --capture=tee-sys --durations=5 $TEST_ARGS
268
- else
269
- python -m pytest -v --capture=tee-sys --durations=5 -m $TEST_SUITES $TEST_ARGS
268
+ PYTEST_ARGS=" -v --capture=tee-sys --durations=5 $TEST_ARGS "
269
+ if [ -n " $TEST_SUITES " ]; then
270
+ PYTEST_ARGS=" -m $TEST_SUITES $PYTEST_ARGS "
270
271
fi
272
+ # shellcheck disable=SC2048
273
+ uv run ${UV_ARGS[*]} pytest $PYTEST_ARGS
271
274
else
272
- python green_framework_test.py $GREEN_FRAMEWORK -v $TEST_ARGS
275
+ # shellcheck disable=SC2048
276
+ uv run ${UV_ARGS[*]} green_framework_test.py $GREEN_FRAMEWORK -v $TEST_ARGS
273
277
fi
274
278
275
279
# Handle perf test post actions.
0 commit comments