pipenv icon indicating copy to clipboard operation
pipenv copied to clipboard

Use index-url in /etc/pip.conf

Open WqyJh opened this issue 5 years ago • 2 comments

Hello, everyone! I don't know why not use index-url defined in /etc/pip.conf.

Currently, pipenv use source.url in Pipfile and a runtime option --pypi-mirror to specify the pypi index page. In my mind, this is not a smart design.

First of all, why should any body write the url in their source code. If someone is working on an opensource project and he use his closest mirror site and write the url in the source code. Other people have to modify the url first to run his code. If he is an developer, his Pipfile and Pipfile.lock would be changed, should he include this change in the SCM? For his convenience, he should include this change. But when he open pull requests to upstream, it's hard to process.

Second, using --pypi-mirror to specify mirror, which is really annoying. Developers from different place would have different command line. Imagine, every time they want to use pipenv, they have to type the --pypi-mirror option with a long url. It's really bad experience. What's more, developers usually have their /etc/pip.conf configuration since they start to play with python, but they still have to type that long url already defined in /etc/pip.conf. For some automation tool, they have to modify all command line relative with pipenv add that annoying option.

As far as I'm concerened, the /etc/pip.conf is the best design to specify the pypi mirror. Which is

  • Non-intrusive: no need to hardcoded in source code, no need to type for every command
  • Compatible with pip: painless for pip user to migrate
  • Humanity: makes people happy using pipenv

WqyJh avatar Dec 07 '19 10:12 WqyJh

Would need to consider the current behavior of pipenv==2022.8.19 with regards to index restricted packages being required to explcitly define package indexes in the Pipfile or use the default. Another thing is if you are using a mirror right now, you are going to have a longer locking phase because only the pypi URL checks for the json package API for pre-fetching the package hash information.

matteius avatar Aug 22 '22 02:08 matteius

Started working on this, but it needs more work: https://github.com/pypa/pipenv/pull/5297

matteius avatar Sep 13 '22 15:09 matteius

@WqyJh Would you be willing to test if this PR which is up to date with main and passing, which reads the pip.conf or `pip.ini? I still need to write documentation for it but I could use some help validating that it does what is expected, and if there are any config values that are ignored: https://github.com/pypa/pipenv/pull/5297

matteius avatar Jan 27 '23 02:01 matteius

pipenv==2023.2.18 has been released with support for this feature enabled by default.

matteius avatar Feb 18 '23 22:02 matteius