Why doesn't setup_requires work properly for numpy?

后端 未结 1 967
情歌与酒
情歌与酒 2020-12-10 14:21

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 setu

相关标签:
1条回答
  • 2020-12-10 14:59

    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:

    ...
    def run(self):
        __builtins__.__NUMPY_SETUP__ = False
        import numpy
        ...
    
    0 讨论(0)
提交回复
热议问题