hubs: delay import pkg_resources

https://github.com/eventlet/eventlet/issues/177
This commit is contained in:
Sergey Shepelev
2014-12-30 03:07:26 +03:00
parent 7b05b3a1ee
commit d026bd5a3d
2 changed files with 13 additions and 9 deletions

View File

@@ -1,14 +1,7 @@
import sys
import os import os
from eventlet.support import greenlets as greenlet, six
from eventlet import patcher
try: from eventlet import patcher
# try and import pkg_resources ... from eventlet.support import greenlets as greenlet, six
import pkg_resources
except ImportError:
# ... but do not depend on it
pkg_resources = None
__all__ = ["use_hub", "get_hub", "get_default_hub", "trampoline"] __all__ = ["use_hub", "get_hub", "get_default_hub", "trampoline"]
@@ -86,6 +79,15 @@ def use_hub(mod=None):
mod = getattr(mod, classname) mod = getattr(mod, classname)
else: else:
found = False found = False
# setuptools 5.4.1 test_import_patched_defaults fail
# https://github.com/eventlet/eventlet/issues/177
try:
# try and import pkg_resources ...
import pkg_resources
except ImportError:
# ... but do not depend on it
pkg_resources = None
if pkg_resources is not None: if pkg_resources is not None:
for entry in pkg_resources.iter_entry_points( for entry in pkg_resources.iter_entry_points(
group='eventlet.hubs', name=mod): group='eventlet.hubs', name=mod):
@@ -115,6 +117,7 @@ def get_hub():
hub = _threadlocal.hub = _threadlocal.Hub() hub = _threadlocal.hub = _threadlocal.Hub()
return hub return hub
from eventlet import timeout from eventlet import timeout

View File

@@ -31,6 +31,7 @@ deps =
psycopg2cffi-compat==1.1 psycopg2cffi-compat==1.1
pyopenssl==0.13 pyopenssl==0.13
pyzmq==13.1.0 pyzmq==13.1.0
setuptools==5.4.1
commands = commands =
nosetests --verbose tests/ nosetests --verbose tests/
nosetests --verbose --with-doctest eventlet/coros.py eventlet/event.py \ nosetests --verbose --with-doctest eventlet/coros.py eventlet/event.py \