-
Notifications
You must be signed in to change notification settings - Fork 3.1k
pip offline behaviour #4753
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
Comments
I'm curious what your use case/motivation here is... I feel it to be more deterministic to download the required files (with a guaranteed internet connection) and then install these downloaded packages (using |
So a few cases, that should all work using the same command:
Use cases might be:
I suppose that it could boil down to not having to provide different commands for pip based on the state of the network connection. In particular, I feel that the commands already available aren't being used intuitively in the case that the system is offline (namely the I don't think this would change the determinism of pip, because if a user has explicitly specified a |
ref: #4321 maybe. (I'm not the best person to comment on this; I'll let someone else take it from here) |
This is unlikely to be something that we're going to do. It's not possible for us to know if you mean to have a network connection or not, so the only thing we can do is what we do now-- try and eventually timeout. This use case you're talking about is probably better suited to running a local DevPI mirror, which will let you work in offline and online cases and will automatically keep your local package cache up to date. |
I appreciate your response but I suspect I failed to explain what is actually causing the problem (I recommend trying the repro steps in the PR to see what the pain point is). In particular, it's not that we have to detect whether we have an internet connection, just that an index is unreachable, and typically that is unlikely to change over the course of a As such, I've investigated a way of getting this working. I hope the PR referenced above clearly demonstrates a solution. This might more adequately demonstrate the core behaviour that was causing excessively long installation times ("don't keep trying it for every single package" as above). I would maintain that usage of pip offline is still a valid use case even in the event that a DevPI mirror is available - because the only way to avoid the excessive timeouts is to use FWIW there's quite a lot of questions on SO about usage offline - without examining every one, it seems to me that offline is definitely one of the use cases for pip, even if it was not originally intended to be. |
There's a dilemma here in that if we mark a URL as invalid when it times out (and so improve the time for offline use) we also cause a transient problem to block any use of the same URL, when later uses might have worked. And I don't think there's many people who need to use pip while offline, and yet for some reason cannot simply add Finally, while I haven't gone through the SO search you posted in detail, I'd imagine a lot of those users would be completely satisfied with |
Thanks for your response, I'll try and answer each of your points. I appreciate that triaging is hard and possibly thankless work, but I assure you I appreciate it and have thought about this.
Yes, I agree conceptually - when corner-case hunting this pops up straight away. But I'm not sure in reality that this would have much effect.
So the user has to determine whether they (or any index) are offline and then change the commands to the program? I don't agree with this approach - it makes it harder to use, less reproducible and less scriptable. Robust programs should deal with network failure gracefully.
Have you tried running the example I posted in the PR? I used
Sorry, I don't run a programmers collective or polling agency! But as a user it is patently better to have to take no action and have the program work, than take some action. If we add a switch, one could replace |
OK. Thanks for your detailed reply. However, I agree with @dstufft, this isn't something we're likely to implement. If someone were to raise a PR for this, it would be reviewed, but there's obviously no guarantee that it would be accepted even in that case. |
I strongly suspect you're not reading my replies. There is already a PR here: #4763 |
No, I simply missed that. Thanks for the pointer. |
Description:
Installing packages from disk when offline:
When no internet connection is available, pip should reprioritise
--find-links
or local URIs.Instead, what happens is it repeatedly tries and fails (with urllib3) to fetch from online URIs. It then falls back to using local ones. For every single package.
I feel this is not resolved using the
--no-index
as, if a connection were available, I would expect pip to make use of it.I would expect one of these three behaviours instead:
What I've run:
I have also tried numerous variations on this including
pip download
(i.e. using the pip download cache instead of a local repo) and others.-i
vs--extra-index-url
etc. Seemingly whichever combination or ordering of parameters, it will try to hit the internet first.The text was updated successfully, but these errors were encountered: