public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Arfrever Frehtes Taifersar Arahesis <Arfrever@gentoo.org>
To: Gentoo Development <gentoo-dev@lists.gentoo.org>
Subject: Re: [gentoo-dev] Versioning of Python scripts
Date: Wed, 23 Dec 2009 01:50:57 +0100	[thread overview]
Message-ID: <200912230151.04357.Arfrever@gentoo.org> (raw)
In-Reply-To: <20091221105014.GA6292@hrair>

[-- Attachment #1: Type: Text/Plain, Size: 3155 bytes --]

2009-12-21 11:50:14 Brian Harring napisał(a):
> On Sat, Dec 19, 2009 at 04:24:49PM +0100, Arfrever Frehtes Taifersar Arahesis wrote:
> > Distutils/Setuptools/Distribute modify shebangs of installed Python scripts, so that they
> > contain path of Python interpreter with version included (e.g. "#!/usr/bin/python3.2").
> > This behavior has both advantage and disadvantages:
> >   - Scripts of packages supporting only e.g. Python 2 can be executed (without 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 easily (without
> >     necessity of using of e.g. "python3.1 /usr/bin/${script}") executed with 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 implemented in Python.
> > Wrapper scripts try to execute "${wrapper_script}-${PYTHON_ABI}" files (e.g. "py.test" will
> > execute "py.test-3.1", when Python 3.1 is set as active Python version).
> > 
> > distutils.eclass will automatically rename some scripts [3] in "${D}usr/bin" and call
> > the function, which generates wrapper scripts. In case somebody is interested in reading of
> > source code of python_generate_wrapper_scripts() function and potential suggesting 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 
> world usage?

It simplifies development of ebuilds of packages having non-Distutils-based build systems.
E.g. ebuilds of packages, which support only Python2, install some executables or libraries
(e.g. /usr/lib/kvirc/4.0/modules/libkvipythoncore.so of net-irc/kvirc) linked against
libpythonX.Y.so and don't install any Python modules, will be able to simply call
'python_set_active_version 2', which will export EPYTHON variable with appropriate value.
Ebuilds should never manually set EPYTHON variable.

> I can see that causing all sorts of mayhem as it passes 
> it's way down through python scripts invoking other scripts- 
> specifically thinking of a py3k only script being forced to 3.1, then 
> invoking a py2k script.

EPYTHON variable should be respected only by scripts, which are used during building, testing
or installation of other packages and need to be called with appropriate Python version.
Examples: py.test, trial
distutils_src_install() will call python_generate_wrapper_scripts() (at least by default)
without -E option.

> Beyond that, please provide a way to *disable* this for a pkg.

OK.

-- 
Arfrever Frehtes Taifersar Arahesis

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2009-12-23  0:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-19 15:24 [gentoo-dev] Versioning of Python scripts Arfrever Frehtes Taifersar Arahesis
2009-12-21 10:50 ` Brian Harring
2009-12-23  0:50   ` Arfrever Frehtes Taifersar Arahesis [this message]
2009-12-22  9:04 ` Peter Volkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200912230151.04357.Arfrever@gentoo.org \
    --to=arfrever@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox