One of the applications, written in Python using Django, I support needs to be optimized. The first step towards any optimization is finding out where and what gains could be made. NewRelic has provided some good initial insight into at least two pain points, however NewRelic data is fairly coarse grained. In order to get better insight I need to work with the tools locally.

I’ve been using the system python for a lot of things and although Python 2.7.10 has only had security patches I would rather test under the correct interpreter version. A search and I quickly found the Python 2.7.14 OSX installer. However I’m a bit concerned about clobbering the default version as I need to support other developers still using the default version.

Some time in the last few weeks I remember traveling across pyenv. The first attempt to install 2.7.14 failed with a complaint about zlib however the log lines printed seem to indicate the it was a failure when considering if it needs to upgrade pip.

Turns out it’s a common build issue as the path isn’t properly resolved. According to their common build problems it should be as easy as CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install 2.7.14. Sure enough that worked.

Now time to figure out how to active it. Ah, that is right pyenv local 2.7.14 should create a file .python-version with that version. virtualenv was acting a bit funky, so I used the PyEnv plugin for it and seems to be working out just fine.

The application dependencies installed and worked without an issue!