Skip to content

Instantly share code, notes, and snippets.

@blazewicz
Last active May 7, 2024 22:02
Show Gist options
  • Save blazewicz/4bf9a656dadb52123a72e69456ae18ec to your computer and use it in GitHub Desktop.
Save blazewicz/4bf9a656dadb52123a72e69456ae18ec to your computer and use it in GitHub Desktop.
pyenv - Install Python 3.x with optimizations on macOS with macports
#!/bin/bash
set +x
PY_VERSION=3.10.1
export MAKE_OPTS="-j4"
export PYTHON_CONFIGURE_OPTS="$PYTHON_CONFIGURE_OPTS --enable-framework"
export PYTHON_CONFIGURE_OPTS="$PYTHON_CONFIGURE_OPTS --with-computed-gotos"
export PYTHON_CONFIGURE_OPTS="$PYTHON_CONFIGURE_OPTS --with-system-expat"
export PYTHON_CONFIGURE_OPTS="$PYTHON_CONFIGURE_OPTS --with-system-ffi"
#export PYTHON_CONFIGURE_OPTS="$PYTHON_CONFIGURE_OPTS --with-ensurepip=no"
export PYTHON_CONFIGURE_OPTS="$PYTHON_CONFIGURE_OPTS --enable-ipv6"
# optimizations
#export CFLAGS="$CFLAGS -march=native"
export PYTHON_CONFIGURE_OPTS="$PYTHON_CONFIGURE_OPTS --enable-optimizations"
#export PYTHON_CONFIGURE_OPTS="$PYTHON_CONFIGURE_OPTS --with-lto"
export CFLAGS="$CFLAGS -I$HOME/.pyenv/versions/$PY_VERSION/openssl/include"
export CFLAGS="$CFLAGS -I$HOME/.pyenv/versions/$PY_VERSION/readline/include"
export CFLAGS="$CFLAGS -I/opt/local/include"
export LDFLAGS="$LDFLAGS -L$HOME/.pyenv/versions/$PY_VERSION/openssl/lib"
export LDFLAGS="$LDFLAGS -L$HOME/.pyenv/versions/$PY_VERSION/readline/lib"
export LDFLAGS="$LDFLAGS -L/opt/local/lib"
export PKG_CONFIG=`which pkg-config`
pyenv install -v --force $PY_VERSION
@tnetsch
Copy link

tnetsch commented Sep 25, 2023

Thanks for the installation script. I am trying to get pyenv installing with my MacPorts distribution but I am not able to figure out which port install commands are needed to satisfy the dependencies during compilation of Python. Have you anything added to MacPorts such as openssl or tcl to make the compilation work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment