diff --git a/dddp/__init__.py b/dddp/__init__.py index 321555c..f60ad98 100644 --- a/dddp/__init__.py +++ b/dddp/__init__.py @@ -6,7 +6,6 @@ from pkg_resources import get_distribution, DistributionNotFound from gevent.local import local from dddp import alea - try: _dist = get_distribution('django-ddp') if not __file__.startswith(os.path.join(_dist.location, 'django-ddp', '')): @@ -43,6 +42,14 @@ def greenify(): # ensure we don't greenify again _GREEN[True] = True + try: + # Use psycopg2 by default + import psycopg2 + except ImportError: + # Fallback to psycopg2cffi if required (eg: pypy) + from psycopg2cffi import compat + compat.register() + class AlreadyRegistered(Exception):