[Python-Dev] Bilingual scripts

Daniel Holth dholth at gmail.com
Tue May 28 19:57:07 CEST 2013

On Tue, May 28, 2013 at 1:30 PM, Barry Warsaw <barry at python.org> wrote:
> On May 25, 2013, at 03:12 AM, Chris McDonough wrote:
>>You probably already know this, but I'll mention it anyway.  This
>>probably matters a lot for nose and pyflakes, but I'd say that for tox
>>it should not, it basically just scripts execution of shell commands.
>>I'd think maybe in cases like tox (and others that are compatible with
>>both Python 2 and 3) the hashbang should just be set to
>>"#!/usr/bin/python" unconditionally.
> Unfortunately, not entirely so:
> https://bitbucket.org/hpk42/tox/issue/96/cant-have-a-python-3-setuppy
>>Maybe we could also think about modifying pyflakes so that it can
>>validate both 2 and 3 code (choosing one or the other based on a header
>>line in the validated files and defaulting to the version of Python
>>being run).  This is kind of the right thing anyway.
> Agreed.  Auto-detection may need to be accompanied by a command line option to
> override in some cases.  But I agree, that in general, it would be very nice
> if the script itself were actually bilingual.  (But then, see my previous
> comment about cross-interpreter dependencies.)
>>Nose is a bit of a special case.  I personally never run nosetests
>>directly, I always use setup.py nosetests, which makes it not matter.
> Which is morally equivalent to `$python -m nose`.
>>In general, I'd like to think that scripts that get installed to global
>>bindirs will execute utilities that are useful independent of the
>>version of Python being used to execute them.
> Agreed.  I'm trying to tease out some conventions we can recommend for when
> this can't be the case for whatever reason.
> -Barry

Wheel has no mechanism for renaming scripts (or any file) based on the
Python version used to install. Instead you would have to build
python-version-specific packages for each desired script name.

More information about the Python-Dev mailing list