-
Notifications
You must be signed in to change notification settings - Fork 144
Closed
Description
GitHub Actions provide no TTY, so colorama import wraps stdout and strips all colors tartley/colorama#209 (comment) so even forcing colors doesn't work.
2022-06-30T17:00:45.4633499Z Successfully installed build-0.8.0 pep517-0.12.0 tomli-2.0.1
2022-06-30T17:00:46.1506025Z ##[group]Run python -m build
2022-06-30T17:00:46.1506287Z �[36;1mpython -m build�[0m
2022-06-30T17:00:46.1506499Z �[36;1mgit status --ignored�[0m
2022-06-30T17:00:46.1559508Z shell: /usr/bin/bash -e {0}
2022-06-30T17:00:46.1559700Z env:
2022-06-30T17:00:46.1559871Z FORCE_COLOR: 1
2022-06-30T17:00:46.1560056Z ##[endgroup]
2022-06-30T17:00:46.6361795Z * Creating venv isolated environment...
2022-06-30T17:00:49.6232262Z * Installing packages in isolated environment... (setuptools >= 40.8.0, wheel)
2022-06-30T17:00:52.0028343Z * Getting dependencies for sdist...
Took me a while to debug this. Added some debug statements.
--- a/src/build/__main__.py
+++ b/src/build/__main__.py
@@ -49,6 +49,7 @@ def _init_colors() -> Dict[str, str]:
_STYLES = _init_colors()
print(_STYLES)
+print('{red}ERROR{reset} {}'.format("msg", **_STYLES))
def _showwarning(
message: Union[Warning, str],
@@ -65,6 +64,7 @@ def _showwarning(
def _setup_cli() -> None:
+ print('{red}ERROR{reset} {}'.format("precolorama", **_STYLES))
warnings.showwarning = _showwarning
try:
@@ -73,6 +73,7 @@ def _setup_cli() -> None:
pass
else:
colorama.init() # fix colors on windows
+ print('{red}ERROR{reset} {}'.format("postcolorama", **_STYLES))
def _error(msg: str, code: int = 1) -> NoReturn: # pragma: no coverAnd got this.
The solution is to enable colorama only on Windows.
Metadata
Metadata
Assignees
Labels
No labels
