diff options
Diffstat (limited to 'numpy/lib/utils.py')
-rw-r--r-- | numpy/lib/utils.py | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py index 684876591..0b2731005 100644 --- a/numpy/lib/utils.py +++ b/numpy/lib/utils.py @@ -1,12 +1,9 @@ import os import sys -import pkgutil import types import re -from numpy.core.numerictypes import obj2sctype, generic, issubclass_, \ - issubsctype, issubdtype -from numpy.core.multiarray import dtype as _dtype +from numpy.core.numerictypes import issubclass_, issubsctype, issubdtype from numpy.core import product, ndarray __all__ = ['issubclass_', 'get_numpy_include', 'issubsctype', @@ -682,15 +679,21 @@ def _lookfor_generate_cache(module, import_modules, regenerate): _all = item.__all__ except AttributeError: _all = None + # import sub-packages if import_modules and hasattr(item, '__path__'): - for m in pkgutil.iter_modules(item.__path__): - if _all is not None and m[1] not in _all: - continue - try: - __import__("%s.%s" % (name, m[1])) - except ImportError: - continue + for pth in item.__path__: + for mod_path in os.listdir(pth): + init_py = os.path.join(pth, mod_path, '__init__.py') + if not os.path.isfile(init_py): + continue + if _all is not None and mod_path not in _all: + continue + try: + __import__("%s.%s" % (name, mod_path)) + except ImportError: + continue + for n, v in inspect.getmembers(item): if _all is not None and n not in _all: continue |