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
Command-line arguments to pip install should take precedence over options configured in requirements.txt #3614
Comments
@pypa/pip-committers Thoughts? |
The order of priority should certainly be clearly defined in the docs. I haven't checked - is it? As to whether the current order is correct or not, I'm unclear. What is established practice for other, similar programs? I'd like to see a non-artificial use case that demonstrates why the proposed behaviour is better than the currently implemented one. (As a counter to the proposal, if you have a requirements file with private packages and an |
We have a case where we have a local pip server which we use in development. So our requirements file includes For deployment we build the wheels and package them up in an RPM, and have the RPM spec file install the requirements with A quick test using my local venv and an internal package. First uninstall it and check
Now try using both flags on the command line:
Which is what we want. (Although what would be expected when both flags are used is an another question - maybe it should be an error? At any rate I don't really mind.) Next try using the set up we have, with
This case is where I want the command line arguments to override the flags in the requirements file. As to what other systems do, I found this answer on stack overflow about precedence which broadly agrees with my understanding, as does Microsoft ASP.NET and these two python packages. |
IMHO, it would make sense for the user to be able to override any config. Perhaps, the user is a CI system with its own package index cache. Shouldn't the user be the ultimate decision maker? I struggle to recall software where this is not the case. |
Honestly, I'm personally not sure how we want to handle this situation. I do think this is a valid feature request that would need to be investigated further. |
I have a use case for this. We have an internal index which is accessible by developers and our CI, however the index is overridden in a deployment environment in order to use a different internal index that is always accessible to production servers in the case of network outages. I believe it's quite standard for command-line arguments to override config options. |
First: thanks for the awesome work with pip! I just stumbled across this and while it seems to have not many attention, I think it really is a game breaker.
Yes and no: https://pip.pypa.io/en/stable/user_guide/#config-precedence clearly described the precedence of config files, environment variables and cli arguments, but neither there nor in https://pip.pypa.io/en/stable/reference/pip_install/#requirements-file-format the precedence of in-line options in requirements files is clarified. My humble option: these should be in between env variables and cli arguments, thus overwriting all configuration done in ones environment (config files and env variables) but being overwritten by explicit cli arguments. I have the following usecase (similar to #3614 (comment)):
|
I also would like to see more clear precedence order in the documentation. As @dquitmann-op pointed out, the current documentation doesn't mention that configuration in requirements.txt take precedence over everything. Nevertheless, I believe the configuration in the requirements.txt should not take precedence over command-line and global environment variables for security and other reasons. |
Happy to accept a PR adding this information to the documentation! ^.^ |
@pradyunsg I am happy to do it but I am not 100% sure if all options in requirements.txt take precedence over command line, environment and local configuration. Still, I wouldn't consider this issue as just documentation. I think the suggestion of removing the precedence of options in requirements.txt is relevant. Do you agree with that? |
First of all, thanks for a job well done with pip! |
Description:
Command-line arguments to
pip install
should take precedence over options configured in requirements.txt files. For example, if--index-url
is specified on the command-line, then it should override the index-url set in a requirements.txt file.What I've run:
This outputs
I would expect that the location searched for
examplethatdoesnotexist
would be the one specified on the command line "https://pypi.python.org/simple/" not the one specified in the requirements.txt file "https://example.com/DONOTQUERY".The text was updated successfully, but these errors were encountered: