For linking libboost-python to the correct python. Apt installation uses system python.
Switch to the desired pyenv
Get python headers path using python-config --includes --libs
and add the path in ~/.zshrc
:
export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/home/ruth/.pyenv/versions/3.6.12/include/python3.6m"
Download latest boost
tar xzvf boost_<version>.tar.gz
cd boost_<version>/
sudo apt-get update
sudo apt-get install build-essential g++ python3-dev autotools-dev libicu-dev build-essential libbz2-dev
echo "using python : : ~/.pyenv/versions/3.6.12/bin/python ;" > ~/user-config.jam
./bootstrap.sh --prefix=/usr/local
./b2
sudo ./b2 -j8 install
sudo ldconfig
Can add multiple pythons versions in user-config.jam to build for multiple python versions. See here
Alternative to using user-config.jam:
./bootstrap.sh --with-python=$(which python3) --prefix=/usr/local
Tested with Ubuntu 20.04 and boost 1.7.4