How install both Python32 and Python33 on OS X for testing with tox?
I'm adding Python 3.x support to my open-source project and want to add both Py32 and Py33 test environments to my tox.ini. I already have Py26 and Py27 tox environments that work fine and I just installed Python 3.3 from homebrew and got the Py33 tox environment working nicely.
The problem seems to be that homebrew doesn't have an obvious way to install both 3.3 and 3.2 and a somewhat extended Googling did not yield an answer.
What's the best way to do this that won't lead me into trouble further down the road? I'm happy to build from source if that's the best solution, have done that before with good success but don't want to break out the axe if a pocket knife will get the job done
I'm running OS X 10.8.4
First we ensure we have
$ brew update $ brew install pyenv
Then we install all the needed python versions with
pyenv. This might take time. See python.org/downloads for available versions.
$ pyenv install 2.6.9 && pyenv ... && pyenv install 3.5.0
In the directory of our setup.py, let us run
pyenv local ...as below. It will create
.python-versionfile that stores the versions to be used.
$ pyenv local 2.6.9 2.7.10 3.2.6 3.3.6 3.4.3 3.5.0
pyenvinstalled the Python distributions to a dir
~/.pyenv/shims. To let them to be found instead default Python, the dir must be prepended to the PATH environment variable. Even though more permanent solutions exist, the following does the trick for one terminal session:
$ eval "$(pyenv init -)" $ echo $PATH /Users/myname/.pyenv/shims:/usr/bin:...
The following has been recommended to be run to ensure the shims have correct packages:
$ pyenv rehash
Now, let us assume the following
[tox] envlist = py26,py27,py30,py31,py32,py33,py34,py35 [testenv] deps= nose2 unittest2 commands=nose2
Finally we can run
toxin all the environments:
$ tox ... py26: commands succeeded py27: commands succeeded py30: commands succeeded py31: commands succeeded py32: commands succeeded py33: commands succeeded py34: commands succeeded py35: commands succeeded congratulations :)