Skip to content

Commit 3274245

Browse files
committed
fix fail_if_no_c
1 parent 90f26e9 commit 3274245

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

tools/fail_if_no_c.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,19 @@
2929
import bson # noqa: E402
3030
import pymongo # noqa: E402
3131

32-
if not pymongo.has_c() or not bson.has_c():
33-
try:
34-
from pymongo import _cmessage # type:ignore[attr-defined] # noqa: F401
35-
except Exception as e:
36-
LOGGER.exception(e)
37-
try:
38-
from bson import _cbson # type:ignore[attr-defined] # noqa: F401
39-
except Exception as e:
40-
LOGGER.exception(e)
41-
sys.exit("could not load C extensions")
32+
33+
def main():
34+
if not pymongo.has_c() or not bson.has_c():
35+
try:
36+
from pymongo import _cmessage # type:ignore[attr-defined] # noqa: F401
37+
except Exception as e:
38+
LOGGER.exception(e)
39+
try:
40+
from bson import _cbson # type:ignore[attr-defined] # noqa: F401
41+
except Exception as e:
42+
LOGGER.exception(e)
43+
sys.exit("could not load C extensions")
44+
45+
46+
if __name__ == "__main__":
47+
main()

0 commit comments

Comments
 (0)