ulfalizer / Kconfiglib

A flexible Python 2/3 Kconfig implementation and library
ISC License
448 stars 160 forks source link

Use Python 3 in scripts #89

Closed rossburton closed 4 years ago

rossburton commented 4 years ago

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.

marc-hb commented 4 years ago

https://lwn.net/Articles/780737/ Revisiting PEP 394

marc-hb commented 4 years ago

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.

rossburton commented 4 years ago

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.

marc-hb commented 4 years ago

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 ...
ulfalizer commented 4 years ago

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.