The Python Launcher for UNIX
An implementation of the py command for UNIX-based platforms.
The goal is to have py become the cross-platform command that all Python users
use when executing a Python interpreter. Not only is it short and to the
point, but it also provides a single command that documentation can use in
examples which will work regardless of what operating system a user is on.
Lastly, it side-steps the "what should the python command point to?" debate by
clearly specifying that upfront (i.e. the newest version of Python that is
installed).
Search order
py -3.6
- Search
PATHforpython3.6
py -3
- Use the
PY_PYTHON3environment variable if defined (e.g.PY_PYTHON3=3.6) - Search
PATHfor all instances ofpython3.Y - Find the executable with largest
Y
py
- Use the
PY_PYTHONenvironment variable if defined (e.g.PY_PYTHON=3) version requested and search accordingly - Search
PATHfor all instances ofpythonX.Y - Find the executable with largest
X.Yversion
TODO
NOTE: I am using this project to learn Rust, so please don't be offended if I choose to implement something myself instead of accepting a pull request that you submit. (Pull requests to do something I have already implemented in a more idiomatic fashion are very much appreciated, though.)
PEP 397: Python launcher for Windows (documentation)
- Virtual environment takes precedence when no version specified (
VIRTUAL_ENV) - Shebang line parsing
- Only the first argument if it's a file and doesn't start with
- - Not necessary, but nice to have
- Only the first argument if it's a file and doesn't start with
PYLAUNCH_DEBUGpy -0- Output well-formatted JSON to start in order for it to be consumable?
- Output column format like
pip list?
py -hemits its own help before continuing on to callpython- Configuration files
- Customized commands
- Want a better format like TOML?
- Want to use
Pipfileand itspython_versionfield? - Probably want a way to override things, e.g. wanting a framework build on macOS somehow
- Aliasing? E.g.
2.7-framework=/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python? - Just provide a way to specify a specific interpreter for a specific version? E.g.
2.7=/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
- Aliasing? E.g.