Skip to content

Conversation

13steinj
Copy link
Contributor

@13steinj 13steinj commented Aug 26, 2025

  • 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.

@13steinj 13steinj force-pushed the feat-fetch-python-always branch 3 times, most recently from 7e648ec to 43cad9a Compare August 26, 2025 18:22
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`.
StrEnum only available in 3.11 :(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant