2

Maybe I don't understand the flow, but I can't manage to install dependencies to setup.py file before the script is actually run. My guess was that providing a setup_requires option to the setup.py file would install modules required by the setup file so that I can import them. Here my file:

import os
import numpy
from Cython.Build import cythonize
from setuptools import setup, Extension

# Cython library
ext = [Extension('sp.filters',  # location of the resulting .so
                 ['sp/filters.pyx'],
                 include_dirs=[numpy.get_include()])]


setup(name='Filters',
      description="BlahBlah",
      long_description="BlahBlahBlah",
      packages=['filters'],
      ext_modules=cythonize(ext),
      setup_requires=[
        'cython',
        'numpy,
        'setuptools'
      ],
      install_requires=['numpy',
                        'numba',
                        'scipy',]
)

But I get the following error:

ERROR: Complete output from command python setup.py egg_info:
    ERROR: Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-req-build-uck5sw58/setup.py", line 8, in <module>
        import numpy
    ModuleNotFoundError: No module named 'numpy'
quamrana
  • 37,849
  • 12
  • 53
  • 71
GuillaumeA
  • 3,493
  • 4
  • 35
  • 69
  • 1
    You may find this question useful: [Add numpy.get_include() argument to setuptools without preinstalled numpy](https://stackoverflow.com/questions/54117786) – hoefling May 07 '19 at 08:38

1 Answers1

0

You import numpy (and Cython) before calling setup(). setup() doesn't have a chance to install anything.

In your case setup_requires cannot help. Install numpy and Cython before running setup.py. Or refactor setup.py to not import numpy and Cython.

phd
  • 82,685
  • 13
  • 120
  • 165
  • Thanks, I hoped there were some magic around `pip install` that parse inside the setup file to find `setup_requires` required packages.... – GuillaumeA May 06 '19 at 20:48