coleifer / pysqlite3

SQLite3 DB-API 2.0 driver from Python 3, packaged separately, with improvements
zlib License
188 stars 53 forks source link

how to solve this problem on mac ? #61

Closed mushanzi1216 closed 1 year ago

mushanzi1216 commented 1 year ago

ollecting pysqlite3 Using cached pysqlite3-0.5.1.tar.gz (40 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: pysqlite3 Building wheel for pysqlite3 (pyproject.toml) ... error error: subprocess-exited-with-error

× Building wheel for pysqlite3 (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [41 lines of output] running bdist_wheel running build running build_py creating build creating build/lib.macosx-10.9-x86_64-cpython-39 creating build/lib.macosx-10.9-x86_64-cpython-39/pysqlite3 copying pysqlite3/init.py -> build/lib.macosx-10.9-x86_64-cpython-39/pysqlite3 copying pysqlite3/dbapi2.py -> build/lib.macosx-10.9-x86_64-cpython-39/pysqlite3 running build_ext Builds a C extension linking against libsqlite3 library building 'pysqlite3._sqlite3' extension creating build/temp.macosx-10.9-x86_64-cpython-39 creating build/temp.macosx-10.9-x86_64-cpython-39/src gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -Qunused-arguments -DMODULE_NAME=\"pysqlite3.dbapi2\" -I/usr/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/blob.c -o build/temp.macosx-10.9-x86_64-cpython-39/src/blob.o gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -Qunused-arguments -DMODULE_NAME=\"pysqlite3.dbapi2\" -I/usr/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/cache.c -o build/temp.macosx-10.9-x86_64-cpython-39/src/cache.o gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -Qunused-arguments -DMODULE_NAME=\"pysqlite3.dbapi2\" -I/usr/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/connection.c -o build/temp.macosx-10.9-x86_64-cpython-39/src/connection.o src/connection.c:1111:10: warning: 'sqlite3_create_window_function' is only available on macOS 10.15 or newer [-Wunguarded-availability-new] rc = sqlite3_create_window_function( ^~~~~~~~~~ /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sqlite3.h:5192:16: note: 'sqlite3_create_window_function' has been marked as being introduced in macOS 10.15 here, but the deployment target is macOS 10.9.0 SQLITE_API int sqlite3_create_window_function( ^ src/connection.c:1111:10: note: enclose 'sqlite3_create_window_function' in a __builtin_available check to silence this warning rc = sqlite3_create_window_function( ^~~~~~~~~~ src/connection.c:1385:10: error: implicit declaration of function 'sqlite3_enable_load_extension' is invalid in C99 [-Werror,-Wimplicit-function-declaration] rc = sqlite3_enable_load_extension(self->db, onoff); ^ src/connection.c:1385:10: note: did you mean 'pysqlite_enable_load_extension'? src/connection.c:1372:18: note: 'pysqlite_enable_load_extension' declared here static PyObject pysqlite_enable_load_extension(pysqlite_Connection self, PyObject args) ^ src/connection.c:1409:10: error: implicit declaration of function 'sqlite3_load_extension' is invalid in C99 [-Werror,-Wimplicit-function-declaration] rc = sqlite3_load_extension(self->db, extension_name, 0, &errmsg); ^ src/connection.c:1409:10: note: did you mean 'pysqlite_load_extension'? src/connection.c:1395:18: note: 'pysqlite_load_extension' declared here static PyObject pysqlite_load_extension(pysqlite_Connection self, PyObject args) ^ 1 warning and 2 errors generated. error: command '/usr/bin/gcc' failed with exit code 1 [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pysqlite3 Failed to build pysqlite3 ERROR: Could not build wheels for pysqlite3, which is required to install pyproject.toml-based projects

coleifer commented 1 year ago

The error indicates exactly the issue: your target macos 10.9 doesn't have a new enough sqlite to support window functions. Apparently your local environment does support window functions, as they are conditionally included: https://github.com/coleifer/pysqlite3/blob/master/src/connection.c#L52

So it comes down to a difference between your local environment and the target environment.

I'd suggest looking at building a statically linked library and bundling sqlite. Instructions are on the readme.

https://github.com/coleifer/pysqlite3#building-a-statically-linked-library

mushanzi1216 commented 1 year ago

The error indicates exactly the issue: your target macos 10.9 doesn't have a new enough sqlite to support window functions. Apparently your local environment does support window functions, as they are conditionally included: https://github.com/coleifer/pysqlite3/blob/master/src/connection.c#L52

So it comes down to a difference between your local environment and the target environment.

I'd suggest looking at building a statically linked library and bundling sqlite. Instructions are on the readme.

https://github.com/coleifer/pysqlite3#building-a-statically-linked-library

follow your opinion, i build a statically linked library ,but after running 'python setup.py build_static build',i got this problem image

coleifer commented 1 year ago

Wait wait wait you're using python 2?

This library is python 3 only.

mushanzi1216 commented 1 year ago

thank you
i have 2 versions of python .Just now I used the wrong command,i should use 'python3 setup.py build_static build' thanks again!! but when i show the sqlite3 version in python why still the old one image

coleifer commented 1 year ago

You need to use pysqlite3, not the standard library sqlite3:

from pysqlite3 import dbapi2 as sqlite3
print(sqlite3.sqlite_version_info)
mushanzi1216 commented 1 year ago

my actually situation is i'm using a embedding database libray called Chroma it need sqltie which version must higher than 3.3.35

image
coleifer commented 1 year ago

That's not really my issue. I'd suggest taking it up with them and asking for a conditional import of pysqlite3 if it's available, eg https://github.com/chroma-core/chroma/blob/main/chromadb/db/impl/sqlite.py#L8

mushanzi1216 commented 1 year ago

you are right! but i can't wait for them. finnally i find this way ,try to replace their libray

image