helper to check for C extension PYTHON-51
This commit is contained in:
parent
2cafc867e6
commit
03bcb23053
@ -9,6 +9,8 @@
|
||||
|
||||
Alias for :class:`pymongo.connection.Connection`.
|
||||
|
||||
.. autofunction:: has_c
|
||||
|
||||
Sub-modules:
|
||||
|
||||
.. toctree::
|
||||
|
||||
@ -33,3 +33,12 @@ version = "1.4+"
|
||||
|
||||
Connection = PyMongo_Connection
|
||||
"""Alias for :class:`pymongo.connection.Connection`."""
|
||||
|
||||
def has_c():
|
||||
"""Is the C extension installed?
|
||||
"""
|
||||
try:
|
||||
from pymongo import _cbson
|
||||
return True
|
||||
except ImportError:
|
||||
return False
|
||||
|
||||
@ -20,7 +20,7 @@ Only really intended to be used by internal build scripts.
|
||||
import sys
|
||||
sys.path[0:0] = [""]
|
||||
|
||||
try:
|
||||
from pymongo import _cbson
|
||||
except ImportError:
|
||||
import pymongo
|
||||
|
||||
if not pymongo.has_c():
|
||||
sys.exit("could not import _cbson")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user