Closed bgottula closed 3 years ago
🤮
This is probably the easiest route (basically option 2 in the description):
https://stackoverflow.com/a/50255019
Add one of those lines in setup.py before importing from numpy and be done with it. :man_shrugging:
setup.py tries to import numpy but it may not be installed before this package is installed. Existing options like
setup_requires
don't work in this case because those don't take effect untilsetup()
is called, but the import happens beforesetup()
.setup.py has the following import:
from numpy.distutils.misc_util import get_numpy_include_dirs
which is used to populate an argument to the
Extension
constructor as part of the call tosetup()
:So even though numpy is included in both
setup_requires
andinstall_requires
, installation will fail unless numpy is already installed in the environment. I don't know yet of a perfect solution, but it's probably one of the following:try
to import numpy and then emit a useful error message if the import fails.setup()
) such that it is installed before importing from it.build_ext
command can be subclassed such that the import can be deferred until the point insetup()
where numpy has been installed. This seems like the most correct way to do things but the documentation and source code is hard to understand. I don't know exactly what theExtension
class does, and whether by subclassingbuild_ext
we can omit it from theext_modules
argument tosetup()
.