Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pythonAny #28

Open
maandree opened this issue Dec 10, 2013 · 1 comment
Open

pythonAny #28

maandree opened this issue Dec 10, 2013 · 1 comment

Comments

@maandree
Copy link
Member

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
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant