Gentoo Logo
Gentoo Spaceship




Note: Due to technical difficulties, the Archives are currently not up to date. GMANE provides an alternative service for most mailing lists.
c.f. bug 424647
List Archive: gentoo-dev
Navigation:
Lists: gentoo-dev: < Prev By Thread Next > < Prev By Date Next >
Headers:
To: Gentoo Development <gentoo-dev@g.o>
From: Arfrever Frehtes Taifersar Arahesis <Arfrever@g.o>
Subject: Re: Locale check in python_pkg_setup()
Date: Sat, 31 Jul 2010 22:10:29 +0200
2010-07-31 21:49:50 Alec Warner napisał(a):
> On Sat, Jul 31, 2010 at 7:44 AM, Arfrever Frehtes Taifersar Arahesis
> <Arfrever@g.o> wrote:
> > 2010-07-30 04:36:22 Brian Harring napisał(a):
> >> On Fri, Jul 30, 2010 at 01:16:42AM +0200, Arfrever Frehtes Taifersar Arahesis wrote:
> >> > --- python.eclass
> >> > +++ python.eclass
> >> > @@ -355,6 +355,8 @@
> >> >     # Check if phase is pkg_setup().
> >> >     [[ "${EBUILD_PHASE}" != "setup" ]] && die "${FUNCNAME}() can be used only in pkg_setup() phase"
> >> >
> >> > +   local locale
> >> > +
> >> >     if [[ "$#" -ne 0 ]]; then
> >> >             die "${FUNCNAME}() does not accept arguments"
> >> >     fi
> >> > @@ -407,6 +409,16 @@
> >> >             unset -f python_pkg_setup_check_USE_flags
> >> >     fi
> >> >
> >> > +   locale="$(python -c 'import os; print(os.environ.get("LC_ALL", os.environ.get("LC_CTYPE", os.environ.get("LANG", "POSIX"))))')"
> >>
> >> You're using python to get the exported env.  Don't.  Use bash (you're
> >> invoking python from freaking bash after all)...
> >
> > Given variable can be set, but not exported.
> 
> If the variable is set but not exported then it is local to the shell
> env.  When bash goes to exec() python the local shell variables are
> not in the env; so os.environ() will not contain them.
> 
> antarus@kyoto ~ $ foo=BAR
> antarus@kyoto ~ $ echo $foo
> BAR
> antarus@kyoto ~ $ python -c 'import os; print os.environ.get("foo")'
> None
> antarus@kyoto ~ $ export foo
> antarus@kyoto ~ $ python -c 'import os; print os.environ.get("foo")'
> BAR

I want only variables exported to Python processes.

> so how is this any different than:
> 
> [[ -n $LC_TYPE ]] && locale=$LC_TYPE
> [[ -n $LC_ALL ]] && locale=$LC_ALL
> locale=${locale:-POSIX}

This code uses non-exported variables.

> if you want to keep it short; or the longer version with more ifs and
> less shell magic.  Normally I'm not a big performance man myself; but
> this is in an eclass used by lots of packages; not just one ebuild.

python_pkg_setup() is a rarely called function.

-- 
Arfrever Frehtes Taifersar Arahesis
Attachment:
signature.asc (This is a digitally signed message part.)
Replies:
Re: Locale check in python_pkg_setup()
-- Petteri Räty
References:
Locale check in python_pkg_setup()
-- Arfrever Frehtes Taifersar Arahesis
Re: Locale check in python_pkg_setup()
-- Arfrever Frehtes Taifersar Arahesis
Re: Locale check in python_pkg_setup()
-- Alec Warner
Navigation:
Lists: gentoo-dev: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
Re: Locale check in python_pkg_setup()
Next by thread:
Re: Locale check in python_pkg_setup()
Previous by date:
Re: Locale check in python_pkg_setup()
Next by date:
Re: New global use flag: vpx or vp8


Updated Jun 29, 2012

Summary: Archive of the gentoo-dev mailing list.

Donate to support our development efforts.

Copyright 2001-2013 Gentoo Foundation, Inc. Questions, Comments? Contact us.