From 2157dc58ea07e033760bcc81fee386f9f879edd2 Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Tue, 3 Mar 2020 11:55:43 -0800 Subject: [PATCH] PYTHON-2148 Test PyOpenSSL support on Windows --- .evergreen/config.yml | 34 ++++++++++++++++++++++++------- .evergreen/run-ocsp-tests.sh | 28 ++++++++++++++++++++++--- .evergreen/run-pyopenssl-tests.sh | 25 +++++++++++++++++++++-- 3 files changed, 75 insertions(+), 12 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 774a84bed..2bea80c42 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -1288,6 +1288,12 @@ axes: batchtime: 10080 # 7 days variables: libmongocrypt_url: https://s3.amazonaws.com/mciuploads/libmongocrypt/windows-test/master/latest/libmongocrypt.tar.gz + - id: windows-64-vsMulti-small + display_name: "Windows 64" + run_on: windows-64-vsMulti-small + batchtime: 10080 # 7 days + variables: + libmongocrypt_url: https://s3.amazonaws.com/mciuploads/libmongocrypt/windows-test/master/latest/libmongocrypt.tar.gz # Test with authentication? - id: auth @@ -1399,23 +1405,27 @@ axes: - id: "win-vs2010-3.4" display_name: "Python 3.4" variables: - PYTHON_BINARY: "/cygdrive/c/python/Python34/python.exe" + PYTHON_BINARY: "C:/python/Python34/python.exe" - id: "win-vs2015-2.7" display_name: "Python 2.7" variables: - PYTHON_BINARY: "/cygdrive/c/python/Python27/python.exe" + PYTHON_BINARY: "C:/python/Python27/python.exe" - id: "win-vs2015-3.5" display_name: "Python 3.5" variables: - PYTHON_BINARY: "/cygdrive/c/python/Python35/python.exe" + PYTHON_BINARY: "C:/python/Python35/python.exe" - id: "win-vs2015-3.6" display_name: "Python 3.6" variables: - PYTHON_BINARY: "/cygdrive/c/python/Python36/python.exe" + PYTHON_BINARY: "C:/python/Python36/python.exe" - id: "win-vs2015-3.7" display_name: "Python 3.7" variables: - PYTHON_BINARY: "/cygdrive/c/python/Python37/python.exe" + PYTHON_BINARY: "C:/python/Python37/python.exe" + - id: "win-vs2015-3.8" + display_name: "Python 3.8" + variables: + PYTHON_BINARY: "C:/python/Python38/python.exe" # Choice of mod_wsgi version - id: mod-wsgi-version @@ -1729,7 +1739,7 @@ buildvariants: python-version: ["2.7", "3.4", "3.5", "3.6", "3.7", "pypy", "pypy3.5"] auth: "*" ssl: "ssl" - display_name: "PyOpenSSL ${python-version} ${platform} ${auth}" + display_name: "PyOpenSSL ${platform} ${python-version} ${auth}" tasks: - "pyopenssl" @@ -1740,7 +1750,7 @@ buildvariants: - rhel70 # CPython 2.7.5 auth: "*" ssl: "ssl" - display_name: "PyOpenSSL Pre-2.7.9 Python ${platform} ${auth}" + display_name: "PyOpenSSL ${platform} Pre-2.7.9 Python ${auth}" tasks: - "pyopenssl" @@ -1753,6 +1763,16 @@ buildvariants: tasks: - "pyopenssl" +- matrix_name: "tests-pyopenssl-windows" + matrix_spec: + platform: windows-64-vsMulti-small + python-version: ["win-vs2015-2.7", "win-vs2010-3.4", "win-vs2015-3.5", "win-vs2015-3.6", "win-vs2015-3.7", "win-vs2015-3.8"] + auth: "*" + ssl: "ssl" + display_name: "PyOpenSSL ${platform} ${python-version} ${auth}" + tasks: + - "pyopenssl" + - matrix_name: "tests-python-version-rhel62-test-encryption" matrix_spec: platform: rhel62 diff --git a/.evergreen/run-ocsp-tests.sh b/.evergreen/run-ocsp-tests.sh index fdfea0641..25006811d 100644 --- a/.evergreen/run-ocsp-tests.sh +++ b/.evergreen/run-ocsp-tests.sh @@ -5,20 +5,42 @@ set -o errexit if [ -z "$PYTHON_BINARY" ]; then echo "No python binary specified" - PYTHON_BINARY=$(command -v python || command -v python3) || true + PYTHON=$(command -v python || command -v python3) || true if [ -z "$PYTHON_BINARY" ]; then echo "Cannot test without python or python3 installed!" exit 1 fi +else + PYTHON="$PYTHON_BINARY" fi -$PYTHON_BINARY -m virtualenv --never-download --no-wheel ocsptest -. ocsptest/bin/activate +if $PYTHON -m virtualenv --version; then + VIRTUALENV="$PYTHON -m virtualenv" +elif command -v virtualenv; then + # We can remove this fallback after: + # https://github.com/10gen/mongo-python-toolchain/issues/8 + VIRTUALENV="$(command -v virtualenv) -p $PYTHON" +else + echo "Cannot test without virtualenv" + exit 1 +fi + +$VIRTUALENV --never-download --no-wheel ocsptest +if [ "Windows_NT" = "$OS" ]; then + . ocsptest/Scripts/activate +else + . ocsptest/bin/activate +fi trap "deactivate; rm -rf ocsptest" EXIT HUP IS_PYTHON_2=$(python -c "import sys; sys.stdout.write('1' if sys.version_info < (3,) else '0')") if [ $IS_PYTHON_2 = "1" ]; then echo "Using a Python 2" + # Upgrade pip to install the cryptography wheel and not the tar. + # <20.1 because 20.0.2 says a future release may drop support for 2.7. + pip install --upgrade 'pip<20.1' + # Upgrade setuptools because cryptography requires 18.5+. + # <45 because 45.0 dropped support for 2.7. pip install --upgrade 'setuptools<45' fi diff --git a/.evergreen/run-pyopenssl-tests.sh b/.evergreen/run-pyopenssl-tests.sh index 4d27ee301..ea4271572 100644 --- a/.evergreen/run-pyopenssl-tests.sh +++ b/.evergreen/run-pyopenssl-tests.sh @@ -9,6 +9,7 @@ export CLIENT_PEM="$DRIVERS_TOOLS/.evergreen/x509gen/client.pem" export CA_PEM="$DRIVERS_TOOLS/.evergreen/x509gen/ca.pem" if [ -z "$PYTHON_BINARY" ]; then + echo "No python binary specified" PYTHON=$(command -v python || command -v python3) || true if [ -z "$PYTHON" ]; then echo "Cannot test without python or python3 installed!" @@ -18,13 +19,33 @@ else PYTHON="$PYTHON_BINARY" fi -$PYTHON -m virtualenv pyopenssltest -. pyopenssltest/bin/activate +if $PYTHON -m virtualenv --version; then + VIRTUALENV="$PYTHON -m virtualenv" +elif command -v virtualenv; then + # We can remove this fallback after: + # https://github.com/10gen/mongo-python-toolchain/issues/8 + VIRTUALENV="$(command -v virtualenv) -p $PYTHON" +else + echo "Cannot test without virtualenv" + exit 1 +fi + +$VIRTUALENV pyopenssltest +if [ "Windows_NT" = "$OS" ]; then + . pyopenssltest/Scripts/activate +else + . pyopenssltest/bin/activate +fi trap "deactivate; rm -rf pyopenssltest" EXIT HUP IS_PYTHON_2=$(python -c "import sys; sys.stdout.write('1' if sys.version_info < (3,) else '0')") if [ $IS_PYTHON_2 = "1" ]; then echo "Using a Python 2" + # Upgrade pip to install the cryptography wheel and not the tar. + # <20.1 because 20.0.2 says a future release may drop support for 2.7. + pip install --upgrade 'pip<20.1' + # Upgrade setuptools because cryptography requires 18.5+. + # <45 because 45.0 dropped support for 2.7. pip install --upgrade 'setuptools<45' fi