Python

brew install pkg-config openssl@1.1 xz gdbm tcl-tk

Clone

gh repo clone python/cpython

Python 3.10

PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig" \
  ./configure --with-pydebug --with-openssl=$(brew --prefix openssl@1.1)

With Address Sanitizer for Debugging

set -e
set -u
set -o pipefail
set -x

dir="builds/simple"
here="$(realpath .)"

mkdir --parent "${dir}"
pushd "${dir}"

export CC="clang"
export LD="clang"
export ASAN_OPTIONS=detect_leaks=0
export MSAN_OPTIONS=poison_in_dtor=0
export CFLAGS="-fno-sanitize-recover"
nice "${here}/configure" \
--with-assertions \
--with-pydebug \
--disable-ipv6 \
--with-trace-refs \
--with-undefined-behavior-sanitizer \
--with-address-sanitizer \

# --with-memory-sanitizer \

nice make -j8
nice make test


export CFLAGS="-fno-sanitize-recover -fwrapv"

Python 3.12

export PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig"

./configure --with-pydebug \
              --with-openssl=$(brew --prefix openssl@1.1) \
              --with-tcltk-libs="$(pkg-config --libs tcl tk)" \
              --with-tcltk-includes="$(pkg-config --cflags tcl tk)"

C Programming

Setup Python with custom OpenSSL

cd ~
wget https://www.openssl.org/source/openssl-1.1.1b.tar.gz
wget https://www.openssl.org/source/openssl-1.1.1b.tar.gz.sha256
sha256sum openssl-1.1.1b.tar.gz
cat openssl-1.1.1b.tar.gz.sha256
tar zxvf openssl-1.1.1b.tar.gz
ls /home/senthilx/
cd openssl-1.1.1b
./config \
    --prefix=/home/senthilx/custom-openssl \
    --libdir=lib \
    --openssldir=/etc/ssl
make -j1 depend
make -j8
make install_sw

cd ~
cd cpython
./configure -C --with-openssl=/home/senthilx/openssl --with-openssl-rpath=auto --prefix=/home/senthilx/python-3.x.x
make
make install

CPython Internals