justinmayer / virtualfish

Fish shell tool for managing Python virtual environments
MIT License
1.07k stars 101 forks source link

Improve detection of installed Python version #221

Open sbaack opened 2 years ago

sbaack commented 2 years ago

First, this commit adds detection of Python versions installed via Python.org's Mac OS installers (which are installed in /Library/Frameworks/Python.framework/Versions/). virtualfish will prefer Python.org installations over Homebrew Python, but asdf, pyenv, or pythonz are preferred over Python.org installs.

Second, this commit fixes an issue in how Python versions are deteced when calling vf new -p or vf upgrade -p. Before this commit, virtualfish checked if various executables are available, but didn't continue to search if the specified Python version has not been installed in the first available application. For example, if pyenv is installed but the specified Python version has not been installed with pyenv, virtualfish will directly fall back to pass to Virtualenv as-is instead of continuing the search in, say, pythonz or Homebrew.

While it is unlikely that one would have both pyenv and pythonz installed, continuing to search for a Python version if it hasn't been installed in the first application found is useful with regards to detecting Python.org installs. One might mostly use pyenv, but has issues compiling a particular Python version with it and therefore installs it with Python.org's Mac installer.