feat: Support always fetching a standalone python interpreter
- [x] I have added a news fragment under
changelog.d/(if the patch affects the end users)
Summary of changes
There exist environments where users need known "good" python interpreters to run their commands from. Notably, linux distros can package non-standard alterations to their Python interpreters, or not have certain "optional" features.
This commit adds --fetch-python={always, missing, never} and the associated environment variable PIPX_FETCH_PYTHON. --fetch-missing-python has been deprecated and aliased to --fetch-python=missing. The corresponding change has been made to PIPX_FETCH_MISSING_PYTHON.
N.b. happy to bikeshed on the name.
Test plan
Tested by running (on a machine with and without python3.{9,10,11}, with and without the environment variable
pipx install --python python3.9 --fetch-python=always black
pipx reinstall --python python3.9 --fetch-python=always black
pipx reinstall --python python3.9 --fetch-python=missing black
pipx reinstall --python python3.10 --fetch-python=never pygments
PIPX_FETCH_MISSING_PYTHON=1 pipx reinstall --python python3.11 pygments
PIPX_FETCH_MISSING_PYTHON=1 PIPX_FETCH_PYTHON=always pipx reinstall --python python3.11 pygments
PIPX_FETCH_PYTHON=always pipx reinstall --python python3.11 pygments
N.b. ran those commands with #1662 cherry picked.
I am happy to add automatic tests as well, I just don't know exactly what would be preferred / which cases you'd like tested. Happy to add any tests requested.