I am using numpy.distutils
to setup a package (mypackage) that has a frotran module. The problem is that if I do pip install mypackage
on an environment that does not have numpy, I get the following error:
ModuleNotFoundError: No module named 'numpy'
The easy solution is to ask users (if I manage to have any) to pip install numpy
before they install my package, but I do not think this is a very elegant solution.
I came up with the idea of calling setuptools.setup
with only setup_requires=['numpy']
before I import numpy and it seems to work well. This is my setup.py
:
import setuptools
setuptools.setup(
setup_requires=[
'numpy'
],)
from numpy.distutils.core import setup, Extension
mod = Extension(name='mypackage.amodule', sources=['source/a.f90'])
setup(name='mypackage',
packages=['mypackage'],
ext_modules=[mod],)
I honestly don't fully understand what it implies to call an empty setup()
(no name, no package). Is this a good solution? Is this somehow a bad practice?