From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1OfIOI-0001tw-5b for garchives@archives.gentoo.org; Sat, 31 Jul 2010 20:10:42 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B1DA3E0B2F; Sat, 31 Jul 2010 20:10:37 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 6571EE0AFA for ; Sat, 31 Jul 2010 20:10:31 +0000 (UTC) Received: from afta-gentoo.localnet (ip-85-198-235-97.broker.com.pl [85.198.235.97]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPSA id CB8DF1B4124 for ; Sat, 31 Jul 2010 20:10:30 +0000 (UTC) From: Arfrever Frehtes Taifersar Arahesis To: Gentoo Development Subject: Re: [gentoo-dev] Locale check in python_pkg_setup() Date: Sat, 31 Jul 2010 22:10:29 +0200 User-Agent: KMail/1.13.5 (Linux/2.6.34-tuxonice-r1-AFTA; KDE/4.4.5; x86_64; ; ) References: <201007300116.43653.Arfrever@gentoo.org> <201007311645.49028.Arfrever@gentoo.org> In-Reply-To: Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart6570429.xrnj544fp2"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201007312211.03680.Arfrever@gentoo.org> X-Archives-Salt: 2dd26c28-ca98-4101-b2f6-e042eda3f917 X-Archives-Hash: a43f298c6a4086d032b2fbde60fbf8da --nextPart6570429.xrnj544fp2 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 2010-07-31 21:49:50 Alec Warner napisa=C5=82(a): > On Sat, Jul 31, 2010 at 7:44 AM, Arfrever Frehtes Taifersar Arahesis > wrote: > > 2010-07-30 04:36:22 Brian Harring napisa=C5=82(a): > >> On Fri, Jul 30, 2010 at 01:16:42AM +0200, Arfrever Frehtes Taifersar A= rahesis wrote: > >> > --- python.eclass > >> > +++ python.eclass > >> > @@ -355,6 +355,8 @@ > >> > # Check if phase is pkg_setup(). > >> > [[ "${EBUILD_PHASE}" !=3D "setup" ]] && die "${FUNCNAME}() can b= e 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=3D"$(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. >=20 > 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. >=20 > antarus@kyoto ~ $ foo=3DBAR > 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: >=20 > [[ -n $LC_TYPE ]] && locale=3D$LC_TYPE > [[ -n $LC_ALL ]] && locale=3D$LC_ALL > locale=3D${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. =2D-=20 Arfrever Frehtes Taifersar Arahesis --nextPart6570429.xrnj544fp2 Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) iQIcBAABAgAGBQJMVINXAAoJEFU3/w1zlLfgw48P/1IuVKWPK42eAgudfUQ/vNn+ shtWgIVARV3qffzlJ+IUp7XbMKDWkRvJtzwcUpf7tpZhKETJ1AqaQV+zvCeXYsU6 n0IOJbTNi+RFq0djkGWeMvNXBRsF5hd5dznaA9w9i70NTJhzGftMKy/e/v334cOz 2dh4F71E0neysfptGSWiBaqQU/MQ0VISomJ1lX/9Pj1qR31m0JzqIM+s3+PSJzns IEiGE8e6mCWArHEGk/WGYMXUzUITusX2Ko9bCVSJ4yKLyuah8+abxvqGLii2jV3K SJjtCrkSOKdUhlWmPzQHmdmoSQfITm8KfWtXQRvLAdHB9A2MMykN5rst5wU+ATd6 6XpaWxA/q02jogZHNJbypGAmjbsiUJLh7a6EQDZTwzLC9UoOefBcjMORTJeXYJYQ QLWyET7+dNV9LMEN33nSGa4W7Yy8UGQ6GoZtugh6hVJTj2j/Q+7pcnKccruluDkX uMh6jWryleJSD6fwy6NF3Pk2gsZLsRv2WJ/07cTNVZHpZZaoizPMBvSrINFV96cV Zfw66BIrHXEOCyf7wR8BpooRlEsSGQbdDaikjDNpygrF2ezG/mu1UdC0R9qLhCDR Ar2hjDeRbtWseWZTEh3swlJR70VR+Ln0LYBhxS4Odv7hy4cBIXihh1YL8Q5aqAx1 K5B660t8NE6O54tuRe9E =/Vq3 -----END PGP SIGNATURE----- --nextPart6570429.xrnj544fp2--