[Python-Dev] Bilingual scripts

Dirkjan Ochtman dirkjan at ochtman.nl
Fri May 24 22:52:43 CEST 2013

On Fri, May 24, 2013 at 10:23 PM, R. David Murray <rdmurray at bitdance.com> wrote:
> Gentoo has a (fairly complex) driver script that is symlinked to all
> of these bin scripts.  The system then has the concept of the
> "current python", which can be set to python2 or python3.  The default
> bin then calls the current default interpreter.  There are also
> xxx2 and xxx3 versions of each bin script, which call the 'current'
> version of python2 or python3, respectively.

I'm one of the Gentoo devs, on the python team. I haven't actually
written any code for this, but I can show a little of what's going on.
I think most of the code is actually in
https://bitbucket.org/mgorny/python-exec. We then install three

lrwxrwxrwx 1 root root  11 May 20 14:06 /usr/bin/sphinx-build -> python-exec
-rwxr-xr-x 1 root root 311 May 20 14:06 /usr/bin/sphinx-build-python2.7
-rwxr-xr-x 1 root root 311 May 20 14:06 /usr/bin/sphinx-build-python3.2

sphinx-build-python2.7 looks like this:

# EASY-INSTALL-ENTRY-SCRIPT: 'Sphinx==1.1.3','console_scripts','sphinx-build'
__requires__ = 'Sphinx==1.1.3'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
        load_entry_point('Sphinx==1.1.3', 'console_scripts', 'sphinx-build')()

We now use a python2.7 suffix rather than just a 2.7 suffix because we
will install separate wrappers for e.g. pypy1.9 (and we are also
prepared to support jython or other implementations at some point).

If you have any more questions, I'll try to answer them; or, join
#gentoo-python on Freenode, there are generally people hanging out
there who know much more about our setup than I do.



More information about the Python-Dev mailing list