Search code examples
pythonsqlitepython-3.4pyenv

Can't downgrade Python 3.4's sqlite3.sqlite_version on Ubuntu 20.04 via pyenv to run tox test


Setup:

  • Ubuntu 20.04
  • Pyenv
  • libsqlite3-dev v3.31.1

I'm trying to downgrade sqlite3.sqlite_version for Python 3.4 to run some tox tests, and am having no luck. I'm on Ubuntu 20.04. I was able to successfully upgrade it to 3.32.1 with:

PYTHON_CONFIGURE_OPTS="LD_RUN_PATH=/home/linuxbrew/.linuxbrew/Cellar/sqlite/3.32.1/lib \
LDFLAGS=-L/home/linuxbrew/.linuxbrew/Cellar/sqlite/3.32.1/lib \
CPPFLAGS=-I/home/linuxbrew/.linuxbrew/include" pyenv install 3.4.8

When I try to install an old formula for 3.25 or 3.24 and substitute into the above LD_RUN_PATH/LDFLAGS variables, I always wind up with 3.31.1 (the Ubuntu system version of libsqlite3-dev). I can't downgrade libsqlite3-dev since it's a dependency for a bunch of other system packages. I'm assuming it's my poor understanding of the flags I'm attempting to pass to the compilation process, but I don't know for sure.

If I drop the CPPFLAGS variable altogether, I'm able to get it to not compile _sqlite3 at all, but when I point it to the value from snippet above, or to /include in separately compiled sqlite3 3.25/3.24, or any of the other combinations I've tried, I still end up with 3.31.1.

Thanks in advance for any light you can shed on this, even if it's just pointing to helpful resources.


Solution

  • I finally got this working with the following:

    1. Uninstall linuxbrew: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"
    2. Reinstall linuxbrew: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
    3. COMMIT=667d43f39f537f23ad6044b73e53482c44c2f93d
    4. brew install https://raw.githubusercontent.com/Homebrew/linuxbrew-core/$COMMIT/Formula/sqlite.rb
    5. pyenv uninstall 3.4.8
    6. export LD_RUN_PATH=/home/linuxbrew/.linuxbrew/Cellar/sqlite/3.25.3/lib
    7. export LDFLAGS=-L/home/linuxbrew/.linuxbrew/Cellar/sqlite/3.25.3/lib
    8. export CFLAGS=-L/home/linuxbrew/.linuxbrew/Cellar/sqlite/3.25.3/lib
    9. export CPPFLAGS=-I/home/linuxbrew/.linuxbrew/include
    10. pyenv install 3.4.8