Enable colours when FORCE_COLOR env var is set
See original GitHub issueWhat’s the problem this feature will solve?
pip 22 now uses Rich for installation progress bars and some error handling, which gives us pretty colours!
Colour can help diagnose problems, and a common place for pip and the need to diagnose problems is on a CI.
However, because the GitHub Actions isn’t a tty, output of tools which autodetect the terminal output is usually monochrome. That’s why many tools and CI setups use the FORCE_COLOR
environment variable, and/or command-line options to turn it back on.
The pip CI included (#10830):
However, pip itself (and Rich) don’t use FORCE_COLOR
, meaning we get monochrome output:
Compare with nox:
https://github.com/pypa/pip/runs/5177210581?check_suite_focus=true
And pytest:
https://github.com/pytest-dev/pytest/runs/5185781927?check_suite_focus=true
Describe the solution you’d like
Enable colour when FORCE_COLOR
is set.
For reference:
Alternative Solutions
Get Rich to support FORCE_COLOR
directly. This was considered in 2020 but rejected in https://github.com/Textualize/rich/issues/343 to leave it up to the developer to support it.
But Will said “I may yet relent on this. I try to be pragmatic!” so it may still be a better option 😃
Additional context
I’m not specifically requesting it here, but could be worth considering also disabling when NO_COLOR
is set: https://no-color.org/
Similarly not requesting it here, but for completeness I’ll mention pytest also has this command-line option:
--color=color color terminal output (yes/no/auto).
And nox:
--nocolor, --no-color
Disable all color output.
--forcecolor, --force-color
Force color output, even if stdout is not an interactive terminal.
Whereas pip only has the negative:
--no-color Suppress colored output.
Code of Conduct
- I agree to follow the PSF Code of Conduct.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:19 (15 by maintainers)
Top GitHub Comments
@willmcgugan This would be great! What’s the next step? Would you like an issue created at https://github.com/Textualize/rich?
Yeah. That would be indeed very useful. Colors in CI are great for visual communication (as otherwise you end up with big blob of text) - especially that often in Ci you enable pretty verbose output to be able to diagnose problems. Nany tools allows forcing colors indeed so it woud be useful to have it in ‘pip’. Happy to help and create a PR for that one if preferred way to do it is agreed to by the maintainers…