Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 309057 - python.eclass: _python_set_color_variables(): Disable colors by default
Summary: python.eclass: _python_set_color_variables(): Disable colors by default
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: High minor (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-11 20:41 UTC by Samuli Suominen (RETIRED)
Modified: 2010-07-25 03:58 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
python.eclass.patch (python.eclass.patch,12.75 KB, patch)
2010-07-18 02:27 UTC, SpanKY
Details | Diff
distutils.eclass.patch (distutils.eclass.patch,4.65 KB, patch)
2010-07-18 04:57 UTC, SpanKY
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Samuli Suominen (RETIRED) gentoo-dev 2010-03-11 20:41:11 UTC
This should be something that looks same across the tree, and IMHO we shouldn't allow random eclasses or ebuilds define their own format. It's a job for the Package Manager, and if it's not coming from there, it should at least match it.

python.eclass:

_python_set_color_variables() {
        if [[ "${NOCOLOR:-false}" =~ ^(false|no)$ ]]; then
                _BOLD=$'\e[1m'
                _RED=$'\e[1;31m'
                _GREEN=$'\e[1;32m'
                _BLUE=$'\e[1;34m'
                _CYAN=$'\e[1;36m'
                _NORMAL=$'\e[0m'
        else
                _BOLD=
                _RED=
                _GREEN=
                _BLUE=
                _CYAN=
                _NORMAL=
        fi
}

Example of `emerge -C gnofract4d` when it hits pkg_postrm (cleaning up byte-compiled python).

<snip>

 [32;01m*[0m [1;34m<<< /usr/lib64/python2.6/site-packages/fractutils/get.py[co][0m
 [32;01m*[0m [1;34m<<< /usr/lib64/python2.6/site-packages/fractutils/formulas.py[co][0m
 [32;01m*[0m [1;34m<<< /usr/lib64/python2.6/site-packages/fractutils/test_flickr.py[co][0m
 [32;01m*[0m [1;34m<<< /usr/lib64/python2.6/site-packages/fractutils/makemap.py[co][0m
 [32;01m*[0m [1;36m<<< /usr/lib64/python2.6/site-packages/fractutils[0m

^ Unstandard colors, not with-in the Gentoo format.

 [32;01m*[0m Updating desktop mime database ...
 [32;01m*[0m Updating shared mime info database ...

</snip>
Comment 1 Samuli Suominen (RETIRED) gentoo-dev 2010-03-11 20:51:30 UTC
Bolded red from deprecation warning (sci-libs/vtk):

[31;01m*[0m 
 [31;01m*[0m [1;31mDeprecation Warning: python_version() is deprecated and will be banned on 2010-07-01.[0m
 [31;01m*[0m [1;31mUse PYTHON() instead of python variable. Use python_get_*() instead of PYVER* variables.[0m
 [31;01m*[0m 
Comment 2 SpanKY gentoo-dev 2010-03-11 21:20:21 UTC
yes, that function needs to be tossed.  we have a color standard integrated with portage that allows people to customize for their own preferences.  this completely ignores that for literally 0 gain.
Comment 3 Mark Loeser (RETIRED) gentoo-dev 2010-03-11 21:25:27 UTC
Yes, that function, and everything that uses the colors throughout the eclass need to go.  Let the package manager format the text and display everything.

Python: could you please let us know if you are going to work on this, or do you wish for us to fix it for you?  Thanks
Comment 4 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2010-03-12 15:39:49 UTC
Colors have been successfully used in some functions for a long time. _python_set_color_variables() has been recently created to avoid setting color variables separately in many functions. We might remove colors from deprecation warnings. In case of python_mod_cleanup(), we would need to find a good (preferably locale-independent) way (with output with constant indentation) of distinction of directories and regular files.
Comment 5 SpanKY gentoo-dev 2010-03-12 15:56:22 UTC
i really dont know what you're trying to say.  i'll phrase it simply: stop trying to do all your own colorization.  use the standard functions to do output (einfo/ewarn/eerror/etc...).
Comment 6 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2010-03-12 19:27:12 UTC
I think that python_mod_cleanup() could use echo instead of einfo.
Colors in python_execute_*() should not be changed (at least when used with echo).
Comment 7 Petteri Räty (RETIRED) gentoo-dev 2010-03-12 19:29:25 UTC
I committed the removal of custom colors with deprecation notices earlier today (unaware of this bug even existing) based on IRC discussions yesterday. The colors can of course be continued to be used in outputs that are purely build time outputting and not for communicating things for users like what cmake builds do.
Comment 8 Mark Loeser (RETIRED) gentoo-dev 2010-07-05 16:10:40 UTC
This seems to be back, and the colors need to be removed.
Comment 9 SpanKY gentoo-dev 2010-07-17 09:37:14 UTC
unless i missed something, this is still broken, so i'll go ahead and fix it for you this weekend
Comment 10 Brian Harring (RETIRED) gentoo-dev 2010-07-17 15:34:36 UTC
@spanky, please ensure it's testing for NOCOLOR (if it survives) assumes coloring is disabled if the var isn't set also... stupid code forces coloring in pkgcore always.
Comment 11 SpanKY gentoo-dev 2010-07-18 02:27:33 UTC
Created attachment 239195 [details, diff]
python.eclass.patch

this is what i plan on committing.  there is no NOCOLOR usage.
Comment 12 Brian Harring (RETIRED) gentoo-dev 2010-07-18 02:35:41 UTC
(In reply to comment #11)
> Created an attachment (id=239195) [details]
> python.eclass.patch
> 
> this is what i plan on committing.  there is no NOCOLOR usage.

Convert _python_set_color_variables to a warning please, one that does nothing- I suspect overlays may have some usage of it.  distutils.eclass in gentoo-x86 definitely does (should be updated the same).

Might want to convert that NEED_PYTHON echo'ing to >&2 btw, although that also has it's own potential issues.

Either way, thanks, this has been a serious annoyance to pkgcore for a long while.
Comment 13 SpanKY gentoo-dev 2010-07-18 04:57:51 UTC
Created attachment 239203 [details, diff]
distutils.eclass.patch

didnt know it was externally used.  this updates distutils.eclass too.  no need to keep the func around as distutils.eclass only uses it in src_* funcs, not any pkg_* funcs.
Comment 14 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2010-07-18 19:50:56 UTC
Colors must be shown for people, who want to see them. I will use PYTHON_COLORS variable.
Comment 15 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2010-07-18 19:52:50 UTC
Reassigning to maintainers.
Comment 16 Brian Harring (RETIRED) gentoo-dev 2010-07-18 20:10:09 UTC
(In reply to comment #14)
> Colors must be shown for people, who want to see them. I will use PYTHON_COLORS
> variable.

Dude, just drop it.  If this were your personal playpen, I'd say go nuts, but it's not.  The end result of those logs can wind up in devs mailboxes (looking might ugly), the implementation has no way of knowing if the PM is writing to a pipe (meaning term codes can't be used in e* funcs) or a tty, and most importantly *everyone is telling you knock that shit off*, both from a QA/policy and PM standpoint.
Comment 17 Samuli Suominen (RETIRED) gentoo-dev 2010-07-18 20:35:24 UTC
mike, the patches look good. please do commit them.
Comment 18 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2010-07-18 21:06:14 UTC
You cannot remove optional feature, which helps other developers develop ebuilds. Colors are now disabled by default and can be enabled by setting PYTHON_COLORS="1" (usually in /etc/make.conf). If somebody doesn't want to have color codes in logs, then he won't set PYTHON_COLORS variable. Colors are no longer used with einfo/elog/ewarn/eerror.
Comment 19 Brian Harring (RETIRED) gentoo-dev 2010-07-25 03:58:12 UTC
you were directed in the ml to work w/ betelgeuse for eqawarn on this... not just slip the unused ewarn in...