From ba826811bcd1187e992a168d488b13b829fc063b Mon Sep 17 00:00:00 2001 From: Tom Kazimiers Date: Fri, 1 Jan 2021 15:41:35 +0100 Subject: [PATCH] CI: simplify sqlite3.so fix for PyPy Instead of forcing the use of OS provided libsqlite3.so through LD_PRELOAD, we now just delete PyPy's copy of the library. This is based on a suggestion by Armin Rigo in the following StackOverflow discussion: https://stackoverflow.com/questions/65476852/ --- .github/workflows/ci.yaml | 3 +-- .travis.yml | 3 +-- scripts/travis/configure_pypy_libs.sh | 37 +++++++++++++++------------ 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a3647905c5..0fc5652a2d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -56,6 +56,7 @@ jobs: - run: pip install -r django/requirements-test.txt coveralls - run: bash scripts/travis/setup_database.sh - run: bash scripts/travis/configure_catmaid.sh + - run: bash scripts/travis/configure_pypy_libs.sh - run: | cd django/projects python manage.py migrate --noinput @@ -65,8 +66,6 @@ jobs: python manage.py makemigrations catmaid name: Check migrations are up to date - run: | - source scripts/travis/configure_pypy_libs.sh - if_pypy_force_os_sqlite_lib cd django/projects coverage run manage.py test catmaid.tests name: Run tests diff --git a/.travis.yml b/.travis.yml index eff1b13cbc..5220d98de2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,9 +26,8 @@ before_install: - bash scripts/travis/install_postgres.sh - bash scripts/travis/install_python.sh - bash scripts/travis/install_gdal.sh - - source scripts/travis/configure_pypy_libs.sh + - bash scripts/travis/configure_pypy_libs.sh - nvm install 11 - - if_pypy_force_os_sqlite_lib install: # Install requirements for running CATMAID and its unit tests - ./scripts/travis/install_requirements.sh diff --git a/scripts/travis/configure_pypy_libs.sh b/scripts/travis/configure_pypy_libs.sh index f0cf2d4c12..63a72c30c3 100644 --- a/scripts/travis/configure_pypy_libs.sh +++ b/scripts/travis/configure_pypy_libs.sh @@ -1,23 +1,26 @@ #!/usr/bin/env bash # -# Prepare environment to run Django with PyPy. - -# Unforunately needed for PyPy at the moment, because it comes with its own -# libsqlite3.so.0, which doesn't have column metadata compiled in, which in turn -# is needed by GDAL and Django. This forces the use of the libsqlite3 library -# provided by the operationg system. This fixes running CATMAID's back-end test -# suit with PyPy on both Travis CI and GH Actions, which failed before due to -# the following error: +# Prepare environment to run Django with PyPy. This effectively means removing +# any copy of the shared library libsqlite3.so that comes with the existing PyPy +# installations. +# +# This is unforunately needed for PyPy at the moment, because it comes with its +# own libsqlite3.so.0 on both Travis and GitHub Actions, which doesn't have +# column metadata compiled in, which in turn is needed by GDAL and Django. In +# order to make PyPy use the OS provided libsqlite3.so, we delete PyPy's copy. +# This fixes running CATMAID's back-end test suit with PyPy on both Travis CI +# and GH Actions, which failed before due to the following error: # # OSError: Cannot load library libgdal.so.20: /usr/lib/libgdal.so.20: undefined symbol: sqlite3_column_table_name # # Since the OS level library is compiled with SQLITE_ENABLE_COLUMN_METADATA=1, -# this is the library we want to use. -if_pypy_force_os_sqlite_lib() { - if python --version | grep PyPy ; then - export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libsqlite3.so.0 - echo "PyPy detected: override PyPy's own copy of libsqlite3.so with OS provided version" - else - echo "Not running PyPy, no library override needed" - fi -} +# this is the library we want to use. More information can also be found here: +# +# https://stackoverflow.com/questions/65476852/ + +set -ex + +# Delete all files that have libsqlite3.so in their path name as well as PyPy +# (regardless of the case of the P). +echo 'Attempting to delete all PyPy copies of libsqlite3.so in order to use OS copy' +sudo time find / -path /proc -prune -o -regex '.*[Pp]y[Pp]y.*libsqlite3\.so.*' -type f -exec rm -f {} +