@@ -37,8 +37,7 @@ export PIP_QUIET=1  # Quiet by default
3737export  PIP_PREFER_BINARY=1 #  Prefer binary dists by default
3838
3939set  +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())" ) 
4241
4342#  Try to source local Drivers Secrets
4443if  [ -f  ./secrets-export.sh ];  then 
4847  echo  " Not sourcing secrets" 
4948fi 
5049
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.
5255if  [ -z  " ${NO_EXT:- } " &&  [ " $PYTHON_IMPL " =  " CPython" ;  then 
53-     python  tools/fail_if_no_c.py
56+     uv run  tools/fail_if_no_c.py
5457fi 
5558
5659if  [ " $AUTH " !=  " noauth" ;  then 
@@ -77,7 +80,7 @@ if [ "$AUTH" != "noauth" ]; then
7780fi 
7881
7982if  [ -n  " $TEST_ENTERPRISE_AUTH " ;  then 
80-     python -m pip install  ' .[ gssapi] ' 
83+     UV_ARGS+=( " --extra  gssapi" ) 
8184    if  [ " Windows_NT" =  " $OS " ;  then 
8285        echo  " Setting GSSAPI_PASS" 
8386        export  GSSAPI_PASS=${SASL_PASS} 
@@ -118,24 +121,26 @@ if [ "$SSL" != "nossl" ]; then
118121fi 
119122
120123if  [ " $COMPRESSORS " =  " snappy" ;  then 
121-     python -m pip install  ' .[ snappy] ' 
124+     UV_ARGS+=( " --extra  snappy" ) 
122125elif  [ " $COMPRESSORS " =  " zstd" ;  then 
123-     python -m pip install  zstandard
126+     UV_ARGS+=( " --extra  zstandard" ) 
124127fi 
125128
126129#  PyOpenSSL test setup.
127130if  [ -n  " $TEST_PYOPENSSL " ;  then 
128-     python -m pip install  ' .[ ocsp] ' 
131+     UV_ARGS+=( " --extra  ocsp" ) 
129132fi 
130133
131134if  [ -n  " $TEST_ENCRYPTION " ||  [ -n  " $TEST_FLE_AZURE_AUTO " ||  [ -n  " $TEST_FLE_GCP_AUTO " ;  then 
132-     #  Check for libmongocrypt checkout .
135+     #  Check for libmongocrypt download .
133136    if  [ !  -d  " libmongocrypt" ;  then 
134137        echo  " Run encryption setup first!" 
135138        exit  1
136139    fi 
137140
138-     python -m pip install ' .[encryption]' 
141+     UV_ARGS+=(" --extra encryption" 
142+     #  TODO: Test with 'pip install pymongocrypt'
143+     UV_ARGS+=(" --group pymongocrypt_source" 
139144
140145    #  Use the nocrypto build to avoid dependency issues with older windows/python versions.
141146    BASE=$( pwd) 
@@ -155,21 +160,17 @@ if [ -n "$TEST_ENCRYPTION" ] || [ -n "$TEST_FLE_AZURE_AUTO" ] || [ -n "$TEST_FLE
155160        exit  1
156161    fi 
157162    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.
168169fi 
169170
170171if  [ -n  " $TEST_ENCRYPTION " ;  then 
171172    if  [ -n  " $TEST_ENCRYPTION_PYOPENSSL " ;  then 
172-         python -m pip install  ' .[ ocsp] ' 
173+         UV_ARGS+=( " --extra  ocsp" ) 
173174    fi 
174175
175176    if  [ -n  " $TEST_CRYPT_SHARED " ;  then 
@@ -214,31 +215,31 @@ if [ -n "$TEST_ATLAS" ]; then
214215fi 
215216
216217if  [ -n  " $TEST_OCSP " ;  then 
217-     python -m pip install  " .[ ocsp] " 
218+     UV_ARGS+=( " --extra  ocsp" ) 
218219    TEST_SUITES=" ocsp" 
219220fi 
220221
221222if  [ -n  " $TEST_AUTH_AWS " ;  then 
222-     python -m pip install  " .[ aws] " 
223+     UV_ARGS+=( " --extra  aws" ) 
223224    TEST_SUITES=" auth_aws" 
224225fi 
225226
226227if  [ -n  " $TEST_AUTH_OIDC " ;  then 
227-     python -m pip install  " .[ aws] " 
228+     UV_ARGS+=( " --extra  aws" ) 
228229    TEST_SUITES=" auth_oidc" 
229230fi 
230231
231232if  [ -n  " $PERF_TEST " ;  then 
232-     python -m pip install simplejson 
233+     UV_ARGS+=( " --group perf " ) 
233234    start_time=$( date +%s) 
234235    TEST_SUITES=" perf" 
235236    #  PYTHON-4769 Run perf_test.py directly otherwise pytest's test collection negatively
236237    #  affects the benchmark results.
237238    TEST_ARGS=" test/performance/perf_test.py $TEST_ARGS " 
238239fi 
239240
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)' 
242243
243244
244245#  Run the tests, and store the results in Evergreen compatible XUnit XML
@@ -249,27 +250,30 @@ python -c 'import sys; print(sys.version)'
249250if  [ -n  " $COVERAGE " &&  [ " $PYTHON_IMPL " =  " CPython" ;  then 
250251    #  Keep in sync with combine-coverage.sh.
251252    #  coverage >=5 is needed for relative_files=true.
252-     python -m pip install pytest-cov  " coverage>=5,<=7.5 " 
253+     UV_ARGS+=( " --group  coverage" ) 
253254    TEST_ARGS=" $TEST_ARGS  --cov" 
254255fi 
255256
256257if  [ -n  " $GREEN_FRAMEWORK " ;  then 
257-     python -m pip install  $GREEN_FRAMEWORK 
258+     UV_ARGS+=( " --group  $GREEN_FRAMEWORK " ) 
258259fi 
259260
260261#  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
262264
263265if  [ -z  " $GREEN_FRAMEWORK " ;  then 
264266    #  Use --capture=tee-sys so pytest prints test output inline:
265267    #  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 " 
270271    fi 
272+     #  shellcheck disable=SC2048
273+     uv run ${UV_ARGS[*]}  pytest $PYTEST_ARGS 
271274else 
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 
273277fi 
274278
275279#  Handle perf test post actions.
0 commit comments