Gentoo Archives: gentoo-dev

From: Arfrever Frehtes Taifersar Arahesis <Arfrever@g.o>
To: Gentoo Development <gentoo-dev@l.g.o>
Subject: Re: [gentoo-dev] Locale check in python_pkg_setup()
Date: Mon, 02 Aug 2010 21:04:33
Message-Id: 201008022303.20713.Arfrever@gentoo.org
In Reply to: Re: [gentoo-dev] Locale check in python_pkg_setup() by "Petteri Räty"
2010-07-31 22:25:26 Petteri Räty napisał(a):
> On 07/31/2010 11:10 PM, Arfrever Frehtes Taifersar Arahesis wrote: > >> > >> 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. > > > > export -p
It would have to be parsed using e.g. grep and sed. It's easier to call Python in this case. The call to Python is sufficiently fast: $ time python -c 'import os; print(os.environ.get("LC_ALL", os.environ.get("LC_CTYPE", os.environ.get("LANG", "POSIX"))))' > /dev/null real 0m0.062s user 0m0.051s sys 0m0.011s -- Arfrever Frehtes Taifersar Arahesis

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-dev] Locale check in python_pkg_setup() "Harald van Dijk" <truedfx@g.o>