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. By having a version-agnostic command
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). This also unifies the suggested command to document for launching
Python on both Windows as UNIX as py
which has existed as the preferred
command on Windows for
some time.
See the top of py --help
for instructions.
Please note that while searching, the search for a Python version can become more specific. This leads to a switch in the search algorithm to the one most appropriate to the specificity of the version.
py -3.6
(specific version)PATH
for python3.6
py -3
(loose/major version)PY_PYTHON3
environment variable if defined
(e.g. PY_PYTHON3=3.6
)PATH
for all instances of python3.Y
Y
that earliest on PATH
py
(any/unknown version)${VIRTUAL_ENV}/bin/python
immediately if available/usr/bin/python
, /usr/local/bin/python
,
/usr/bin/env python
or python
, proceed based on the version found
(bare python
is considered python2
for backwards-compatibility)PY_PYTHON
environment variable if defined
(e.g. PY_PYTHON=3
or PY_PYTHON=3.6
)PATH
for all instances of pythonX.Y
X.Y
earliest on PATH
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)
py --list
pip list
(based on a Twitter poll)py -0
/py -0p
/py --list-paths
for simplicityPY_
(it's always PYTHON
)PY_PYTHON
feels redundant2.7-framework
for /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
?2.7
for /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
python3.7
like pypy3
?PATH
../pyvenv.cfg
to resolve for Any
version.pyd
files)pylauncher
package (it will make the pipenv developers happy 😃; might change name to pyfinder
for package)OsString
/OsStr
everywhere (versus now which is wherever it's easy w/ path::Path
)?
CString
)human-panic
PYLAUNCH_DEBUG
?PATH
, VIRTUAL_ENV
to ease testability)
Option
versus Result
(e.g. split_shebang(),
versionfromflag(),
choose_executable()`)nix
dependency for a straight
libc
dependency (to potentially make Debian
packaging easier)