From 6b5a33fc4cd0e7b92dae59de7efa325c63c0ce2d Mon Sep 17 00:00:00 2001 From: Jib Date: Fri, 22 Nov 2024 15:05:05 -0500 Subject: [PATCH] Check for c extensions in CPython builds --- .evergreen/run-tests.sh | 4 ++-- .evergreen/utils.sh | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh index 9716c1fc79..95fe10a6c3 100755 --- a/.evergreen/run-tests.sh +++ b/.evergreen/run-tests.sh @@ -38,6 +38,7 @@ export PIP_PREFER_BINARY=1 # Prefer binary dists by default set +x python -c "import sys; sys.exit(sys.prefix == sys.base_prefix)" || (echo "Not inside a virtual env!"; exit 1) +PYTHON_IMPL=$(python -c "import platform; print(platform.python_implementation())") # Try to source local Drivers Secrets if [ -f ./secrets-export.sh ]; then @@ -48,7 +49,7 @@ else fi # Ensure C extensions have compiled. -if [ -z "${NO_EXT:-}" ]; then +if [ -z "${NO_EXT:-}" ] && [ "$PYTHON_IMPL" = "CPython" ]; then python tools/fail_if_no_c.py fi @@ -245,7 +246,6 @@ python -c 'import sys; print(sys.version)' # Run the tests with coverage if requested and coverage is installed. # Only cover CPython. PyPy reports suspiciously low coverage. -PYTHON_IMPL=$(python -c "import platform; print(platform.python_implementation())") if [ -n "$COVERAGE" ] && [ "$PYTHON_IMPL" = "CPython" ]; then # Keep in sync with combine-coverage.sh. # coverage >=5 is needed for relative_files=true. diff --git a/.evergreen/utils.sh b/.evergreen/utils.sh index 908cf0564a..d3af2dcc7a 100755 --- a/.evergreen/utils.sh +++ b/.evergreen/utils.sh @@ -78,6 +78,7 @@ testinstall () { PYTHON=$1 RELEASE=$2 NO_VIRTUALENV=$3 + PYTHON_IMPL=$(python -c "import platform; print(platform.python_implementation())") if [ -z "$NO_VIRTUALENV" ]; then createvirtualenv $PYTHON venvtestinstall @@ -86,7 +87,11 @@ testinstall () { $PYTHON -m pip install --upgrade $RELEASE cd tools - $PYTHON fail_if_no_c.py + + if [ "$PYTHON_IMPL" = "CPython" ]; then + $PYTHON fail_if_no_c.py + fi + $PYTHON -m pip uninstall -y pymongo cd ..