What's the problem this feature will solve?
I'm running pip install -r requirements.txt
at each deployment to keep my third-parties up to date with the code. With several dozens of requirements, the log is pretty big, while I don't really care to know that 99 % of the libs was "already satisfied" from one deployment to the next one. The worst is sub-dependencies are also shown, so in fact I can get up to 200 lines displayed...
Most of the execution trace is:
Requirement already satisfied: setuptools==36.6.0 in my_venv/lib/python3.5/site-packages (from -r requirements.txt (line 8)) (36.6.0)
Requirement already satisfied: Django==2.1.2 in my_venv/lib/python3.5/site-packages (from -r requirements.txt (line 9)) (2.1.2)
Requirement already satisfied: django-formtools==2.1 in my_venv/lib/python3.5/site-packages (from -r requirements.txt (line 10)) (2.1)
Requirement already satisfied: djangorestframework==3.7.7 in my_venv/lib/python3.5/site-packages (from -r requirements.txt (line 11)) (3.7.7)
Requirement already satisfied: django-rest-framework-mongoengine==3.3.0 in my_venv/lib/python3.5/site-packages (from -r requirements.txt (line 12)) (3.3.0)
[...]
Requirement already satisfied: pycparser in my_venv/lib/python3.5/site-packages (from cffi>=1.4.1->cryptography>=1.1->fabric==2.3.1->-r requirements.txt (line 93)) (2.14)
Describe the solution you'd like
I would like to be able to hide those warnings with a simple command argument. For example:
pip install -r requirements.txt --no-warn-already-satisfied
Alternative Solutions
It seems that -q
is doing the job, but it is hiding in fact all log message at INFO level, so new installations get hidden too... I still want to monitor that so I can log any environment changes from my deployment log.
For now, the only viable solution is to use standard UNIX tools, and exclude those lines with grep
: https://stackoverflow.com/questions/36350951/hide-requirement-already-satisfied-warning It does work, but it could be better :)
Additional context
The name --no-warn-already-satisfied
would be consistent with other options that already exists in pip install
arguments, such as no-warn-conflicts
and no-warn-script-location
Regarding consistency, the problem with no-warn-already-satisfied
is that those already-satisfied messages are not warnings (both examples you gave are).
It seems like a more scalable approach would be for pip to let one pass one or more "ids" of messages to suppress (like how Django, flake, etc. operate).
Then there wouldn't need to be a separate flag for each message (of which there can be very many). Also, allowing message ids would make it easier to support suppressing many different messages without having to open a separate PR for each one.
I like @cjerdonek's suggestion here.
It's definitely more scalable and makes more sense to allow.
I like the proposed approach too. I did not look into pip before, but indeed the "already met" messages are coming from a log.info
statement, so a "--no-warn" flag would not be consistent.
The idea of having a keyword-code for each type of output and being able to disable one or many in a single command line argument seems to resolve most of the use cases I guess, and we could even suppress the no-warn-conflicts
and no-warn-script-location
arguments in the long term.
a temporary solution could be:
pip install -r requirements.txt | grep -v 'already satisfied'
works really well for me
My pip install -r requirements.txt command is in a Makefile but is followed by && so the "| grep -v already" breaks the &&.
pip install -r requirements.txt && another_command
It would be nice to have an option to quiet these messages.
My pip install -r requirements.txt command is in a Makefile but is followed by && so the "| grep -v already" breaks the &&.
pip install -r requirements.txt && another_command
It would be nice to have an option to quiet these messages.
I think you could do pip install -r requirements.txt | grep -v 'already satisfied' || true
The negative effect of such an approach seems to be the fact that if the "pip install" fails, then the whole statement does not error out and the entire script continues...
I removed the "discussion needed" label as I think we agree the right way to fix this is to address: https://github.com/pypa/pip/issues/6119
Rather than closing as a duplicate, I'll leave this open for easier discoverability and since there's not much harm.
My pip install -r requirements.txt command is in a Makefile but is followed by && so the "| grep -v already" breaks the &&.
pip install -r requirements.txt && another_command
It would be nice to have an option to quiet these messages.I think you could do
pip install -r requirements.txt | grep -v 'already satisfied' || true
The negative effect of such an approach seems to be the fact that if the "pip install" fails, then the whole statement does not error out and the entire script continues...
The solution to the above seems to be the following:
set -o pipefail; pip install -r requirements.txt | { grep -v "already satisfied" || :; }
which errors out if pip install errors out, but does not error out if grep errors out i.e. does not output anything, and grep filters out unneeded output.
Most helpful comment
a temporary solution could be:
works really well for me