You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Configuration.add_subpackage fails on Python 3.4 #8147
Using numpy 1.11.2 and Python 3.4, trying to run a setupy.py script which uses subpackage using numpy.distutil fails when importlib.machinery cannot be found in the npy_load_module function.
For example using the following setup.py and foo/setup.py scripts:
$ python setup.py build_ext -i
Traceback (most recent call last):
File "setup.py", line 10, in <module>
setup(configuration=configuration)
File "/Users/jhelmus/anaconda/envs/py34/lib/python3.4/site-packages/numpy/distutils/core.py", line 135, in setup
config = configuration()
File "setup.py", line 7, in configuration
config.add_subpackage('foo')
File "/Users/jhelmus/anaconda/envs/py34/lib/python3.4/site-packages/numpy/distutils/misc_util.py", line 1000, in add_subpackage
caller_level = 2)
File "/Users/jhelmus/anaconda/envs/py34/lib/python3.4/site-packages/numpy/distutils/misc_util.py", line 969, in get_subpackage
caller_level = caller_level + 1)
File "/Users/jhelmus/anaconda/envs/py34/lib/python3.4/site-packages/numpy/distutils/misc_util.py", line 882, in _get_configuration_from_setup_py
('.py', 'U', 1))
File "/Users/jhelmus/anaconda/envs/py34/lib/python3.4/site-packages/numpy/compat/py3k.py", line 112, in npy_load_module
return importlib.machinery.SourceFileLoader(name, fn).load_module()
AttributeError: 'module' object has no attribute 'machinery'
This works in Python 3.5 and 2.7 and with earlier versions of NumPy prior to the addition of npy_load_module.
This bug can likely be fixed by adding import importlib to the npy_load_module. I will submit a PR shortly.
A workaround is to import importlib.machinery somewhere in the root setup.py file.
Activity
BUG: import full module path in npy_load_module
Fix install with numpy 1.11 and Python 3.4
JohnnyJia2023 commentedon Nov 30, 2017
For some reason, python 3.6 does not initialize machinery module in init.py. However, you can import it by the following way. It is very weird.
from importlib.machinery import SourceFileLoader
config = SourceFileLoader('config', os.path.abspath('../config.py')).load_module()