summaryrefslogtreecommitdiff
path: root/numpy/lib/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/utils.py')
-rw-r--r--numpy/lib/utils.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py
index 1c88fb3f1..0b2731005 100644
--- a/numpy/lib/utils.py
+++ b/numpy/lib/utils.py
@@ -1,6 +1,5 @@
import os
import sys
-import pkgutil
import types
import re
@@ -680,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