pipenv: pipenv doesn't respect pip.conf
I’m using devpi as a private pypi repository where I can proxy cache pypi packages and add my own in-house packages.
My pip.conf
looks like the following:
[global]
index_url = https://pypi.priv.xxx/prod/+simple/
[search]
index = https://pypi.priv.xxx/prod/
Couldn’t find another issue mentioning this problem.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 30
- Comments: 22 (6 by maintainers)
These entries need to go into your Pipfile.
These entries may contain credentials which certainly won’t go into the Pipfile which is supposed to go into the project repo.
@hrbonz @ninrod @GhostofGoes fixed in #1769 and #1809 – environment variables in Pipfiles are now expanded at runtime
Thanks all for your patience, our highest priority has been the core functionality of the codebase, so features like this one tend to slip through the cracks. Always happy to discuss contributions for items we aren’t currently prioritizing however!
gentleman, seriously. I have a simple use case that directly is affected by this issue.
I have a project that uses pipenv. I write this project both at home and at work. At home, I have no problem. At work, I have to use the internal pipy index.
As the Pipfile is commited and pushed to git, I cannot keep changing it as I hop from home to work. I would like to have an external configuration that signals to pipenv that I have to use another index.
putting this config inside the Pipfile does not work.
@kennethreitz I don’t think I’ve made my case really clear so let me try to convince you with some use cases I’ve run into while getting started with pipenv. First of, I’m just starting to dive into pipenv, how it works and its code. I know that you can specify a source in
Pipfile
, I also saw you can use named indexes, that looks similar to what can be done in~/.pypirc
.Creating a new pipenv project/environment
Install a package from an additional index
When installing a package that pypi doesn’t know, it won’t work right away (it does work with pip or pip-tools as they use
pip.conf
settings).If
Pipfile
gets set with a new index and the package is associated with this index (following https://docs.pipenv.org/advanced.html#specifying-package-indexes), trying to install the package from the command line will callpypi
first anyway:Use a requirement file generated by
pip-tools
When using
pip-tools
, the requirements file will start with the index used to install packages:This setting is not respected when using the requirement file (starting with a clean project):
Observations
I feel that there is some sort of “gap” in the handling of indexes and the UX:
Pipfile
and associate every package with an index. That’s not very convenient in the case of a bunch of packages from pypi and only one from a private index.I’m diving in the code to provide a PR to cover the problems exposed above:
pip.conf
for custom indexesPipfile
to be used when none is specifiedPipfile
If an index is used either in a requirement file or on the command line but is unknown to
Pipfile
then an entry should be added with an automatic name similar to the venv naming used in pipenv.Why do I care so much? Living in China, pypi is not always available or fast (numerous timeouts or dead slowness) so having an index like devpi that caches and allows me to mix my private packages is a double win. That makes our dev, testing, docker builds, etc way faster.
As an example, this is a pretty classic behavior happening when timeouts get involved:
I like the idea of being able to put those configs in
Pipfile
(to easily share the config to other devs), but pipenv definitively must also respectpip.conf
(resort to it for anything not defined in Pipfile).Any updates on this?
@kennethreitz Nope. For real example, I live in China. The speed to pypi.python.org is usually lower than 50k/s , I have to set a global china mirror. Or I would see a lot of
So, you mean every time I use pipenv need to write a pip.conf[Pipfile] for it ? It is unacceptable for me.
Kindly reopen the issue, or please offer other suggestions for making sure this feature gets more attention.
One way of circumventing this is by using an environment variable PIPENV_PYPI_MIRROR to point to your private mirror that caches pypi. See https://pipenv.pypa.io/en/latest/advanced/#using-a-pypi-mirror
Then the standard PyPi specified in your Pipfile can point to the official mirror. That said, it still better if pipenv would respect pipconf!
Hi, @kennethreitz thanks for awesome project.
I have question, will you reconsider Your position on that issue after arguments brought into that discussion?
I have another very similar use case with pip.conf and having credentials in seperate pip.conf file is valid for having predictable build on CI/CD pipeline and local dev machine.
@hrbonz for now I found solution to use just
$PIP_INDEX_URL
env variables from pip until pip.conf file will be supported by pipenv. Those$PIP_VARIABLE
could be sourced for now from.env
file.Can we reopen this issue? pipenv is a really convenient tool, but this particular issue where pipenv does not respect pip.conf is a noticeable pain point, to the point that I just resort to using venv.
I think that combining pypa/pip#3728 and custom indexes would be the solution for private indexes without exposing credentials. Also commented in #1406.
For me, it is. I really need a global mirror settings.
pip.conf is follow:
respect pip.conf means pip user can switch to pipenv seamlessly.
I came here to file exactly this bug. I’ve had to ditch pipenv because it doesn’t respect the pip configuration, and as has been discussed here in this issue, the configuration of PyPi mirrors or alternate indexes is generally not something that can be put into the PIpfile.