File tree Expand file tree Collapse file tree 3 files changed +22
-13
lines changed Expand file tree Collapse file tree 3 files changed +22
-13
lines changed Original file line number Diff line number Diff line change 33set -o xtrace
44set -o errexit
55
6+ . .evergreen/utils.sh
7+
68${PYTHON_BINARY} setup.py clean
79cd ..
8- ${PYTHON_BINARY} -m virtualenv mockuptests
9- . mockuptests/bin/activate
10- trap " deactivate " EXIT HUP
10+
11+ createvirtualenv ${PYTHON_BINARY} mockuptests
12+ trap " deactivatei, rm -rf mockuptests " EXIT HUP
1113
1214# Install PyMongo from git clone so mockup-tests don't
1315# download it from pypi.
Original file line number Diff line number Diff line change @@ -75,15 +75,13 @@ if [ -z "$PYTHON_BINARY" ]; then
7575 echo " Cannot test without python3.6+ installed!"
7676 fi
7777elif [ " $COMPRESSORS " = " snappy" ]; then
78- $PYTHON_BINARY -m virtualenv --never-download snappytest
79- . snappytest/bin/activate
78+ createvirtualenv $PYTHON_BINARY snappytest
8079 trap " deactivate; rm -rf snappytest" EXIT HUP
8180 # 0.5.2 has issues in pypy3(.5)
8281 pip install python-snappy==0.5.1
8382 PYTHON=python
8483elif [ " $COMPRESSORS " = " zstd" ]; then
85- $PYTHON_BINARY -m virtualenv --never-download zstdtest
86- . zstdtest/bin/activate
84+ createvirtualenv $PYTHON_BINARY zstdtest
8785 trap " deactivate; rm -rf zstdtest" EXIT HUP
8886 pip install zstandard
8987 PYTHON=python
@@ -106,7 +104,6 @@ if [ -n "$TEST_ENCRYPTION" ]; then
106104 PYTHON=python
107105
108106 if [ " Windows_NT" = " $OS " ]; then # Magic variable in cygwin
109- $PYTHON -m pip install -U setuptools
110107 # PYTHON-2808 Ensure this machine has the CA cert for google KMS.
111108 powershell.exe " Invoke-WebRequest -URI https://oauth2.googleapis.com/" > /dev/null || true
112109 fi
Original file line number Diff line number Diff line change 11#! /bin/bash -ex
22
3+ set -o xtrace
4+
35# Usage:
46# createvirtualenv /path/to/python /output/path/for/venv
57# * param1: Python binary to use for the virtualenv
68# * param2: Path to the virtualenv to create
79createvirtualenv () {
810 PYTHON=$1
911 VENVPATH=$2
10- if $PYTHON -m virtualenv --version; then
11- VIRTUALENV=" $PYTHON -m virtualenv --never-download"
12- elif $PYTHON -m venv -h> /dev/null; then
12+ if $PYTHON -m venv -h> /dev/null; then
1313 # System virtualenv might not be compatible with the python3 on our path
1414 VIRTUALENV=" $PYTHON -m venv"
15+ elif $PYTHON -m virtualenv --version; then
16+ VIRTUALENV=" $PYTHON -m virtualenv"
1517 else
1618 echo " Cannot test without virtualenv"
1719 exit 1
1820 fi
1921 $VIRTUALENV $VENVPATH
2022 if [ " Windows_NT" = " $OS " ]; then
23+ # Workaround https://bugs.python.org/issue32451:
24+ # mongovenv/Scripts/activate: line 3: $'\r': command not found
25+ dos2unix $VENVPATH /Scripts/activate || true
2126 . $VENVPATH /Scripts/activate
2227 else
2328 . $VENVPATH /bin/activate
2429 fi
25- python -m pip install --upgrade pip
26- python -m pip install --upgrade setuptools wheel
30+
31+ PYVER=$( ${PYTHON} -c " import sys; sys.stdout.write('.'.join(str(val) for val in sys.version_info[:2]))" )
32+ # pip fails to upgrade in a Python 3.6 venv on Windows.
33+ if [ $PYVER != " 3.6" -o " Windows_NT" != " $OS " ] ; then
34+ python -m pip install --upgrade pip
35+ python -m pip install --upgrade setuptools wheel
36+ fi
2737}
2838
2939# Usage:
You can’t perform that action at this time.
0 commit comments