1

My Python package requires numpy at build time in order to compile cython extensions. Running python setup.py install will fail if numpy is not available in the environment.

I've read online that I can add a setup_requires section to my setup.py setup function call to get this working. So I've done the following:

setup(
    setup_requires=[
        "setuptools>=18.0",
        "numpy>1.14",
    ],
    install_requires=[
        "numpy>1.14",
        ...
    ],
)

However, when I do this, my travis CI fails with

ValueError: numpy.ufunc size changed, may indicate binary incompatibility. Expected 216 from C header, got 192 from PyObject

However, if I ensure that numpy is available and remove the setup_requires section, this works.

I am confused by this behaviour, it almost seems like it's using two different versions of numpy? I can't imagine what else could cause this incompatibility.

My question is 1. why doesn't this work and 2. what, then, is the canonical way to ensure that numpy is installed when building packages.

Pavlin
  • 5,390
  • 6
  • 38
  • 51
  • Could you require a later version of numpy by default? >1.16.1 instead of numpy >1.14? Could be an issue with an older version. And i believe putting it in setup_requirements is correct. Perhaps you have an older version installed so it uses that in set up instead of downloading the latest? – user2379875 Jul 03 '19 at 20:53
  • This runs on Travis CI, where every run a fresh VM is booted up, so this is always run in a clean environment. Unless Travis does some bizarre caching (which it probably doesn't), this can't possibly be the issue. – Pavlin Jul 04 '19 at 09:35

1 Answers1

0

setup_requires runs before install_requires and is only for the packages that make a sort of frame for the upcoming installers.

  1. You do not need to have the same package again in install_requires if you already had it in setup_requires.
  2. Since there might be dependencies during setup_requires workflow (>1.14 can be anything), you might run into new dependency issues when you try to install packages that need another numpy version.

You can get around this by setting the version with == or better, as you say it, just take it out of the setup_requires.

See "SSL certificate verify failed" using pip to install packages for a proof.

Side remark: setuptools should not be in the setup_requires list, see Should setuptools be in the setup_requires entry of setup.cfg files?.

questionto42
  • 7,175
  • 4
  • 57
  • 90