diff --git a/Makefile.pre.in b/Makefile.pre.in index 1afd9e13319..2e42d53d5b9 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -2490,6 +2490,7 @@ MODULE__SHA512_DEPS=$(srcdir)/Modules/hashlib.h MODULE__SOCKET_DEPS=$(srcdir)/Modules/socketmodule.h MODULE__SSL_DEPS=$(srcdir)/Modules/_ssl.h $(srcdir)/Modules/_ssl/cert.c $(srcdir)/Modules/_ssl/debughelpers.c $(srcdir)/Modules/_ssl/misc.c $(srcdir)/Modules/_ssl_data.h $(srcdir)/Modules/_ssl_data_111.h $(srcdir)/Modules/_ssl_data_300.h $(srcdir)/Modules/socketmodule.h MODULE__TESTCAPI_DEPS=$(srcdir)/Modules/testcapi_long.h +MODULE__SQLITE3_DEPS=$(srcdir)/Modules/_sqlite/connection.h $(srcdir)/Modules/_sqlite/cursor.h $(srcdir)/Modules/_sqlite/microprotocols.h $(srcdir)/Modules/_sqlite/module.h $(srcdir)/Modules/_sqlite/prepare_protocol.h $(srcdir)/Modules/_sqlite/row.h $(srcdir)/Modules/_sqlite/util.h # IF YOU PUT ANYTHING HERE IT WILL GO AWAY # Local Variables: diff --git a/Misc/NEWS.d/next/Build/2021-11-09-23-30-12.bpo-45774.Mwm3ZR.rst b/Misc/NEWS.d/next/Build/2021-11-09-23-30-12.bpo-45774.Mwm3ZR.rst new file mode 100644 index 00000000000..09095ab2cf9 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2021-11-09-23-30-12.bpo-45774.Mwm3ZR.rst @@ -0,0 +1,2 @@ +The build dependencies for :mod:`sqlite3` are now detected by ``configure`` and +``pkg-config``. Patch by Erlend E. Aasland. diff --git a/Modules/Setup b/Modules/Setup index 414c6af4b69..f8c90ea7772 100644 --- a/Modules/Setup +++ b/Modules/Setup @@ -227,7 +227,6 @@ time timemodule.c #_dbm _dbmmodule.c -lgdbm_compat -DUSE_GDBM_COMPAT #_gdbm _gdbmmodule.c -lgdbm #_lzma _lzmamodule.c -llzma -#_sqlite3 _sqlite/connection.c _sqlite/cursor.c _sqlite/microprotocols.c _sqlite/module.c _sqlite/prepare_protocol.c _sqlite/row.c _sqlite/statement.c _sqlite/util.c -lsqlite3 #_uuid _uuidmodule.c -luuid #zlib zlibmodule.c -lz diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in index 0722eae87a3..2e87b032e35 100644 --- a/Modules/Setup.stdlib.in +++ b/Modules/Setup.stdlib.in @@ -53,3 +53,9 @@ # Linux and FreeBSD, needs sys/soundcard.h or linux/soundcard.h @MODULE_OSSAUDIODEV_TRUE@ossaudiodev ossaudiodev.c + + +############################################################################ +# Modules with third party dependencies +# +@MODULE__SQLITE3_TRUE@_sqlite3 _sqlite/connection.c _sqlite/cursor.c _sqlite/microprotocols.c _sqlite/module.c _sqlite/prepare_protocol.c _sqlite/row.c _sqlite/statement.c _sqlite/util.c diff --git a/configure b/configure index fc7b8dc5968..657c71dca62 100755 --- a/configure +++ b/configure @@ -624,6 +624,8 @@ ac_includes_default="\ ac_subst_vars='LTLIBOBJS MODULE_BLOCK +MODULE__SQLITE3_FALSE +MODULE__SQLITE3_TRUE MODULE__DECIMAL_FALSE MODULE__DECIMAL_TRUE MODULE__ELEMENTTREE_FALSE @@ -669,6 +671,8 @@ DFLAGS DTRACE TCLTK_LIBS TCLTK_INCLUDES +LIBSQLITE3_LIBS +LIBSQLITE3_CFLAGS LIBMPDEC_INTERNAL LIBMPDEC_LDFLAGS LIBMPDEC_CFLAGS @@ -895,7 +899,9 @@ LDFLAGS LIBS CPPFLAGS CPP -PROFILE_TASK' +PROFILE_TASK +LIBSQLITE3_CFLAGS +LIBSQLITE3_LIBS' # Initialize some variables set by options. @@ -1669,6 +1675,10 @@ Some influential environment variables: CPP C preprocessor PROFILE_TASK Python args for PGO generation task + LIBSQLITE3_CFLAGS + C compiler flags for LIBSQLITE3, overriding pkg-config + LIBSQLITE3_LIBS + linker flags for LIBSQLITE3, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -10930,12 +10940,229 @@ if test "$have_glibc_memmove_bug" = yes; then as_fn_append LIBMPDEC_CFLAGS " -U_FORTIFY_SOURCE" fi + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBSQLITE3" >&5 +$as_echo_n "checking for LIBSQLITE3... " >&6; } + +if test -n "$LIBSQLITE3_CFLAGS"; then + pkg_cv_LIBSQLITE3_CFLAGS="$LIBSQLITE3_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sqlite3 >= 3.7.15\""; } >&5 + ($PKG_CONFIG --exists --print-errors "sqlite3 >= 3.7.15") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBSQLITE3_CFLAGS=`$PKG_CONFIG --cflags "sqlite3 >= 3.7.15" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$LIBSQLITE3_LIBS"; then + pkg_cv_LIBSQLITE3_LIBS="$LIBSQLITE3_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sqlite3 >= 3.7.15\""; } >&5 + ($PKG_CONFIG --exists --print-errors "sqlite3 >= 3.7.15") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBSQLITE3_LIBS=`$PKG_CONFIG --libs "sqlite3 >= 3.7.15" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + LIBSQLITE3_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "sqlite3 >= 3.7.15" 2>&1` + else + LIBSQLITE3_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "sqlite3 >= 3.7.15" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$LIBSQLITE3_PKG_ERRORS" >&5 + + + LIBSQLITE3_LIBS="-lsqlite3" + LIBSQLITE3_CFLAGS= + + +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + + LIBSQLITE3_LIBS="-lsqlite3" + LIBSQLITE3_CFLAGS= + + +else + LIBSQLITE3_CFLAGS=$pkg_cv_LIBSQLITE3_CFLAGS + LIBSQLITE3_LIBS=$pkg_cv_LIBSQLITE3_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +fi +as_fn_append LIBSQLITE3_CFLAGS ' -I$(srcdir)/Modules/_sqlite' + +save_CFLAGS=$CFLAGS +save_CPPFLAGS=$CPPFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS +CPPFLAGS="$LIBSQLITE3_CFLAGS $CFLAGS" +LDFLAGS="$LIBSQLITE3_LIBS $LDFLAGS" + +ac_fn_c_check_header_mongrel "$LINENO" "sqlite3.h" "ac_cv_header_sqlite3_h" "$ac_includes_default" +if test "x$ac_cv_header_sqlite3_h" = xyes; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_open_v2 in -lsqlite3" >&5 +$as_echo_n "checking for sqlite3_open_v2 in -lsqlite3... " >&6; } +if ${ac_cv_lib_sqlite3_sqlite3_open_v2+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsqlite3 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sqlite3_open_v2 (); +int +main () +{ +return sqlite3_open_v2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_sqlite3_sqlite3_open_v2=yes +else + ac_cv_lib_sqlite3_sqlite3_open_v2=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_open_v2" >&5 +$as_echo "$ac_cv_lib_sqlite3_sqlite3_open_v2" >&6; } +if test "x$ac_cv_lib_sqlite3_sqlite3_open_v2" = xyes; then : + + have_sqlite3=yes + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + + #include + #if SQLITE_VERSION_NUMBER < 3007015 + # error "SQLite 3.7.15 or higher required" + #endif + +int +main () +{ + + ; + return 0; +} + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + have_supported_sqlite3=yes +else + have_supported_sqlite3=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +else + have_sqlite3=no +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_load_extension in -lsqlite3" >&5 +$as_echo_n "checking for sqlite3_load_extension in -lsqlite3... " >&6; } +if ${ac_cv_lib_sqlite3_sqlite3_load_extension+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsqlite3 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char sqlite3_load_extension (); +int +main () +{ +return sqlite3_load_extension (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_sqlite3_sqlite3_load_extension=yes +else + ac_cv_lib_sqlite3_sqlite3_load_extension=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_load_extension" >&5 +$as_echo "$ac_cv_lib_sqlite3_sqlite3_load_extension" >&6; } +if test "x$ac_cv_lib_sqlite3_sqlite3_load_extension" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSQLITE3 1 +_ACEOF + + LIBS="-lsqlite3 $LIBS" + +fi + + +fi + + + +CFLAGS=$save_CFLAGS +CPPFLAGS=$save_CPPFLAGS +LDFLAGS=$save_LDFLAGS +LIBS=$save_LIBS + # Check for support for loadable sqlite extensions { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --enable-loadable-sqlite-extensions" >&5 $as_echo_n "checking for --enable-loadable-sqlite-extensions... " >&6; } # Check whether --enable-loadable-sqlite-extensions was given. if test "${enable_loadable_sqlite_extensions+set}" = set; then : - enableval=$enable_loadable_sqlite_extensions; + enableval=$enable_loadable_sqlite_extensions; if test "x$have_sqlite3_load_extension" = xno; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Your version of SQLite does not support loadable extensions" >&5 +$as_echo "$as_me: WARNING: Your version of SQLite does not support loadable extensions" >&2;} +fi else enable_loadable_sqlite_extensions=no fi @@ -19431,6 +19658,56 @@ fi $as_echo "$py_cv_module__decimal" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _sqlite3" >&5 +$as_echo_n "checking for stdlib extension module _sqlite3... " >&6; } + case $py_stdlib_not_available in #( + *_sqlite3*) : + py_cv_module__sqlite3=n/a ;; #( + *) : + + if test "$have_sqlite3" = "yes"; then : + if test "$have_supported_sqlite3" = "yes"; then : + py_cv_module__sqlite3=yes +else + py_cv_module__sqlite3=missing +fi +else + py_cv_module__sqlite3=disabled + +fi + + ;; +esac + as_fn_append MODULE_BLOCK "MODULE__SQLITE3=$py_cv_module__sqlite3$as_nl" + if test "x$py_cv_module__sqlite3" = xyes; then : + + as_fn_append MODULE_BLOCK "MODULE__SQLITE3_CFLAGS=$LIBSQLITE3_CFLAGS$as_nl" + as_fn_append MODULE_BLOCK "MODULE__SQLITE3_LDFLAGS=$LIBSQLITE3_LIBS$as_nl" + if true; then + MODULE__SQLITE3_TRUE= + MODULE__SQLITE3_FALSE='#' +else + MODULE__SQLITE3_TRUE='#' + MODULE__SQLITE3_FALSE= +fi + + +else + + if false; then + MODULE__SQLITE3_TRUE= + MODULE__SQLITE3_FALSE='#' +else + MODULE__SQLITE3_TRUE='#' + MODULE__SQLITE3_FALSE= +fi + + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $py_cv_module__sqlite3" >&5 +$as_echo "$py_cv_module__sqlite3" >&6; } + + # substitute multiline block, must come after last PY_STDLIB_MOD() @@ -19583,6 +19860,14 @@ if test -z "${MODULE__DECIMAL_TRUE}" && test -z "${MODULE__DECIMAL_FALSE}"; then as_fn_error $? "conditional \"MODULE__DECIMAL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${MODULE__SQLITE3_TRUE}" && test -z "${MODULE__SQLITE3_FALSE}"; then + as_fn_error $? "conditional \"MODULE__SQLITE3\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${MODULE__SQLITE3_TRUE}" && test -z "${MODULE__SQLITE3_FALSE}"; then + as_fn_error $? "conditional \"MODULE__SQLITE3\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 diff --git a/configure.ac b/configure.ac index d2cb67a39cb..4bac7ccf248 100644 --- a/configure.ac +++ b/configure.ac @@ -3165,12 +3165,52 @@ if test "$have_glibc_memmove_bug" = yes; then AS_VAR_APPEND([LIBMPDEC_CFLAGS], [" -U_FORTIFY_SOURCE"]) fi +dnl Check for SQLite library. Use pkg-config if available. +PKG_CHECK_MODULES( + [LIBSQLITE3], [sqlite3 >= 3.7.15], [], [ + LIBSQLITE3_LIBS="-lsqlite3" + LIBSQLITE3_CFLAGS= + ] +) +AS_VAR_APPEND([LIBSQLITE3_CFLAGS], [' -I$(srcdir)/Modules/_sqlite']) + +dnl bpo-45774/GH-29507: The CPP check in AC_CHECK_HEADER can fail on FreeBSD, +dnl hence CPPFLAGS instead of CFLAGS. We still need to save CFLAGS, because it +dnl is touched by AC_CHECK_HEADER. +AS_VAR_COPY([save_CFLAGS], [CFLAGS]) +AS_VAR_COPY([save_CPPFLAGS], [CPPFLAGS]) +AS_VAR_COPY([save_LDFLAGS], [LDFLAGS]) +AS_VAR_COPY([save_LIBS], [LIBS]) +CPPFLAGS="$LIBSQLITE3_CFLAGS $CFLAGS" +LDFLAGS="$LIBSQLITE3_LIBS $LDFLAGS" + +AC_CHECK_HEADER([sqlite3.h], [ + AC_CHECK_LIB([sqlite3], [sqlite3_open_v2], [ + have_sqlite3=yes + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ + #include + #if SQLITE_VERSION_NUMBER < 3007015 + # error "SQLite 3.7.15 or higher required" + #endif + ], []) + ], [have_supported_sqlite3=yes], [have_supported_sqlite3=no]) + ], [have_sqlite3=no]) + AC_CHECK_LIB([sqlite3], [sqlite3_load_extension]) +]) + +AS_VAR_COPY([CFLAGS], [save_CFLAGS]) +AS_VAR_COPY([CPPFLAGS], [save_CPPFLAGS]) +AS_VAR_COPY([LDFLAGS], [save_LDFLAGS]) +AS_VAR_COPY([LIBS], [save_LIBS]) + # Check for support for loadable sqlite extensions AC_MSG_CHECKING(for --enable-loadable-sqlite-extensions) AC_ARG_ENABLE(loadable-sqlite-extensions, AS_HELP_STRING([--enable-loadable-sqlite-extensions], [support loadable extensions in _sqlite module, see Doc/library/sqlite3.rst (default is no)]), - [], + [AS_VAR_IF([have_sqlite3_load_extension], [no], + [AC_MSG_WARN([Your version of SQLite does not support loadable extensions])])], [enable_loadable_sqlite_extensions=no]) AC_MSG_RESULT($enable_loadable_sqlite_extensions) @@ -5999,6 +6039,10 @@ PY_STDLIB_MOD([pyexpat], [], [], [$LIBEXPAT_CFLAGS], [$LIBEXPAT_LDFLAGS]) PY_STDLIB_MOD([_elementtree], [], [], [$LIBEXPAT_CFLAGS], []) PY_STDLIB_MOD([_decimal], [], [], [$LIBMPDEC_CFLAGS], [$LIBMPDEC_LDFLAGS]) +PY_STDLIB_MOD([_sqlite3], + [test "$have_sqlite3" = "yes"], + [test "$have_supported_sqlite3" = "yes"], + [$LIBSQLITE3_CFLAGS], [$LIBSQLITE3_LIBS]) # substitute multiline block, must come after last PY_STDLIB_MOD() AC_SUBST([MODULE_BLOCK]) diff --git a/pyconfig.h.in b/pyconfig.h.in index b8f63955e31..0cc593fdfc5 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -634,6 +634,9 @@ /* Define to 1 if you have the `sendfile' library (-lsendfile). */ #undef HAVE_LIBSENDFILE +/* Define to 1 if you have the `sqlite3' library (-lsqlite3). */ +#undef HAVE_LIBSQLITE3 + /* Define to 1 if you have the header file. */ #undef HAVE_LIBUTIL_H diff --git a/setup.py b/setup.py index a09cf18213f..040f90af601 100644 --- a/setup.py +++ b/setup.py @@ -1371,108 +1371,17 @@ class PyBuildExt(build_ext): self.missing.append('_gdbm') def detect_sqlite(self): - # The sqlite interface - sqlite_setup_debug = False # verbose debug prints from this script? - - # We hunt for #define SQLITE_VERSION "n.n.n" - sqlite_incdir = sqlite_libdir = None - sqlite_inc_paths = [ '/usr/include', - '/usr/include/sqlite', - '/usr/include/sqlite3', - '/usr/local/include', - '/usr/local/include/sqlite', - '/usr/local/include/sqlite3', - ] - if CROSS_COMPILING: - sqlite_inc_paths = [] - MIN_SQLITE_VERSION_NUMBER = (3, 7, 15) # Issue 40810 - MIN_SQLITE_VERSION = ".".join([str(x) - for x in MIN_SQLITE_VERSION_NUMBER]) - - # Scan the default include directories before the SQLite specific - # ones. This allows one to override the copy of sqlite on OSX, - # where /usr/include contains an old version of sqlite. - if MACOS: - sysroot = macosx_sdk_root() - - for d_ in self.inc_dirs + sqlite_inc_paths: - d = d_ - if MACOS and is_macosx_sdk_path(d): - d = os.path.join(sysroot, d[1:]) - - f = os.path.join(d, "sqlite3.h") - if os.path.exists(f): - if sqlite_setup_debug: print("sqlite: found %s"%f) - with open(f) as file: - incf = file.read() - m = re.search( - r'\s*.*#\s*.*define\s.*SQLITE_VERSION\W*"([\d\.]*)"', incf) - if m: - sqlite_version = m.group(1) - sqlite_version_tuple = tuple([int(x) - for x in sqlite_version.split(".")]) - if sqlite_version_tuple >= MIN_SQLITE_VERSION_NUMBER: - # we win! - if sqlite_setup_debug: - print("%s/sqlite3.h: version %s"%(d, sqlite_version)) - sqlite_incdir = d - break - else: - if sqlite_setup_debug: - print("%s: version %s is too old, need >= %s"%(d, - sqlite_version, MIN_SQLITE_VERSION)) - elif sqlite_setup_debug: - print("sqlite: %s had no SQLITE_VERSION"%(f,)) - - if sqlite_incdir: - sqlite_dirs_to_check = [ - os.path.join(sqlite_incdir, '..', 'lib64'), - os.path.join(sqlite_incdir, '..', 'lib'), - os.path.join(sqlite_incdir, '..', '..', 'lib64'), - os.path.join(sqlite_incdir, '..', '..', 'lib'), - ] - sqlite_libfile = self.compiler.find_library_file( - sqlite_dirs_to_check + self.lib_dirs, 'sqlite3') - if sqlite_libfile: - sqlite_libdir = [os.path.abspath(os.path.dirname(sqlite_libfile))] - - if sqlite_incdir and sqlite_libdir: - sqlite_srcs = [ - '_sqlite/connection.c', - '_sqlite/cursor.c', - '_sqlite/microprotocols.c', - '_sqlite/module.c', - '_sqlite/prepare_protocol.c', - '_sqlite/row.c', - '_sqlite/statement.c', - '_sqlite/util.c', ] - sqlite_defines = [] - - # Enable support for loadable extensions in the sqlite3 module - # if --enable-loadable-sqlite-extensions configure option is used. - if ( - MACOS and - sqlite_incdir == os.path.join(MACOS_SDK_ROOT, "usr/include") and - sysconfig.get_config_var("PY_SQLITE_ENABLE_LOAD_EXTENSION") - ): - raise DistutilsError("System version of SQLite does not support loadable extensions") - - include_dirs = ["Modules/_sqlite"] - # Only include the directory where sqlite was found if it does - # not already exist in set include directories, otherwise you - # can end up with a bad search path order. - if sqlite_incdir not in self.compiler.include_dirs: - include_dirs.append(sqlite_incdir) - # avoid a runtime library path for a system library dir - if sqlite_libdir and sqlite_libdir[0] in self.lib_dirs: - sqlite_libdir = None - self.add(Extension('_sqlite3', sqlite_srcs, - define_macros=sqlite_defines, - include_dirs=include_dirs, - library_dirs=sqlite_libdir, - libraries=["sqlite3",])) - else: - self.missing.append('_sqlite3') + sources = [ + "_sqlite/connection.c", + "_sqlite/cursor.c", + "_sqlite/microprotocols.c", + "_sqlite/module.c", + "_sqlite/prepare_protocol.c", + "_sqlite/row.c", + "_sqlite/statement.c", + "_sqlite/util.c", + ] + self.addext(Extension("_sqlite3", sources=sources)) def detect_platform_specific_exts(self): # Unix-only modules