Gabriel Passos
Gabriel Passos

Reputation: 11

How to compile Python APSW with local build os SQLite

I'm developing an application and I would like to compile SQLite with some personalized flags and use this build of SQLite with APSW! To be more specific, I would like to use the options in the Recommended Compile-time Options section of SQLite Compile-time Options Docs (https://www.sqlite.org/compile.html).

I'm using version 3.39.4.0 of APSW and version 3.39.4 of SQLite in Ubuntu.

1) First try:

I tried to use the amalgamation with the --definevalues flag in build_ext, passing my options to CFLAGS, but my options appear to not be applied.

The command line that I used was:

python3 setup.py fetch --sqlite --version=3.39.4 build_ext --definevalues CFLAGS="Recommended Compile-time Options Here" install

2) Second try:

In APSW docs, I noticed that when building APSW without amalgamation, the setup.py will look for the header sqlite3/sqlite3.h and the library sqlite3/libsqlite3.so. Then, I tried to generate the shared object libsqlite3.so and copy sqlite3.h and libsqlite3.so to the subdirectory sqlite3 in the apsw root. These are the commands that I used to generate libsqlite3.so shared object.

gcc -lpthread -ldl -lm -c -fPIC sqlite3.c -o sqlite3.o
gcc sqlite3.o -shared -o libsqlite3.so

To build and install APSW, I used the command

python3 setup.py build install

The installation ran well, but when I execute

python3 -m apsw.tests

to test the installation, I got the error

ImportError: cannot open shared object file: No such file or directory

I need some help to build APSW with a local build of SQLite. Do you know an easy way to do it or what I'm doing wrong in my tries?

Upvotes: 0

Views: 153

Answers (1)

PChemGuy
PChemGuy

Reputation: 1719

You do not need to deal with APSW. The official SQLite binary release can be dropped in place of module included with Python. So you compile SQLite, replace the library that came with Python, and use the stock Python bindings (import sqlite3). I checked it on Windows, but, I suppose, it should work on Linux as well.

Upvotes: -1

Related Questions