New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setup.py sys calls break in a pip install #4474
Comments
Please post here what is the content of sys.argv in the failing case. |
I assume it's these lines, which start at line 217 in current master:
It's the least hacky thing we came up with so far to cover all the use-cases for A full traceback here would be helpful. As would a more detailed explanation of how to reproduce the issue. |
Digging in, I was able to isolate this to an issue associated with utilizing the
You can see the else clause is entered on the second execution of setup.py. I am not installing scipy itself via git, but I am installing my own packages that depend on scipy using the I just happened to hit this error while running Chef, but I suspect Chef is entirely unrelated. Anyway, I suspect the fix is to modify the conditional to include |
I can replace this. With numpy install things work, but in a clean virtualenv with
|
|
Probably fixed by gh-4475. EDIT: eh, probably not, since it fails on importing |
Is this actually even fixable on our side? |
@pv you're probably right. It's not easy to see from the output what exact commands pip uses, but it looks like it messes up. The |
Not related to this issue, but:
|
I'm pretty sure that it used to be necessary. The description of Numpy will be built twice in some (or all) cases, that's sub-optimal. But without it there's no guarantee that numpy is built and installed into a location visible for scipy before scipy is built. |
If your analysis is correct, that looks like a setuptools bug. |
Thanks @rgommers, happy to test if you like. |
@rgommers: note that the page says "setuptools will attempt to obtain these (even going so far as to download them using EasyInstall) before processing the rest of the setup script or command" --- it appears to me that the whole setup_requires stuff is designed only to deal with dependencies arising after setup() is called, so it will not help us here when our setup() comes from numpy. The egg-info stuff produced by |
@rgommers: comments on your PR, but it looks like the change to add develop may have gone in the wrong place? |
@malina-kirn: this issue is a bug in pip --- it should respect |
Hmm, I'll go back and look at why adding the |
That issue was gh-3566. I think it does work. Try:
When removing |
It's sort of documented here (at least it vaguely mentions |
And building numpy twice cannot be avoided if you want to build all dependencies in an isolated environment and install them in random order. At least |
Conclusion: I think my PR fixes this issue, first |
@rgommers: That the numpy egg is in the current directory does not appear to make |
I see yet another behavior. I can reproduce @pv results with Using python setup.py:
Using pip -e:
I'm not sure if the second installation mechanism is supposed to call generate_cython in this scenario or not. Certainly I don't need Cython for a typical install of scipy ( |
@malina-kirn: you mentioned earlier that the failures are sporadic --- the question is whether pip says (i) Which did it do for you? Also, what is your |
@pv you're correct, I also see that Don't know if this is a regression or if it never worked. There's a lot of issues for |
I'm going to give up on this one - enough time wasted on poorly implemented setuptools features. |
@pv Ah, indeed, it's undoubtedly an intermittent failure when using pip install -e. I haven't been able to reproduce it on my command line, but my Chef script hits it consistently. The Chef script indirectly installs scipy as a dependency of my own package, which I install via pip install -e. Likely a deterministic but non-ordered operation. I'm also using pip 1.5.6 on my laptop and Chef is configured to always get the latest pip via get-pip.py. I've put in a workaround in my VM installation by installing a version of numpy prior to installing my own package. If my package states a newer dependency on scipy and/or numpy, it will get updated. The only time this could cause problems is if the scipy setup.py file needs a newer version of numpy than I've referenced in the system install. But the numpy.distutils import has been in setup.py for a while, so it's unlikely I'll need to keep updating the Chef recipe with newer numpy releases to support the scipy install. In the meantime, I would like to file a bug against setuptools, but am not sufficiently-versed in setuptools to continue with follow-ups on the ticket. @pv, would you be willing to file this bug? I'd like to follow, but probably could not meaningfully contribute. @rgommers thanks for the attempt, I appreciate your attention to this matter. Would you like me to close this ticket - or would you like to keep open and/or close yourself? |
Update: my Chef VM reports pip --version of 6.0.6. Wow, big jump from 1.5 to 6.0! https://pip.pypa.io/en/latest/news.html Wonder if this is specific to pip 6? I wonder if this will always break in pip 6? |
@malina-kirn: The installation order indeed was changed in pip 6.0.x, see pypa/pip#1934 As to why it still fails: perhaps, you listed |
@pv: I've never had much luck changing the order of packages in I suspect pypa/pip/issues/1934 isn't related, since that ticket addresses issues in install_requires, whereas I think the problem here is related to pip not respecting setup_requires. |
The present issue can be solved by making either install_requires or |
Ah, I understand now. Thanks for the clarification. I tried digging around in that fix in pypa/pip#1934. Just reversing the requirements order doesn't seem to cover all use cases, as far as I can tell. On a hunch, I removed numpy from my own install_requires, to see if relying on scipy's install_requires fixed the issue. That worked. I'm guessing, but I think by putting numpy in my own install_requires, both scipy and numpy end up being put in the same set of requirements at the same 'level.' Whereas, if I rely on scipy to install numpy for me, I suspect that my own dependency on scipy gets called after scipy's dependency on numpy is called. I'm not a huge fan of relying on transitive package dependencies to install packages that I actually need for my own code. But this does seem like a viable workaround. |
I'm installing python + various packages (including scipy) using the python Chef recipe. I execute various pip install commands wrapped by the pip API provided by this Chef recipe.
Unfortunately, the setup.py file from scipy Lines 217-219 makes calls to get system arguments in an attempt to determine whether or not the setup is being run through pip. In Chef, these checks don't appear to work and the install script enters the else conditional. The else conditional imports numpy on Line 237. Since I'm using pip to install everything, sometimes numpy is installed prior to scipy setup.py being called, sometimes it isn't. Consequently, I get intermittent installation failures when installing scipy.
I don't fully understand the motivation behind the else block, but assume it's in there for a good reason.
The conditional statement in setup.py Lines 217-219 is terribly hacky. I don't know if there's a better way to determine if setup.py is being called from pip - the only similarly hacky workaround I can think of is to step through the process IDs of the current process and its parents to see if any of them contain pip. Yuck. Any thoughts on how to resolve this?
The text was updated successfully, but these errors were encountered: