PYTHON-4988: Check C extensions are loaded ONLY in CPython builds (#2016)

This commit is contained in:
Jib 2024-11-25 13:13:44 -05:00 committed by GitHub
parent 1c7a7fe9ec
commit 9b5c0981d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View File

@ -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.

View File

@ -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 ..