|
|
Subscribe / Log in / New account

Revisiting PEP 394

Revisiting PEP 394

Posted Mar 1, 2019 8:44 UTC (Fri) by jani (subscriber, #74547)
Parent article: Revisiting PEP 394

For the plain python shebang to be forward compatible with the eventual Python 4, whether that's compatible with Python 3 or not, they'll need to provide a mechanism for the scripts to specify which Python versions they're compatible with. Simply switching python to point at python3 will generate another problem with Python 4, and especially so if it breaks compatibility with Python 3. If the plain python shebang sticks to Python 2, what shebang do you add to scripts that are compatible with both Python 3 and 4?

So here's an idea: Allow scripts to declare the Python versions they're compatible with using a python_requires special comment near the top of the file. The plain python shebang would be a launcher that looks at the comment, and runs the latest compatible Python version that's available, or falls back to a baseline Python version if there's no python_requires. I think the baseline could be Python 2.

PEP263 (https://www.python.org/dev/peps/pep-0263/) defines a special comment for encoding, this would be similar.

PEP440 (https://www.python.org/dev/peps/pep-0440/) defines the version identification and dependency specification.

The Python packaging user guide (https://packaging.python.org/guides/distributing-packages...) defines the python_requires for packaging.


to post comments

Revisiting PEP 394

Posted Mar 1, 2019 8:49 UTC (Fri) by jani (subscriber, #74547) [Link]

Oh, obviously scripts could still use specific python3 or python4 shebangs, but would use plain python shebang with python_requires if they are compatible with multiple versions.

Revisiting PEP 394

Posted Mar 2, 2019 22:35 UTC (Sat) by intgr (subscriber, #39733) [Link]

> with the eventual Python 4, whether that's compatible with Python 3 or not

Python developers have stated on the record that breaking compatibility so harshly with Python 3 was a huge mistake and will not be repeated. If there will be a Python 4, it won't be the same kind of nightmare that Python 3 was, but will hopefully follow the usual practice of __future__ flags and deprecations announced well in advance.

> Allow scripts to declare the Python versions they're compatible with

That's already somewhat covered by the __future__ module: https://docs.python.org/3.8/library/__future__.html


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds