From 26e00ec107760ff3a6a56a52a4dde46aaae417d8 Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Fri, 20 Nov 2020 12:43:32 -0800 Subject: [PATCH 1/8] PYTHON-2431 Fix MONGODB-AWS auth tests on macOS --- .evergreen/config.yml | 2 +- .evergreen/run-mongodb-aws-test.sh | 7 ++++--- .evergreen/utils.sh | 8 +++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index c161aeaa21..1f019fa7ac 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -492,7 +492,7 @@ functions: script: | ${PREPARE_SHELL} # The aws_e2e_assume_role script requires python3 with boto3. - virtualenv -p ${python3_binary} mongovenv + ${python3_binary} -m venv mongovenv if [ "Windows_NT" = "$OS" ]; then . mongovenv/Scripts/activate else diff --git a/.evergreen/run-mongodb-aws-test.sh b/.evergreen/run-mongodb-aws-test.sh index f0d59e960a..e534b0c8dc 100755 --- a/.evergreen/run-mongodb-aws-test.sh +++ b/.evergreen/run-mongodb-aws-test.sh @@ -3,6 +3,9 @@ set -o xtrace set -o errexit # Exit the script with error if any of the commands fail +# Get access to createvirtualenv. +. .evergreen/utils.sh + ############################################ # Main Program # ############################################ @@ -39,8 +42,6 @@ fi # show test output set -x -VIRTUALENV=$(command -v virtualenv) - authtest () { if [ "Windows_NT" = "$OS" ]; then PYTHON=$(cygpath -m $PYTHON) @@ -49,7 +50,7 @@ authtest () { echo "Running MONGODB-AWS authentication tests with $PYTHON" $PYTHON --version - $VIRTUALENV -p $PYTHON --system-site-packages --never-download venvaws + createvirtualenv $PYTHON venvaws if [ "Windows_NT" = "$OS" ]; then . venvaws/Scripts/activate else diff --git a/.evergreen/utils.sh b/.evergreen/utils.sh index 9a92f15295..0e0b16fe8e 100755 --- a/.evergreen/utils.sh +++ b/.evergreen/utils.sh @@ -8,14 +8,16 @@ createvirtualenv () { PYTHON=$1 VENVPATH=$2 if $PYTHON -m virtualenv --version; then - VIRTUALENV="$PYTHON -m virtualenv" + VIRTUALENV="$PYTHON -m virtualenv --never-download" + elif $PYTHON -m venv -h >/dev/null; then + VIRTUALENV="$PYTHON -m venv" elif command -v virtualenv; then - VIRTUALENV="$(command -v virtualenv) -p $PYTHON" + VIRTUALENV="$(command -v virtualenv) -p $PYTHON --never-download" else echo "Cannot test without virtualenv" exit 1 fi - $VIRTUALENV --system-site-packages --never-download $VENVPATH + $VIRTUALENV --system-site-packages $VENVPATH if [ "Windows_NT" = "$OS" ]; then . $VENVPATH/Scripts/activate else From 44cfe48e1a401903663e34cc2a2011cb47514441 Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Fri, 20 Nov 2020 13:19:16 -0800 Subject: [PATCH 2/8] TODO: test release, encryption, aws auth, revert --- .evergreen/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 1f019fa7ac..024b206732 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -823,7 +823,7 @@ tasks: - name: "release" tags: ["release"] exec_timeout_secs: 216000 # 60 minutes (manylinux task is slow). - git_tag_only: true + git_tag_only: false commands: - command: shell.exec type: test From d7ee043d58a484d695a413f77b236acffd772908 Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Fri, 20 Nov 2020 14:21:49 -0800 Subject: [PATCH 3/8] PYTHON-2431 only use venv on macOS --- .evergreen/config.yml | 5 ++++- .evergreen/utils.sh | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 024b206732..0d47ff91c7 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -487,12 +487,15 @@ functions: "run aws auth test with assume role credentials": - command: shell.exec type: test + shell: bash params: working_dir: "src" script: | ${PREPARE_SHELL} + # Get access to createvirtualenv. + . .evergreen/utils.sh # The aws_e2e_assume_role script requires python3 with boto3. - ${python3_binary} -m venv mongovenv + createvirtualenv ${python3_binary} mongovenv if [ "Windows_NT" = "$OS" ]; then . mongovenv/Scripts/activate else diff --git a/.evergreen/utils.sh b/.evergreen/utils.sh index 0e0b16fe8e..faf66ffcfe 100755 --- a/.evergreen/utils.sh +++ b/.evergreen/utils.sh @@ -9,7 +9,8 @@ createvirtualenv () { VENVPATH=$2 if $PYTHON -m virtualenv --version; then VIRTUALENV="$PYTHON -m virtualenv --never-download" - elif $PYTHON -m venv -h >/dev/null; then + elif [ $(uname -s) = "Darwin" ] && $PYTHON -m venv -h >/dev/null; then + # Only use venv on macOS, venv fails on Windows and some Linux distros. VIRTUALENV="$PYTHON -m venv" elif command -v virtualenv; then VIRTUALENV="$(command -v virtualenv) -p $PYTHON --never-download" From 08e92510369209939ddf4b1f80db3848fbf2e757 Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Fri, 20 Nov 2020 14:49:41 -0800 Subject: [PATCH 4/8] Revert "TODO: test release, encryption, aws auth, revert" This reverts commit 44cfe48e1a401903663e34cc2a2011cb47514441. --- .evergreen/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 0d47ff91c7..3ee991771e 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -826,7 +826,7 @@ tasks: - name: "release" tags: ["release"] exec_timeout_secs: 216000 # 60 minutes (manylinux task is slow). - git_tag_only: false + git_tag_only: true commands: - command: shell.exec type: test From 4533584da125a1c6267107b53712affce7262064 Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Fri, 20 Nov 2020 15:10:54 -0800 Subject: [PATCH 5/8] PYTHON-2431 Fix Windows Python 3.5 pip error --- .evergreen/run-mongodb-aws-test.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.evergreen/run-mongodb-aws-test.sh b/.evergreen/run-mongodb-aws-test.sh index e534b0c8dc..2e6d935a80 100755 --- a/.evergreen/run-mongodb-aws-test.sh +++ b/.evergreen/run-mongodb-aws-test.sh @@ -56,6 +56,13 @@ authtest () { else . venvaws/bin/activate fi + + # Added to fix Windows Python 3.5 pip install error: + # TypeError: stat: can't specify None for path argument + if [ "Windows_NT" = "$OS" ]; then # Magic variable in cygwin + $PYTHON -m pip install -U setuptools + fi + pip install '.[aws]' python test/auth_aws/test_auth_aws.py deactivate From 95ddabf8c3bb3afadd8aa2cf6d267a0392f73ff0 Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Fri, 20 Nov 2020 16:20:09 -0800 Subject: [PATCH 6/8] PYTHON-2431 Attempt to use venv on windows one last time --- .evergreen/config.yml | 5 ----- .evergreen/run-mongodb-aws-test.sh | 12 ------------ .evergreen/utils.sh | 8 +++++--- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 3ee991771e..e9a0f94538 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -496,11 +496,6 @@ functions: . .evergreen/utils.sh # The aws_e2e_assume_role script requires python3 with boto3. createvirtualenv ${python3_binary} mongovenv - if [ "Windows_NT" = "$OS" ]; then - . mongovenv/Scripts/activate - else - . mongovenv/bin/activate - fi pip install boto3 cd ${DRIVERS_TOOLS}/.evergreen/auth_aws mongo aws_e2e_assume_role.js diff --git a/.evergreen/run-mongodb-aws-test.sh b/.evergreen/run-mongodb-aws-test.sh index 2e6d935a80..85cdf0267a 100755 --- a/.evergreen/run-mongodb-aws-test.sh +++ b/.evergreen/run-mongodb-aws-test.sh @@ -51,18 +51,6 @@ authtest () { $PYTHON --version createvirtualenv $PYTHON venvaws - if [ "Windows_NT" = "$OS" ]; then - . venvaws/Scripts/activate - else - . venvaws/bin/activate - fi - - # Added to fix Windows Python 3.5 pip install error: - # TypeError: stat: can't specify None for path argument - if [ "Windows_NT" = "$OS" ]; then # Magic variable in cygwin - $PYTHON -m pip install -U setuptools - fi - pip install '.[aws]' python test/auth_aws/test_auth_aws.py deactivate diff --git a/.evergreen/utils.sh b/.evergreen/utils.sh index faf66ffcfe..f848facfba 100755 --- a/.evergreen/utils.sh +++ b/.evergreen/utils.sh @@ -9,8 +9,8 @@ createvirtualenv () { VENVPATH=$2 if $PYTHON -m virtualenv --version; then VIRTUALENV="$PYTHON -m virtualenv --never-download" - elif [ $(uname -s) = "Darwin" ] && $PYTHON -m venv -h >/dev/null; then - # Only use venv on macOS, venv fails on Windows and some Linux distros. + elif [[ $(uname -s) == "Darwin" || "Windows_NT" == "$OS" ]] && $PYTHON -m venv -h >/dev/null; then + # Only use venv on macOS or Windows, venv fails on some Linux distros. VIRTUALENV="$PYTHON -m venv" elif command -v virtualenv; then VIRTUALENV="$(command -v virtualenv) -p $PYTHON --never-download" @@ -20,7 +20,9 @@ createvirtualenv () { fi $VIRTUALENV --system-site-packages $VENVPATH if [ "Windows_NT" = "$OS" ]; then - . $VENVPATH/Scripts/activate + # Workaround https://bugs.python.org/issue32451: + # mongovenv/Scripts/activate: line 3: $'\r': command not found + . $VENVPATH/Scripts/activate || (dos2unix $VENVPATH/Scripts/activate && . $VENVPATH/Scripts/activate) else . $VENVPATH/bin/activate fi From 55fe633451b3f9d5e1a2d0ad1f01b539c2cf926e Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Fri, 20 Nov 2020 21:04:32 -0800 Subject: [PATCH 7/8] Revert all changes --- .evergreen/config.yml | 10 ++++++---- .evergreen/run-mongodb-aws-test.sh | 12 ++++++++---- .evergreen/utils.sh | 13 ++++--------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index e9a0f94538..c161aeaa21 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -487,15 +487,17 @@ functions: "run aws auth test with assume role credentials": - command: shell.exec type: test - shell: bash params: working_dir: "src" script: | ${PREPARE_SHELL} - # Get access to createvirtualenv. - . .evergreen/utils.sh # The aws_e2e_assume_role script requires python3 with boto3. - createvirtualenv ${python3_binary} mongovenv + virtualenv -p ${python3_binary} mongovenv + if [ "Windows_NT" = "$OS" ]; then + . mongovenv/Scripts/activate + else + . mongovenv/bin/activate + fi pip install boto3 cd ${DRIVERS_TOOLS}/.evergreen/auth_aws mongo aws_e2e_assume_role.js diff --git a/.evergreen/run-mongodb-aws-test.sh b/.evergreen/run-mongodb-aws-test.sh index 85cdf0267a..f0d59e960a 100755 --- a/.evergreen/run-mongodb-aws-test.sh +++ b/.evergreen/run-mongodb-aws-test.sh @@ -3,9 +3,6 @@ set -o xtrace set -o errexit # Exit the script with error if any of the commands fail -# Get access to createvirtualenv. -. .evergreen/utils.sh - ############################################ # Main Program # ############################################ @@ -42,6 +39,8 @@ fi # show test output set -x +VIRTUALENV=$(command -v virtualenv) + authtest () { if [ "Windows_NT" = "$OS" ]; then PYTHON=$(cygpath -m $PYTHON) @@ -50,7 +49,12 @@ authtest () { echo "Running MONGODB-AWS authentication tests with $PYTHON" $PYTHON --version - createvirtualenv $PYTHON venvaws + $VIRTUALENV -p $PYTHON --system-site-packages --never-download venvaws + if [ "Windows_NT" = "$OS" ]; then + . venvaws/Scripts/activate + else + . venvaws/bin/activate + fi pip install '.[aws]' python test/auth_aws/test_auth_aws.py deactivate diff --git a/.evergreen/utils.sh b/.evergreen/utils.sh index f848facfba..9a92f15295 100755 --- a/.evergreen/utils.sh +++ b/.evergreen/utils.sh @@ -8,21 +8,16 @@ createvirtualenv () { PYTHON=$1 VENVPATH=$2 if $PYTHON -m virtualenv --version; then - VIRTUALENV="$PYTHON -m virtualenv --never-download" - elif [[ $(uname -s) == "Darwin" || "Windows_NT" == "$OS" ]] && $PYTHON -m venv -h >/dev/null; then - # Only use venv on macOS or Windows, venv fails on some Linux distros. - VIRTUALENV="$PYTHON -m venv" + VIRTUALENV="$PYTHON -m virtualenv" elif command -v virtualenv; then - VIRTUALENV="$(command -v virtualenv) -p $PYTHON --never-download" + VIRTUALENV="$(command -v virtualenv) -p $PYTHON" else echo "Cannot test without virtualenv" exit 1 fi - $VIRTUALENV --system-site-packages $VENVPATH + $VIRTUALENV --system-site-packages --never-download $VENVPATH if [ "Windows_NT" = "$OS" ]; then - # Workaround https://bugs.python.org/issue32451: - # mongovenv/Scripts/activate: line 3: $'\r': command not found - . $VENVPATH/Scripts/activate || (dos2unix $VENVPATH/Scripts/activate && . $VENVPATH/Scripts/activate) + . $VENVPATH/Scripts/activate else . $VENVPATH/bin/activate fi From 4e254c57d1a3579b51afabc377d492d7b2479b8b Mon Sep 17 00:00:00 2001 From: Shane Harvey Date: Fri, 20 Nov 2020 21:14:30 -0800 Subject: [PATCH 8/8] PYTHON-2431 Fix issue, attempt 746 --- .evergreen/config.yml | 2 +- .evergreen/run-mongodb-aws-test.sh | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index c161aeaa21..5e2ce14d3a 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -1568,7 +1568,7 @@ axes: variables: skip_EC2_auth_test: true skip_ECS_auth_test: true - python3_binary: python3 + python3_binary: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 libmongocrypt_url: https://s3.amazonaws.com/mciuploads/libmongocrypt/macos/master/latest/libmongocrypt.tar.gz - id: rhel62 display_name: "RHEL 6.2 (x86_64)" diff --git a/.evergreen/run-mongodb-aws-test.sh b/.evergreen/run-mongodb-aws-test.sh index f0d59e960a..e276a82bb4 100755 --- a/.evergreen/run-mongodb-aws-test.sh +++ b/.evergreen/run-mongodb-aws-test.sh @@ -39,7 +39,12 @@ fi # show test output set -x -VIRTUALENV=$(command -v virtualenv) +# Workaround macOS python 3.9 incompatibility with system virtualenv. +if [ $(uname -s) = "Darwin" ]; then + VIRTUALENV="/Library/Frameworks/Python.framework/Versions/3.9/bin/python3 -m virtualenv" +else + VIRTUALENV=$(command -v virtualenv) +fi authtest () { if [ "Windows_NT" = "$OS" ]; then