Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

cmd/pyenv-sync: Create major version symlink(s) to fix pyenv support #18978

Merged
merged 1 commit into from
Dec 23, 2024

Conversation

landoncrabtree
Copy link
Contributor

@landoncrabtree landoncrabtree commented Dec 21, 2024

Added proper pyenv support to brew pyenv-sync by symlinking major version executables to their minor.

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example. - Test already exists for pyenv-sync
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run 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 the bin directory for executables, so by-default, the following executables are in PATH (in this example, for say python@3.12)

2to3-3.12
idle3.12
pip3.12
pydoc3.12
python3.12
python3.12-config
wheel3.12

So, if a user invokes python3 or pip3, it will not be in ~/.pyenv/versions/___/bin and pyenv will fallback to system default (in this case, the latest python3 installation from Homebrew, python3.13). This commit adds additional symlinks: python3, pip3, wheel3, idle3, pydoc3 that way pyenv version management works as expected using python3 and pip3.

See the following for reference on what issue(s) this fixes:

Looks like it's been an issue for a while (July 2023). The proposed fixes are:

  • python formula adds the symlinks themselves
  • pyenv adds some sort of detection for Homebrew and checks libexec instead of bin
  • Users create the symlinks manually (eg: 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)

@landoncrabtree landoncrabtree changed the title Added proper pyenv support to brew pyenv-sync by symlinking major ver… cmd/pyenv-sync: Create major version symlink(s) to fix pyenv support Dec 22, 2024
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work, particularly for a first PR! Thanks @landoncrabtree, you rock!

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Dec 23, 2024
Merged via the queue into Homebrew:master with commit 402c47f Dec 23, 2024
28 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants