Use Python 3 in scripts
rossburton opened this issue · comments
Now that Python 2 is EOL, would it be sensible to change the hashbangs in all the scripts to use #! /usr/bin/env python3
?
There's an increasing number of systems without Python 2 at all, and they don't need to have a python
binary available. For example, my Debian chroot for development in doesn't have a /usr/bin/python
but has Python 3 installed.
https://lwn.net/Articles/780737/ Revisiting PEP 394
would it be sensible to change the hashbangs in all the scripts to use #! /usr/bin/env python3?
Isn't this equivalent to dropping support for python2? Which some people will keep using even after it stops being supported.
They'd still be able to use python2 genconfig
. Using the unversioned name breaks for people without an unversioned symlink, so someone's going to be upset either way.
Just for fun, sharing a very "creative" workaround I've seen once:
#!/bin/sh
"true" '''\'
if [check some stuff]; then
exec python2 "$0" "$@"
else
exec python3 "$0" "$@"
fi
exit 127
'''
import ...
I'm fine with changing the hashbangs to use python3
. Installing the wheels on Python 2 should still work, because entry_points
creates bounce scripts with their own hashbangs, and manually running python script.py
on older systems probably isn't too bad. More important to have stuff be seamless on modern systems.
I wonder if there are systems where python
points to Python 3 and python3
isn't available. Probably rare at least, going on https://www.python.org/dev/peps/pep-0394/#for-python-runtime-distributors.