Skip to content

Commit 09952f0

Browse files
committed
consolidate
1 parent 28554b9 commit 09952f0

File tree

2 files changed

+10
-29
lines changed

2 files changed

+10
-29
lines changed

.evergreen/scripts/run_tests.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,10 @@
2929

3030
# Ensure C extensions if applicable.
3131
if not os.environ.get("NO_EXT") and platform.python_implementation() == "CPython":
32-
import bson
33-
import pymongo
34-
35-
if not pymongo.has_c() or not bson.has_c():
36-
try:
37-
from pymongo import _cmessage # type:ignore[attr-defined] # noqa: F401
38-
except Exception as e:
39-
LOGGER.exception(e)
40-
try:
41-
from bson import _cbson # type:ignore[attr-defined] # noqa: F401
42-
except Exception as e:
43-
LOGGER.exception(e)
44-
sys.exit("could not load C extensions")
32+
sys.path.insert(0, str(ROOT / "tools"))
33+
from fail_if_no_c import main as fail_if_no_c
34+
35+
fail_if_no_c()
4536

4637
if os.environ.get("PYMONGOCRYPT_LIB"):
4738
# Ensure pymongocrypt is working properly.

tools/fail_if_no_c.py

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818
"""
1919
from __future__ import annotations
2020

21-
import os
22-
import subprocess
21+
import logging
2322
import sys
24-
from pathlib import Path
23+
24+
LOGGER = logging.getLogger(__name__)
25+
logging.basicConfig(level=logging.INFO, format="%(levelname)-8s %(message)s")
2526

2627
sys.path[0:0] = [""]
2728

@@ -32,20 +33,9 @@
3233
try:
3334
from pymongo import _cmessage # type:ignore[attr-defined] # noqa: F401
3435
except Exception as e:
35-
print(e)
36+
LOGGER.exception(e)
3637
try:
3738
from bson import _cbson # type:ignore[attr-defined] # noqa: F401
3839
except Exception as e:
39-
print(e)
40+
LOGGER.exception(e)
4041
sys.exit("could not load C extensions")
41-
42-
if os.environ.get("ENSURE_UNIVERSAL2") == "1":
43-
parent_dir = Path(pymongo.__path__[0]).parent
44-
for pkg in ["pymongo", "bson", "grifs"]:
45-
for so_file in Path(f"{parent_dir}/{pkg}").glob("*.so"):
46-
print(f"Checking universal2 compatibility in {so_file}...")
47-
output = subprocess.check_output(["file", so_file]) # noqa: S603, S607
48-
if "arm64" not in output.decode("utf-8"):
49-
sys.exit("Universal wheel was not compiled with arm64 support")
50-
if "x86_64" not in output.decode("utf-8"):
51-
sys.exit("Universal wheel was not compiled with x86_64 support")

0 commit comments

Comments
 (0)