[Python-Dev] Bilingual scripts

Barry Warsaw barry at python.org
Tue May 28 19:30:58 CEST 2013


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130528/dc73ac32/attachment.pgp>


More information about the Python-Dev mailing list