[Numpy-discussion] specifying numpy as dependency in your project, install_requires

Ralf Gommers ralf.gommers at gmail.com
Fri Sep 21 16:13:41 EDT 2012


Hi,

An issue I keep running into is that packages use:
    install_requires = ["numpy"]
or
    install_requires = ['numpy >= 1.6']

in their setup.py. This simply doesn't work a lot of the time. I actually
filed a bug against patsy for that (https://github.com/pydata/patsy/issues/5),
but Nathaniel is right that it would be better to bring it up on this list.

The problem is that if you use pip, it doesn't detect numpy (may work
better if you had installed numpy with setuptools) and tries to
automatically install or upgrade numpy. That won't work if users don't have
the right compiler. Just as bad would be that it does work, and the user
didn't want to upgrade for whatever reason.

This isn't just my problem; at Wes' pandas tutorial at EuroScipy I saw
other people have the exact same problem. My recommendation would be to not
use install_requires for numpy, but simply do something like this in
setup.py:

    try:
        import numpy
    except ImportError:
        raise ImportError("my_package requires numpy")

or

    try:
        from numpy.version import short_version as npversion
    except ImportError:
        raise ImportError("my_package requires numpy")
    if npversion < '1.6':
       raise ImportError("Numpy version is %s; required is version >= 1.6"
% npversion)

Any objections, better ideas? Is there a good place to put it in the numpy
docs somewhere?

Ralf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120921/41a8c20f/attachment.html>


More information about the NumPy-Discussion mailing list