Command-line arguments to pip install should take precedence over options configured in requirements.txt
See original GitHub issue- Pip version: 8.1.1
- Python version: 2.7.11
- Operating System: Ubuntu 16.04
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:
pushd $(mktemp -d) >/dev/null
virtualenv -q .
source bin/activate >/dev/null
pip install -qU pip
echo "\
--index-url=https://example.com/DONOTQUERY
examplethatdoesnotexist
" > r.txt
pip install --isolated --index-url=https://pypi.python.org/simple/ -vr r.txt > log
grep DONOTQUERY -B 2 log && echo "Queried https://example.com/DONOTQUERY"
grep pypi log || echo "Did not query pypi.python.org"
This outputs
Collecting examplethatdoesnotexist (from -r r.txt (line 2))
1 location(s) to search for versions of examplethatdoesnotexist:
* https://example.com/DONOTQUERY/examplethatdoesnotexist/
Getting page https://example.com/DONOTQUERY/examplethatdoesnotexist/
Starting new HTTPS connection (1): example.com
"GET /DONOTQUERY/examplethatdoesnotexist/ HTTP/1.1" 404 606
Could not fetch URL https://example.com/DONOTQUERY/examplethatdoesnotexist/: 404 Client Error: Not Found for url: https://example.com/DONOTQUERY/examplethatdoesnotexist/ - skipping
Queried https://example.com/DONOTQUERY
Did not query pypi.python.org
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”.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:11 (4 by maintainers)
Top Results From Across the Web
User Guide - pip documentation v22.3.1
Logically, a Requirements file is just a list of pip install arguments placed in a file. Note that you should not rely on...
Read more >User Guide — pip 10.0.0.dev0 documentation
Logically, a Requirements file is just a list of pip install arguments placed in a file ... Command line options have precedence over...
Read more >How to maintain pip install options in requirements file ...
In new virtualenv, try to install same project from requirements. txt . pip builds the C extension for pymongo :( (test2)day@office:~/test2$ ...
Read more >pip Documentation
Command line options have precedence over environment variables, which have precedence ... pip install --download DIR -r requirements.txt.
Read more >User Guide — pip 8.1.1 documentation
pip freeze > requirements.txt pip install -r requirements.txt ... Command line options have precedence over environment variables, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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.