This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Detect SQLite in configure.ac
Type: enhancement Stage: resolved
Components: Build Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, erlendaasland
Priority: normal Keywords: patch

Created on 2021-11-09 22:26 by erlendaasland, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 29507 merged erlendaasland, 2021-11-09 22:29
PR 29659 merged erlendaasland, 2021-11-20 13:08
PR 30016 merged erlendaasland, 2021-12-09 22:37
Messages (11)
msg406059 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-11-09 22:26
"Autoconfiscate" SQLite detection. Plan:

- Detect header/library using AC_CHECK_HEADERS/AC_CHECK_LIB
- Check required version using AC_COMPILE_IFELSE
- Use AC_CHECK_LIB to check if sqlite3_load_extension is present, and if the result harmonises with --enable-loadable-sqlite-extensions; bail if not


Nice side effect: configure will bail if --enable-loadable-sqlite-extensions is used and the target SQLite library was compiled with SQLITE_OMIT_LOAD_EXTENSION, even if we are not on macOS.
msg406061 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-11-09 22:46
Your solution looks very similar to my WIP patch:

AC_CHECK_HEADERS([sqlite3.h],
  [AC_SEARCH_LIBS([sqlite3_version], [sqlite3])]
)

AS_VAR_IF([ac_cv_search_sqlite3_version], [no], [], [
  # found a working sqlite3.h and sqlite3 library
  # ac_cv_search_sqlite3_version != no
  LIBS="$LIBS $ac_cv_search_sqlite3_version"
  
  AC_CACHE_CHECK([for sqlite3 version >= 3.7.15], [ac_cv_lib_sqlite3_supported], [
    AC_LINK_IFELSE([
      AC_LANG_PROGRAM([
        #include <sqlite3.h>
        #if SQLITE_VERSION_NUMBER < 3007015
          #error "sqlite version is too old"
        #endif], []
      )
    ], [ac_cv_lib_sqlite3_supported=yes], [ac_cv_lib_sqlite3_supported=no])
  ])
  
  AC_CACHE_CHECK([for sqlite3_enable_load_extension], [ac_cv_lib_sqlite3_sqlite3_enable_load_extension], [
    AC_LINK_IFELSE(
      [AC_LANG_PROGRAM([#include <sqlite3.h>], [void *x = sqlite3_enable_load_extension])],
      [ac_cv_lib_sqlite3_sqlite3_enable_load_extension=yes],
      [ac_cv_lib_sqlite3_sqlite3_enable_load_extension=no])
  ])
])

LIBS=$LIBS_SAVE

AS_VAR_IF([ac_cv_lib_sqlite3_supported], [yes],
  [AC_DEFINE([HAVE_LIBSQLITE3], [1], [Define to 1 if you have the `sqlite3' library (-lsqlite3).])]
)

AS_VAR_IF([ac_cv_lib_sqlite3_sqlite3_enable_load_extension], [yes],
  [AC_DEFINE([HAVE_SQLITE3_ENABLE_LOAD_EXTENSION], [1], 
             [Define to 1 if `sqlite3' library supports sqlite3_enable_load_extension.])]
)
msg406066 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-11-09 23:58
Nice. I think I'll steal some of your ideas tomorrow :)
msg406076 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-11-10 08:08
I saw your message concerning sqlite3 on the FreeBSD buildbot. It's hard to tell why configure on FreeBSD doesn't find sqlite3.h without access to config.log or a shell. Maybe sqlite3 is installed in /usr/local ? ``configure`` does not use /usr/local/include and /usr/local/lib by default. ``setup.py`` extends the search paths for headers and libraries by non-standard locations.

A "config.site" file should do the trick:

$ mkdir -p /usr/local/etc
$ cat > /usr/local/etc/config.site << EOF
test -z "$CPPFLAGS" && CPPFLAGS="-I$/usr/local/include"
test -z "$LDFLAGS" && LDFLAGS="-L/usr/local/lib"
EOF
msg406584 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-11-19 14:10
New changeset 29e5874d5a9205c488f783356d0cf3f115399327 by Erlend Egeberg Aasland in branch 'main':
bpo-45774: Autoconfiscate SQLite detection (GH-29507)
https://github.com/python/cpython/commit/29e5874d5a9205c488f783356d0cf3f115399327
msg406585 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-11-19 14:13
Awesome work! Thanks to your tireless effort we know have a blue print how to use pkg-config for other librariess.
msg406652 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-11-20 13:10
Needs amendment before closing. See GH-29659.
msg406653 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-11-20 13:11
> Awesome work! Thanks to your tireless effort we know have a blue print how to use pkg-config for other librariess.

Thank you for reviewing, and thank you for paving the way with all these build system improvements :)
msg406655 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-11-20 14:03
New changeset 6d430ef5ab62158a200b94dff31b89524a9576bb by Erlend Egeberg Aasland in branch 'main':
bpo-45774: Fix SQLite load extension autodetection (GH-29659)
https://github.com/python/cpython/commit/6d430ef5ab62158a200b94dff31b89524a9576bb
msg408161 - (view) Author: Erlend E. Aasland (erlendaasland) * (Python triager) Date: 2021-12-09 22:33
Reopening: the current detection is a little bit weak; many SQLite API's may be disabled at SQLite compile time using SQLITE_OMIT_* defines. We must make sure we've got all vital functions in place before marking the sqlite3 module as present and usable.

The following API's can be omitted using compile time defines:

- sqlite3_column_decltype (SQLITE_OMIT_DECLTYPE)
- sqlite3_complete (SQLITE_OMIT_COMPLETE)
- sqlite3_enable_shared_cache (SQLITE_OMIT_SHARED_CACHE)
- sqlite3_progress_handler (SQLITE_OMIT_PROGRESS_CALLBACK)
- sqlite3_set_authorizer (SQLITE_OMIT_AUTHORIZATION)
- sqlite3_trace_v2 (SQLITE_OMIT_TRACE)
- sqlite3_trace (SQLITE_OMIT_TRACE, SQLITE_OMIT_DEPRECATED)


The following API's _may_ be disabled in the future using SQLITE_OMIT_FLOATING_POINT:

- sqlite3_bind_double
- sqlite3_column_double
- sqlite3_result_double
- sqlite3_value_double
msg416775 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2022-04-05 12:54
New changeset f1606a5ba50bdc4e7d335d62297b4b4043a25e6e by Erlend Egeberg Aasland in branch 'main':
bpo-45774: Harden SQLite detection (GH-30016)
https://github.com/python/cpython/commit/f1606a5ba50bdc4e7d335d62297b4b4043a25e6e
History
Date User Action Args
2022-04-11 14:59:52adminsetgithub: 89932
2022-04-05 13:56:26erlendaaslandsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-04-05 12:54:55christian.heimessetmessages: + msg416775
2021-12-09 22:37:37erlendaaslandsetstage: resolved -> patch review
pull_requests: + pull_request28240
2021-12-09 22:33:03erlendaaslandsetstatus: closed -> open
resolution: fixed -> (no value)
messages: + msg408161
2021-11-20 16:36:59erlendaaslandsetstatus: open -> closed
resolution: fixed
2021-11-20 14:03:00christian.heimessetmessages: + msg406655
2021-11-20 13:11:19erlendaaslandsetmessages: + msg406653
2021-11-20 13:10:09erlendaaslandsetstatus: closed -> open
resolution: fixed -> (no value)
messages: + msg406652
2021-11-20 13:08:52erlendaaslandsetpull_requests: + pull_request27901
2021-11-19 14:16:12christian.heimeslinkissue45573 superseder
2021-11-19 14:13:02christian.heimessettype: enhancement
messages: + msg406585
2021-11-19 14:12:31erlendaaslandsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-11-19 14:10:45christian.heimessetmessages: + msg406584
2021-11-10 08:08:29christian.heimessetmessages: + msg406076
2021-11-09 23:58:42erlendaaslandsetmessages: + msg406066
2021-11-09 22:46:50christian.heimessetmessages: + msg406061
2021-11-09 22:29:01erlendaaslandsetkeywords: + patch
stage: patch review
pull_requests: + pull_request27758
2021-11-09 22:26:46erlendaaslandcreate