File tree Expand file tree Collapse file tree 2 files changed +10
-29
lines changed Expand file tree Collapse file tree 2 files changed +10
-29
lines changed Original file line number Diff line number Diff line change 29
29
30
30
# Ensure C extensions if applicable.
31
31
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 ()
45
36
46
37
if os .environ .get ("PYMONGOCRYPT_LIB" ):
47
38
# Ensure pymongocrypt is working properly.
Original file line number Diff line number Diff line change 18
18
"""
19
19
from __future__ import annotations
20
20
21
- import os
22
- import subprocess
21
+ import logging
23
22
import sys
24
- from pathlib import Path
23
+
24
+ LOGGER = logging .getLogger (__name__ )
25
+ logging .basicConfig (level = logging .INFO , format = "%(levelname)-8s %(message)s" )
25
26
26
27
sys .path [0 :0 ] = ["" ]
27
28
32
33
try :
33
34
from pymongo import _cmessage # type:ignore[attr-defined] # noqa: F401
34
35
except Exception as e :
35
- print (e )
36
+ LOGGER . exception (e )
36
37
try :
37
38
from bson import _cbson # type:ignore[attr-defined] # noqa: F401
38
39
except Exception as e :
39
- print (e )
40
+ LOGGER . exception (e )
40
41
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" )
You can’t perform that action at this time.
0 commit comments