Update: 2025/2026

I use uv almost exclusively now; and sometimes poetry. My development environment is typically something along the lines of:

  • homebrew for installed, compiled applications.

  • mise for common utilities that are large and updated infrequently, for example:

    • ansible
    • node
    • python
  • uv for python virtual environment management.

One side effect of the above is that I haven’t had to remember how to compile python in a while.

For historic context; here’s the original post:

Pyenv

I’ve been using pyenv for ages to manage my python environments. I’ll leave singing the praises of this for others who do it well. Bascially I have a custom python environment for pretty much every project. This avoids dependency conflicts and ‘rot’ across projects.

It is an essential tool and I cannot imagine Python without it.

However, it is a bit difficult to remember the incantations needed to get it to build successfully on MacOS 10.15 and beyond. So I’m going to record this here and save myself the constant Google searching everytime I need to build a new environment or run into trouble. For bonus points I suppose I should add the error messages too so I can find this (and potentially others) while looking for how to solve the problem.

Building Python with pyenv on MacOS Catalina (and later)

LDFLAGS="-L $(xcrun --show-sdk-path)/usr/lib -L $(brew --prefix)/lib" \
CFLAGS="-I $(xcrun --show-sdk-path)/usr/include -I $(brew --prefix)/include" \
PYTHON_CONFIGURE_OPTS="--enable-framework" \
MACOSX_DEPLOYMENT_TARGET=11.1 \
SDKROOT=$(xcrun --show-sdk-path) \
pyenv install -v 3.8.2

Change 3.8.6 to whatever mainline release you’d like to install.

2026-07-22: Updated to mention more modern stack setup. 2021-01-11: Updated for Big Sur