[Python-ideas] Migration of /usr/bin/python to python3
Andrew Barnert
abarnert at yahoo.com
Wed Mar 11 23:45:19 CET 2015
On Mar 11, 2015, at 1:38 PM, M.-A. Lemburg <mal at egenix.com> wrote:
>
>> On 11.03.2015 21:03, David Mertz wrote:
>> https://www.python.org/dev/peps/pep-0394/
>
> I think the migration should start with modifying scripts to use
>
> #!/usr/bin/env python2
>
> when they are Python 2 only (*) and
>
> #!/usr/bin/env python3
>
> when they are Python 3 only and
>
> #!/usr/bin/env python
>
> only when they support both Python 2 and 3.
Except that you need a step 0: Not every system out there is PEP 394-compliant. Most notably, the built-in Python on OS X has nothing named python2, and python is a wrapper executable that selects between python2.5, python2.6, and python2.7. Some of the popular third-party Python-with-extra-batteries installs still give you only python and maybe python2.7, but not python2. And most linux distros' built-in and standard repo Pythons are PEP 394-compliant, but "most Linux distros" is not the same thing as "all non-OS X Unix-like systems".
So if you want to move this forward, I think someone needs to create a central place with all the info on how far we are from 100% PEP 394 compliance (including but reports to each vendor, etc.) and start pressuring the vendors who don't comply.
In the case of Apple, unless you can get them to add a python2 executable in bug fix releases of 10.9 and 10.10, rather than just in 10.11, it'll be a long time before python2 becomes a portable command. (Even if you could, would dropping OS X 10.6-10.8 be acceptable today for most scripts?)
> "Explicit is better than implicit" and all that Zen :-)
>
> Once that's done, switching the symlink is really a no-brainer.
>
> The recipe for this is easy too:
>
> 1. replace all "#!/usr/bin/env python" with "#!/usr/bin/env python2"
> 2. migrate your scripts one by one to either Python 3.x or
> to Python 2.7 + 3.4+
> 3. after migration replace "#!/usr/bin/env python2" with
> "#!/usr/bin/env python3" or "#!/usr/bin/env python" resp.
>
> (*) Some OSes may require to use python2.7, if they don't come
> with a symlink from python2 -> python2.7.
>
> --
> Marc-Andre Lemburg
> eGenix.com
>
> Professional Python Services directly from the Source (#1, Mar 11 2015)
>>>> Python Projects, Coaching and Consulting ... http://www.egenix.com/
>>>> mxODBC Plone/Zope Database Adapter ... http://zope.egenix.com/
>>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
> ________________________________________________________________________
>
> ::::: Try our mxODBC.Connect Python Database Interface for free ! ::::::
>
> eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
> D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
> Registered at Amtsgericht Duesseldorf: HRB 46611
> http://www.egenix.com/company/contact/
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
More information about the Python-ideas
mailing list