Last active
August 3, 2021 20:51
-
-
Save EricCousineau-TRI/ce79d3265bb72934267e24ddc8c623bc to your computer and use it in GitHub Desktop.
Build a Debug+Valgrind version of Python 3.8.8, NumPy 1.18.2, and GDB 8.1.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euxo pipefail | |
install_prefix=~/.local/opt/cpython/3.8.8-dbg | |
jobs=4 | |
# CPython | |
# https://stackoverflow.com/a/20126802/7829525 | |
( | |
[ ! -d cpython ] && git clone https://github.com/python/cpython | |
cd cpython | |
git fetch && git checkout v3.8.8 | |
make clean || : | |
./configure --with-pydebug CFLAGS='-O0 -g' --enable-shared \ | |
--prefix=${install_prefix} \ | |
LDFLAGS=-Wl,-rpath=${install_prefix}/lib \ | |
--with-ensurepip=upgrade \ | |
--without-pymalloc --with-valgrind | |
make -j ${jobs} install | |
) | |
${install_prefix}/bin/pip3 install gnureadline==8.0.0 | |
# NumPy | |
( | |
[ ! -d numpy ] && git clone https://github.com/numpy/numpy.git | |
cd numpy | |
git fetch && git checkout v1.18.2 | |
# Ensure we have Cython. | |
${install_prefix}/bin/pip3 install cython==0.29.16 | |
${install_prefix}/bin/python3 setup.py build --debug -j ${jobs} install \ | |
--prefix ${install_prefix} | |
) | |
# GDB - since it uses Python. | |
<<'EOF' | |
# Add the following to `~/.gdbinit` to debug CPython C extensions | |
python | |
# http://droettboom.com/blog/2015/11/20/gdb-python-extensions/ | |
def setup_python(event): | |
import libpython | |
gdb.events.new_objfile.connect(setup_python) | |
end | |
EOF | |
( | |
which makeinfo || ( | |
echo -e "Need to run:\n\n\n sudo apt install texinfo\n\n" | |
exit 1 | |
) | |
[ ! -d binutils-gdb ] && git clone git://sourceware.org/git/binutils-gdb.git | |
cd binutils-gdb | |
git fetch && git checkout gdb-8.1.1-release | |
./configure \ | |
LIBS='-lpython3.8d' LDFLAGS="-L${install_prefix}/lib" \ | |
--prefix ${install_prefix} --with-python | |
make -j ${jobs} VERBOSE=1 | |
make -j ${jobs} -C gdb install | |
) | |
# Consider some bash help: | |
# https://gist.github.com/EricCousineau-TRI/6870970d68f75d23061177a52932a5d1#file-bash_helper_functions-sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should fix per comment here:
https://gitter.im/pybind/Lobby?at=5f00c7dbfa0c9221fc7b669d