Skip to content Skip to sidebar Skip to footer

Why Doesn't Setup_requires Work Properly For Numpy?

I wanted to create a setup.py file that automatically resolves a build-time dependency to numpy (for compiling extensions). My first guess was to use setup_requires and subclass a

Solution 1:

Figured out, that a proper initialization of the numpy module is prevented by a check for __NUMPY_SETUP__ inside numpy/__init__.py:

if __NUMPY_SETUP__:
    import sys as _sys
    _sys.stderr.write('Running from numpy source directory.\n')
    del _sys
else:
    # import subodules etc. (main branch)

This global state is not reset by setuptools after the installation. The following works:

...
defrun(self):
    __builtins__.__NUMPY_SETUP__ = Falseimport numpy
    ...

Post a Comment for "Why Doesn't Setup_requires Work Properly For Numpy?"