helper to check for C extension PYTHON-51

This commit is contained in:
Mike Dirolf 2010-03-10 10:16:44 -05:00
parent 2cafc867e6
commit 03bcb23053
3 changed files with 14 additions and 3 deletions

View File

@ -9,6 +9,8 @@
Alias for :class:`pymongo.connection.Connection`.
.. autofunction:: has_c
Sub-modules:
.. toctree::

View File

@ -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

View File

@ -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")