-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Enable colours when FORCE_COLOR env var is set #10909
Comments
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.. |
Let's also ping @willmcgugan from Rich: do you think it would be better for Rich itself to use I think it would: better to do things upstream and it would mean other users of Rich would also benefit. Please let me know if I should instead comment in Textualize/rich#343 or open a new Rich issue. |
I don't want to add FORCE_COLOR to Rich because on some apps Since there is no sane standard at the moment, I'd prefer to leave it up apps to decide how to do it. Fortunately it is trivial to implement it how you wish. |
Agree with @willmcgugan :). Also not everyone uses |
Okay, thanks Will! For pip: I checked the top 5,000 PyPI packages (with help from this and that):
The top four all just check for any value of the env var (difference in the order of precedence). Those four account for over 98% of the downloads of these eight. So how about pip (55%) follows the pytest pattern? |
I have some good news, apparently colorama also approved adoption of a sister change tartley/colorama#230 (comment) and will likely be merged soon. Based on the stats I seen, I think we have a clear winner. I know that two vars is less ideal but having this is still far better than one variable for each command line tool!. At least people recognized the pattern and moved on. To be honest any generic environment variable is much better than Funny that I see myself explaining the same thins I already did two years ago on rich, while the proposal was refused. I do hope that maybe in 2022 we might be able to realize that making the life easier for most users should be a priority. |
Wait, so there no way to enable color at all? |
I thought |
I could do some tests on both local terminals and also on github actions to test if everything is working as expected and if we can close this bug. Still, i kinda find hard to convince pip to produce some colored output when there is nothing to download and I do not want to reset my cache. Is there a specific command I can use to produce something colored? |
If |
Hi @willmcgugan! I suppose that |
@willmcgugan This would be great! What's the next step? Would you like an issue created at https://github.com/Textualize/rich? |
Sure. |
@hugovk @willmcgugan I am happy to remove that feature from enrich once rich adopts it. With bit of luck, I might even see the day the entire wrapper (enrich) becomes obsolete. |
Posted at Textualize/rich#2425! :) |
@pradyunsg how about refreshing the vendored copy of rich? Textualize/rich#2449 |
That should happen automatically when we re-vendor prior to the 22.3 release. |
See also #11515 |
Last time i checked it wasn't the 1960's. So I think the CI could be colorized. Configured pytest, tox, mypy(#7771) and pip¹ (I already already colorized black and isort when I initially added them) 1: Pip doesn't work yet pypa/pip#10909, so this is just a placedholder for when it (hopefully) soon will. Co-authored-by: KotlinIsland <[email protected]>
I think we're all set now, thanks all for working on this! |
What'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):
pip/.github/workflows/ci.yml
Lines 14 to 17 in 4a508c2
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 Textualize/rich#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:
And nox:
Whereas pip only has the negative:
Code of Conduct
The text was updated successfully, but these errors were encountered: