Python has a great tool for creating closed environments called virtualenv, tox. There is an elegant tool called latest /) that automates multiple versions of testing. (Personal subjectivity) In order to handle these tools effectively, there is a demand for coexistence of multiple versions of Python. (Well, coexistence of multiple versions isn't limited to Python, it seems to be a requirement that can be either Ruby or Perl, and I think you can find a library for it with a little research.) As software to easily fulfill this request, pythonbrew, pythonz, [pyenv](https:: //github.com/yyuu/pyenv) and so on.
Somehow the reason is (laughs). If I force you to say, I don't want to increase the number of management tools too much. As the number of tools of this type increases, it becomes difficult to understand what is managed, what, and how, and the configuration files (mainly .bashrc / .zshrc) also expand.
Since Homebrew is a general-purpose package manager, it naturally provides software other than Python, and (as I recently learned) Homebrew-Cask , GUI apps can also be managed. If you put it together as much as possible, it will be easier to manage.
The current Homebrew repository HEAD only supports the latest versions of Python 2 and 3 (2.7, 3.4), and other versions cannot be installed.
python
% brew search python
gst-python010 python python3 wxpython zpython
homebrew/apache/mod_python
% brew info python
python: stable 2.7.6 (bottled), HEAD
http://www.python.org
…
% brew info python3
python3: stable 3.4.1 (bottled), HEAD
https://www.python.org/
#But I have an old version of Formula ... when and where did I get it ...
% brew list | grep python
python
python26
python3
python31
python32
There are repositories that provide Formulas for different software versions, but not Python. Why is it so… https://github.com/Homebrew/homebrew-versions
So I decided to create a custom Homebrew repository with each version of Formula.
https://github.com/FGtatsuro/homebrew-custom
Creating / using a repository is very easy
brew tap (Github user name) / (repository name)
. (FGtatsuro / custom
in this repository)brew update
to get the Formula in the registered repository.Each Formula is based on the original Formula (python.rb
, python3.rb
) with the following changes.
make alt install
instead ofmake install
. This will prevent symbolic links such as python
, python3
from being created under Homebrew's bin
(default:/ usr / local / bin /
). (A link will be created that includes even minor versions like python3.3
.)Pip
, pip2
) that do not include minor versions.Both 1 and 2 are to avoid executing an unintended version due to symbolic link overwriting when multiple versions are installed.
I think there are pros and cons to deleting the python
link, but I also use the environment created with virtualenv for my usual environment, especially because those symbolic links are created in this environment. It doesn't matter.
If not, it's a good idea to decide which version you want to use in the main and then create a new symbolic link.
python
% ln -s /usr/local/bin/python34 /usr/local/bin/python
"Wow, just write a ww MakeFile, isn't it? Www? Does it mean to manage it with Homebrew?" (I feel like I said that)
It seems that python
, python3
may be requested due to the dependency of another Formula, and at that time, it conflicts with python27
, python34
put in the custom repository.
So, it's safer to use the latest one from the original repository.
Recommended Posts