cmd/pyenv-sync: Create major version symlink(s) to fix pyenv support #18978
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added proper pyenv support to brew pyenv-sync by symlinking major version executables to their minor.
pyenv-sync
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally? - Errors here but none related to my changes.This PR aims to fix
brew pyenv-sync
support. Prior to this,pyenv-sync
only symlinks~/.pyenv/versions/python{major}.{minor}.{patch}
to/opt/homebrew/Cellar/python@{major}.{minor}/{major}.{minor}.{patch}
.pyenv
looks within thebin
directory for executables, so by-default, the following executables are in PATH (in this example, for say [email protected])So, if a user invokes
python3
orpip3
, it will not be in ~/.pyenv/versions/___/binand
pyenvwill fallback to system default (in this case, the latest
python3installation from Homebrew,
python3.13). This commit adds additional symlinks:
python3, pip3, wheel3, idle3, pydoc3that way
pyenvversion management works as expected using
python3and
pip3`.See the following for reference on what issue(s) this fixes:
brew pyenv-sync
is ignored when runningpython3
pyenv/pyenv#3105brew pyenv-sync
#17563Looks like it's been an issue for a while (July 2023). The proposed fixes are:
python
formula adds the symlinks themselvespyenv
adds some sort of detection for Homebrew and checkslibexec
instead ofbin
ln -s ~/.pyenv/versions/3.12.8/bin/python3.12 ~/.pyenv/versions/3.12.8/bin/python3
)pyenv-sync
creates the symlinks (This seems like the most appropriate approach, which is what I have done)