Skip to content

Instantly share code, notes, and snippets.

@jorgejesus
Last active December 7, 2023 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorgejesus/e033febe68150ed8495060322d0a5c3f to your computer and use it in GitHub Desktop.
Save jorgejesus/e033febe68150ed8495060322d0a5c3f to your computer and use it in GitHub Desktop.
sqlite3 build and integration into python 3.10.8 using pyenv
# using zsh bash on Ubuntu 22.04.2 LTS
export PYENV_PYTHON_VERSION=3.10.8
export SQLITE_VERSION=3410000
export SQLITE_INSTALL_PATH=/opt/sqlite3
cd ~
test -f sqlite-autoconf-$SQLITE_VERSION.tar.gz || wget https://sqlite.org/2023/sqlite-autoconf-$SQLITE_VERSION.tar.gz
tar zxvf sqlite-autoconf-$SQLITE_VERSION.tar.gz
cd sqlite-autoconf-$SQLITE_VERSION
CFLAGS="-march=native -g -O3" CXXFLAGS=${CFLAGS} ./configure --prefix=$SQLITE_INSTALL_PATH --enable-readline
make
sudo mkdir $SQLITE_INSTALL_PATH
sudo make install
# add library locations to zsh
echo "export PATH=${SQLITE_INSTALL_PATH}/bin:\$PATH" >> ~/.zshrc
echo "export LD_LIBRARY_PATH=${SQLITE_INSTALL_PATH}/lib" >> ~/.zshrc
echo "export LD_RUN_PATH=${SQLITE_INSTALL_PATH}/lib" >> ~/.zshrc
source ~/.zshrc
# Just in case system wide ldconfig not certain
sudo echo "${SQLITE_INSTALL_PATH}/lib" > /etc/ld.so.conf.d/sqlite3.conf
sudo ldconfig
# Clean up sqlite source
cd ~
rm sqlite-autoconf-$SQLITE_VERSION.tar.gz && rm -r sqlite-autoconf-$SQLITE_VERSION
# pyenv build with CPU optmizations
PYTHON_CONFIGURE_OPTS="--enable-loadable-sqlite-extensions --enable-optimizations \
LD_RUN_PATH="${SQLITE_INSTALL_PATH}/lib LDFLAGS=-L${SQLITE_INSTALL_PATH}/lib CPPFLAGS="-I${SQLITE_INSTALL_PATH/include}" \
CFLAGS="-march=native -g -O3" CXXFLAGS=${CFLAGS} pyenv install -v $PYENV_PYTHON_VERSION
@jorgejesus
Copy link
Author

include --with-lto for extra optimization (link time optimization)

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