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 1NMh5K-0003jb-Pf for garchives@archives.gentoo.org; Mon, 21 Dec 2009 12:09:59 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 65872E09A6 for ; Mon, 21 Dec 2009 12:09:58 +0000 (UTC) Received: from mail-yw0-f187.google.com (mail-yw0-f187.google.com [209.85.211.187]) by pigeon.gentoo.org (Postfix) with ESMTP id 7006DE06F3 for ; Mon, 21 Dec 2009 10:51:58 +0000 (UTC) Received: by ywh17 with SMTP id 17so6136528ywh.2 for ; Mon, 21 Dec 2009 02:51:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:date:from:to:cc :subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent; bh=vM59CGv3DsqmwPZYnIIq2wdoAs0o8vvXdCUgNacPJT4=; b=shRYj3y7pjGqVAsUy8tsvejEE841G/lJe00pZRo1GYwQHm4OArUQ91P1GpUEVYA1XJ vDFbbl2jf/8XA07yX+Wwo2u+SHvO2RQoTX3IH+MzASbqEtKIFs6rPZi+n17pNlT0Dj1z 4gRQAQ5NygFD1/5EG4KR6JQPMcUOIxUHSdYxk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=mO3jQaYS5Tr5KCms5YksZaL6/k1+sqcdn2U+tGwDjKH4QTIkYiA6ZrvaYDbac1GCIu KfHG9x6l9t1VqzUeNy3a4oNflNuwHPUY1KrTk3haB0ZBiNK0ip/doB5MReglWw8KfSTG jtgKuzmZcNa6w4wOm6WqB3qHvJD2vaSTjFoDo= Received: by 10.151.92.9 with SMTP id u9mr10890949ybl.158.1261392717993; Mon, 21 Dec 2009 02:51:57 -0800 (PST) Received: from smtp.gmail.com (c-98-210-130-131.hsd1.ca.comcast.net [98.210.130.131]) by mx.google.com with ESMTPS id 34sm2299627yxf.47.2009.12.21.02.51.54 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 21 Dec 2009 02:51:56 -0800 (PST) Received: by smtp.gmail.com (sSMTP sendmail emulation); Mon, 21 Dec 2009 02:50:14 -0800 Date: Mon, 21 Dec 2009 02:50:14 -0800 From: Brian Harring To: Arfrever Frehtes Taifersar Arahesis Cc: gentoo-dev@lists.gentoo.org Subject: Re: [gentoo-dev] Versioning of Python scripts Message-ID: <20091221105014.GA6292@hrair> References: <200912191624.55244.Arfrever@gentoo.org> 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; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="17pEHd4RhPHOinZp" Content-Disposition: inline In-Reply-To: <200912191624.55244.Arfrever@gentoo.org> User-Agent: Mutt/1.5.20 (2009-06-14) X-Archives-Salt: 1d748e96-2682-4bcd-9da0-edd0d815c91f X-Archives-Hash: 2b99c12f393af47f5bc6dd8cd94ff641 --17pEHd4RhPHOinZp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Dec 19, 2009 at 04:24:49PM +0100, Arfrever Frehtes Taifersar Arahes= is wrote: > Distutils/Setuptools/Distribute modify shebangs of installed Python scrip= ts, so that they > contain path of Python interpreter with version included (e.g. "#!/usr/bi= n/python3.2"). > This behavior has both advantage and disadvantages: > - Scripts of packages supporting only e.g. Python 2 can be executed (wi= thout necessity > of using of e.g. "python2 /usr/bin/${script}") after activating of e.= g. Python 3. > - Scripts of packages supporting multiple Python versions ignore active= Python version. > - Scripts of packages supporting multiple Python versions cannot be eas= ily (without > necessity of using of e.g. "python3.1 /usr/bin/${script}") executed w= ith a Python > version different than active Python version. > The best solution, which removes these 2 disadvantages and preserves the = advantage, seems > to be to rename Python scripts to include Python version [1] in filenames= , and create wrapper > scripts, which call appropriate target scripts [2]. Some files sometimes = try to execute > e.g. "/usr/bin/python /usr/bin/${script}", so wrapper scripts must be imp= lemented in Python. > Wrapper scripts try to execute "${wrapper_script}-${PYTHON_ABI}" files (e= =2Eg. "py.test" will > execute "py.test-3.1", when Python 3.1 is set as active Python version). >=20 > distutils.eclass will automatically rename some scripts [3] in "${D}usr/b= in" and call > the function, which generates wrapper scripts. In case somebody is intere= sted in reading of > source code of python_generate_wrapper_scripts() function and potential s= uggesting of > improvements, I'm attaching this function and 2 example wrapper scripts. = I'm planning to > commit addition of this function in next week. Not really a huge fan of the EPYTHON var... can you clarify it's real=20 world usage? I can see that causing all sorts of mayhem as it passes=20 it's way down through python scripts invoking other scripts-=20 specifically thinking of a py3k only script being forced to 3.1, then=20 invoking a py2k script. Beyond that, please provide a way to *disable* this for a pkg. At=20 least for pkgcore, I've already been looking at ways to deal with=20 this and would rather solve it at the pkg level (since EPYTHON let=20 alone eselect may not exist for certain target deployments of=20 pkgcore itself). Basically, no point in having wrapper scripts if the target already=20 can do it's own version of this, hence wanting a way to disable it in=20 the ebuild- that's just for the script mangling, library installing=20 for multiple python abis is a seperate thing. Aside from that, punting on the re import might be nice primarily for=20 speed reasons (no it's not a huge import in cost, but this is an extra=20 ~.025 per python script invoked, ignoring the ~.3 to ~.02 for eselect=20 dependant on cache status). ~harring --17pEHd4RhPHOinZp Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.13 (GNU/Linux) iEYEARECAAYFAksvUuYACgkQsiLx3HvNzgfGRACfVze0kDEaWwWhLKI0LdOaETHR VhgAniABqWJmOi9Xv7ku3WpIjgOwH4H5 =1/CJ -----END PGP SIGNATURE----- --17pEHd4RhPHOinZp--