Some Linux distributions have packages called python-is-python2 and
python-is-python3 which control whether one gets python2 or python3 in
scripts that have a #!/usr/bin/env python shebang.
In either case, things break. That’s where python-is-magic comes in. It
rejects those choices and tries to “Do What I Mean”.
The main mechanism is attempting to compile the target script as Python 3 code in a subprocess without running it. If this fails, the script is assumed to be Python 2 code.
You need Python 3.6 or higher.
Some extra startup time. Consider fixing your Python programs.
-
Cache results
-
Automate installation into
PATH
Take your pick of “public domain” equivalent licenses: