Why Ubuntu doesn’t support certain form of shebang for Python?

Scott Kitterman ubuntu at kitterman.com
Wed Nov 12 00:05:07 UTC 2014


On Tuesday, November 11, 2014 15:52:22 Neal McBurnett wrote:
> On Tue, Nov 11, 2014 at 05:19:38PM -0500, Barry Warsaw wrote:
> > On Nov 11, 2014, at 11:48 AM, Neal McBurnett wrote:
> > >I'm glad that python2 is in Debian and Ubuntu (do you know offhand which
> > >releases?).  Which distros is it still not supported in?  Are they likely
> > >to catch up?
> > 
> > Sorry, I don't know off-hand.
> > 
> > >Do you see a path to a world where compliance with PEP 0394 is the right
> > >approach, making the transition to python3 easier?
> > >
> > >  http://legacy.python.org/dev/peps/pep-0394/
> > 
> > I suspect PEP 394 will mostly be a reflection of reality rather than a
> > driver of downstream policy.  E.g. I think it will be a very long time,
> > if ever, that you'll see PEP 394 recommend, or widespread de facto
> > adoption, of /usr/bin/python pointing to Python 3.  Maybe by Python 4
> > <wink>.
> > 
> > Hopefully though PEP 394 will stop other distros from doing insane things
> > like was done with that one existing "adventurous" outlier.
> > 
> > Cheers,
> > -Barry
> 
> I should have clarified my point better.  Scott's message recommended
> putting python, rather than python2 in shebangs, since it works in more
> distros.  That seems to be In contrast with PEP 394, which says to use
> python2 rather than python, unless the code works in both python 2.x and
> python 3.x.  That is in order to facilitate migration, and it would be
> necessary before anyone could make the next step you talk of (pointing
> python to python 3).
> 
> That's why I'm wondering where the PEP 394 approach doesn't currently work,
> and when we might indeed recommend following the current PEP 394 standard.

Personally, I think PEP 394 was a mistake.  As I said, there is no single 
shebang you can use that will get the correct result on all distros.  
/usr/bin/python works on all but one.  Creating /usr/bin/python2 as an 
attempted fix for their insanity didn't actually solve the problem anytime 
soon.

If /usr/bin/python ever points to a python3 version in Debian/Ubuntu, then 
it's likely I'm not involved in the maintenance anymore.  The sane plan would 
be just to retire it when python2.7 is no longer supported and just use 
/usr/bin/python3 (or whatever) after that.  There's no benefit and only risk of 
pain to ever switching /usr/bin/python to point to python3.  Even after 
python2.7 is removed from the archive, people will compile their own, so why 
ask for trouble.

Scott K




More information about the Ubuntu-devel-discuss mailing list