The `python` command should be permanently reserved for Python 2

Regarding the update to the default version of Python:

In order to ensure that old Python-2-only scripts break cleanly and promptly in a Python-3-only system environment, please make sure to reserve the command name python and the #! path /usr/bin/python for Python 2.

That means, in any context (other than a virtualenv) where Python 3 is installed and Python 2 isn’t, only /usr/bin/python3 and python3 should be available. /usr/bin/python must not exist at all, and the bare command name python must not work.

This applies to all build environments, whether or not they are technically Python-related, since it is a popular scripting language for other types of build.

1 Like

I don’t think this would apply. There will be no changes to the non-Python jobs; if it was working before, it would still work.

Only the python builds that don’t specify the Python version will see the behavior change, and that will be fixed by specifying 2.7.

2 Likes

@BanzaiMan is correct.

Without language: python, the command python --version will output:
Python 2.7.6 on Travis CI Trusty and Python 2.7.12 on Travis CI Xenial.

That’s still a dangerous and ill-advised change. python should never invoke Python 3, no matter what the context is. If I were BDFL I wouldn’t even allow it in a virtualenv.

Then the python core team should make that decision, in my opinion.

FYI, in python-dev, an update to PEP 394 is under discussion (and goes smoothly so far) that would

  • recommend to use python3 as the default Python command due to the upcoming drop of Py2
  • let distributions choose what python means, effectively making it a “transitional” option with no guarantee for compatibility across distributions.
    • except in virtualenvs where it refers to the env’s interpreter.
2 Likes

I’m aware. I think the “let distributions choose what python means” part is a serious error and I mean to bring that up with them. Meanwhile, for itself, Travis can and should commit to the absence of the python command in its build environments when Python 2 is not available.

Before you do that, reread my previous post after the edits. This provision is meant to help distributions gradually move python from Py2 to Py3 with minimal pain. So it is provisional, progressive, and I’m pretty positive that it will land.

Please also take into account that RPM-based distros chose to not have python at all by default having two separate python2 and python3 which is IMHO the best decision possible. But I don’t think that Travis CI should maintain modified OS images anyway.

1 Like