sorin-ionescu / prezto

The configuration framework for Zsh
MIT License
14.02k stars 4.49k forks source link

`brew install virtualenvwrapper` not auto-picked up by Prezto's `python` module on Macbook M1 #2094

Open jeffwidman opened 3 months ago

jeffwidman commented 3 months ago

I was surprised to notice that on a Macbook M1, if I install virtualenvwrapper via brew install virtualenvwrapper that the python module doesn't pick it up. For it to work, I have to explicitly call source .virtualenvwrapper.sh and ain't nobody got time for 'dat!

Looking at the python module here in Prezto, I expected it to automatically discover the presence of the virtualenvwrapper.sh file and source it: https://github.com/sorin-ionescu/prezto/blob/9195b66161b196238cbd52a8a4abd027bdaf5f73/modules/python/init.zsh#L138-L144

I did notice on a M1 Macbook that since Homebrew uses a different path than intel macs, that may be the problem:

$ which virtualenvwrapper.sh                                                                                                                                                                                                                                                                                                       
/opt/homebrew/bin/virtualenvwrapper.sh

But when I tried locally hardcoding the different path, it didn't seem to work:

    virtualenvwrapper_sources=(
      ${(@Ov)commands[(I)virtualenvwrapper(_lazy|).sh]}
      /usr/share/virtualenvwrapper/virtualenvwrapper(_lazy|).sh(OnN)
      # /opt/homebrew/bin/virtualenvwrapper(_lazy|).sh(OnN)
    )
    if (( $#virtualenvwrapper_sources )); then
      source "$virtualenvwrapper_sources[1]"
    fi
jeffwidman commented 3 months ago

For now as a temp workaround, I'm doing:

$ pip3 install --break-system-packages virtualenvwrapper

But while that works, I actually think it'd be slightly cleaner to be able to brew install virtualenvwrapper... or rather, regardless of where it's coming from, if my path is setup such that I can call which virtualenvwrapper.sh, then I'd expect prezto to source that...

Just not sure why it isn't working... 🤔

indrajitr commented 3 months ago

This is likely related to how Homebrew changed stuff around Python 3.12. Details are here (https://docs.brew.sh/Homebrew-and-Python#pep-668-and-virtual-environments), but this probably will require a bit more research.