jazzband / pip-tools

A set of tools to keep your pinned Python dependencies fresh.
https://pip-tools.rtfd.io
BSD 3-Clause "New" or "Revised" License
7.67k stars 608 forks source link

Allow force-enabling or force-disabling colorized output #2041

Closed aneeshusa closed 7 months ago

aneeshusa commented 7 months ago

click allows emitted colored text via click.style, which is used by pip-compile to emit colorized e.g. comments to stderr. click uses auto-detection to only enable colors when writing to a TTY.

At Lyft, we operate pip-compile as a service: pip-compile invocations are forwarded to a set of remote machines, which leverage a shared cache for much faster compiles. However, they run pip-compile as a subprocess without a TTY attached meaning the output we stream back to the user is not colorized.

Therefore, add a --color and matching --no-color argument to force-enable as well as force-disable color (the default remains click's auto-detection). This could also be used for e.g. running pip-compile in CI.

AFAIK pip-sync does not emit colored output, so I did not add the --color/--no-color options there.

Contributor checklist
Maintainer checklist
aneeshusa commented 7 months ago

Thank you for taking a look @chrysle!