pypa / pip

The Python package installer
https://pip.pypa.io/
MIT License
9.52k stars 3.03k forks source link

'pip_version_check' in outdated.py does not respect local index-url within a virtualenv #4303

Closed cooperlees closed 7 years ago

cooperlees commented 7 years ago

Description:

Running pip commands in a virtualenv where no direct Internet connection is available to hang as it's trying to talk to pypi.python.org. We have a local PyPI Mirror (synced via bandersnatch) running that is reachable. It's configured as such:

[global] timeout = 10 index-url = https://pypi.somecompanyiworkfor.com/simple

What I've run:

pip freeze -v: http://pastebin.com/iL2ZtCaQ

dstufft commented 7 years ago

@cooperlees The problem is that the outdated code uses PyPI's JSON API and it sort of purposely talks directly to PyPI and ignores the local repositories so that a stale mirror doesn't keep people pinned back.

So there are a few options here:

cooperlees commented 7 years ago

Thanks for the quick reply! 1) I feel if people allow their local mirror to go stale that's their own problem 🤡 ... #monitoring

How about for now I look at a 'use_local_mirror_for_pip_upgrade' option in pip.conf and adding code to respect that for those who want it in outdated.py + deps?

dstufft commented 7 years ago

Yea, it can be done via configuration too (all of pip's options are available as a CLI flag, an environment variable, and configuration flag).

Overall though, I am generally against adding configuration options if we can help it. I'd personally prefer to just drop the use of JSON all together and rely on PackageFinder configured the same as pip install would to locate the latest version rather than adding a configuration option to switch between them. How the outdated check happens should be an implementation detail.

If this seems like something that would work for you, the quickest way to get this change in would be to submit a PR.

cooperlees commented 7 years ago

Working on a PR: https://github.com/pypa/pip/pull/4308

vphilippon commented 7 years ago

I think this has fallen in a crack and was fixed by #4336

cooperlees commented 7 years ago

Yes. That was me. Been waiting for 9.1.0 to confirm, but let's just assume it works for now.