Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .evergreen/check-c-extensions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -o errexit # Exit the script with error if any of the commands fail

# Supported/used environment variables:
# C_EXTENSIONS Pass --no_ext to skip installing the C extensions.

PYTHON_IMPL=$(python -c "import platform; print(platform.python_implementation())")
if [ -z "$C_EXTENSIONS" ] && [ "$PYTHON_IMPL" = "CPython" ]; then
PYMONGO_C_EXT_MUST_BUILD=1 python setup.py build_ext -i
python tools/fail_if_no_c.py
fi
1 change: 0 additions & 1 deletion .evergreen/run-perf-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export TEST_PATH="${PROJECT_DIRECTORY}/driver-performance-test-data"
export OUTPUT_FILE="${PROJECT_DIRECTORY}/results.json"

export PYTHON_BINARY=/opt/mongodbtoolchain/v3/bin/python3
export C_EXTENSIONS=1
export PERF_TEST=1

bash ./.evergreen/tox.sh -m test-eg
9 changes: 2 additions & 7 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -o xtrace
# AUTH Set to enable authentication. Defaults to "noauth"
# SSL Set to enable SSL. Defaults to "nossl"
# GREEN_FRAMEWORK The green framework to test with, if any.
# C_EXTENSIONS If non-empty, c extensions are enabled.
# C_EXTENSIONS Pass --no_ext to skip installing the C extensions.
# COVERAGE If non-empty, run the test suite with coverage.
# COMPRESSORS If non-empty, install appropriate compressor.
# LIBMONGOCRYPT_URL The URL to download libmongocrypt.
Expand Down Expand Up @@ -272,12 +272,7 @@ fi
PIP_QUIET=0 python -m pip list

if [ -z "$GREEN_FRAMEWORK" ]; then
if [ -z "$C_EXTENSIONS" ] && [ "$PYTHON_IMPL" = "CPython" ]; then
python setup.py build_ext -i
# This will set a non-zero exit status if either import fails,
# causing this script to exit.
python -c "from bson import _cbson; from pymongo import _cmessage"
fi
.evergreen/check-c-extensions.sh
python -m pytest -v --durations=5 --maxfail=10 $TEST_ARGS
else
python green_framework_test.py $GREEN_FRAMEWORK -v $TEST_ARGS
Expand Down
9 changes: 6 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def run(self):
try:
build_ext.run(self)
except Exception:
if "TOX_ENV_NAME" in os.environ:
if os.environ.get("PYMONGO_C_EXT_MUST_BUILD"):
raise
e = sys.exc_info()[1]
sys.stdout.write("%s\n" % str(e))
Expand All @@ -86,7 +86,7 @@ def build_extension(self, ext):
try:
build_ext.build_extension(self, ext)
except Exception:
if "TOX_ENV_NAME" in os.environ:
if os.environ.get("PYMONGO_C_EXT_MUST_BUILD"):
raise
e = sys.exc_info()[1]
sys.stdout.write("%s\n" % str(e))
Expand Down Expand Up @@ -120,7 +120,10 @@ def build_extension(self, ext):


if "--no_ext" in sys.argv or os.environ.get("NO_EXT"):
sys.argv.remove("--no_ext")
try:
sys.argv.remove("--no_ext")
except ValueError:
pass
ext_modules = []
elif sys.platform.startswith("java") or sys.platform == "cli" or "PyPy" in sys.version:
sys.stdout.write(
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ labels = # Use labels and -m instead of -e so that tox -m <label> fails instantl
description = run base set of unit tests with no extra functionality
extras =
test
allowlist_externals =
.evergreen/check-c-extensions.sh
commands =
python --version
python setup.py build_ext -i
.evergreen/check-c-extensions.sh
pytest -v --durations=5 --maxfail=10 {posargs}

[testenv:test-eg]
Expand Down