GNU-Pony / info

[pre-alpha] Distro information and roadmap
http://gnu-pony.github.io/info
14 stars 1 forks source link

pythonAny #28

Open maandree opened 10 years ago

maandree commented 10 years ago

Many Python 2 scripts (not that many Python 3) scripts just specifiy python in the shebang. Similarly shell scripts can some times invoke python without specifying the version.

Will package maintainer should try to fix this, and inform the upstream, this can still be a problem for software that is downloaded directly from the upstream and not from the package repository. Additionally it can be a problem if a packager misses to fix the shebang.

To fix this there should be a script, /usr/bin/python that tires to figure out whether a script, from the command line arguments or from the standard input, is written in Python 2 or Python 3, and exec into the which it thinks it is. If it cannot figure out which version of Python to use it should exec into python2, as that is more likely to be correct.

However if the standard input is a tty (or pty) and a script is not specified in the command line, it should exec into python3 so python can still be used to start python3 in interactive mode.

maandree commented 10 years ago

python -m py_compile FILE.py can be used to compile a file. This will empty to create a __pycache__ directory with a .pyc file in it. But if the user does not have write permission to the directory FILE.py is located in, this will fail.

If their is not a good existing way, it should be possible to fork py_compile to perform a dry-run and perhaps strip out compilation and optimisation.