<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Jan 6, 2019 at 12:45 PM Thomas Robitaille <<a href="mailto:thomas.robitaille@gmail.com">thomas.robitaille@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi all,<br>
<br>
Back in December I started getting failures in continuous integration<br>
as well as reports of failures from users of installation issues for a<br>
couple of packages. The problem can be easily reproduced in a Docker<br>
container with:<br>
<br>
   FROM ubuntu:16.04<br>
   RUN apt-get update<br>
   RUN apt-get install -y python3 python3-dev python3-pip python3-wheel<br>
   RUN pip3 install fast-histogram<br>
   RUN python3 -c 'import fast_histogram'<br>
<br>
Doing this results in the following traceback:<br>
<br>
   ImportError: No module named 'numpy.core._multiarray_umath'<br>
   Traceback (most recent call last):<br>
     File "<string>", line 1, in <module><br>
     File "/usr/local/lib/python3.5/dist-packages/fast_histogram/__init__.py",<br>
line 1, in <module><br>
       from .histogram import *<br>
     File "/usr/local/lib/python3.5/dist-packages/fast_histogram/histogram.py",<br>
line 7, in <module><br>
       from ._histogram_core import (_histogram1d,<br>
   ImportError: numpy.core.multiarray failed to import<br>
<br>
I've seen similar issues with other packages too. The key is that the<br>
fast-histogram package defines:<br>
<br>
   setup_requires=['numpy']<br>
<br>
in the setup.py (since the package has a C extension that uses the<br>
Numpy C API) and numpy is needed before the install_requires<br>
dependencies are installed:<br>
<br>
   <a href="https://github.com/astrofrog/fast-histogram/blob/master/setup.py" rel="noreferrer" target="_blank">https://github.com/astrofrog/fast-histogram/blob/master/setup.py</a><br>
<br>
Now this normally works fine, but the issues I saw started when the<br>
first 1.16 RC was made available, when installing into an environment<br>
in which numpy is not already installed.<br>
<br>
My understanding is that setup_requires is honored by easy_install<br>
(even if installing the main package with pip), which doesn't ignore<br>
pre-releases. Thus, the package is built against the 1.16 RC but then<br>
1.15 is installed due to:<br>
<br>
   install_requires=['numpy']<br>
<br>
which is honored by pip.<br></blockquote><div><br></div><div>Oh fun. Thanks for explaining this!</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
I think that the correct solution is to make sure that:<br>
<br>
   [build-system]<br>
   requires = ["setuptools", "wheel", "numpy"]<br>
<br>
is added to the pyproject.toml file (as per PEP 518). </blockquote><div><br></div><div>To clarify: you're talking about fast-histogram's pyproject.toml file right?<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This then works<br>
properly with recent versions of pip (>10 I think). I think removing<br>
setup_requires then makes sense because it'd be better to have an<br>
error with older versions of pip that numpy is not installed rather<br>
than having the package built against the wrong version.<br></blockquote><div><br></div><div>This is a pretty hacky solution, needed because pip doesn't support setup_requires, but yes it should work and I can't think of a better way.<br></div><div><br> </div><div>Cheers,<br></div><div>Ralf</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
I know this is a temporary issue in the sense that it will go away<br>
once the final version of 1.16 is out, but I just wanted to share this<br>
as a heads-up in case you get reports of issues from other people, and<br>
also to check whether there are any other solutions/workarounds to be<br>
aware of? (to avoid a similar situation in future).<br>
<br>
Thanks,<br>
Tom<br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div></div>