Skip to content

Commit 29e5874

Browse files
Erlend Egeberg Aaslandtiran
Erlend Egeberg Aasland
andauthored
bpo-45774: Autoconfiscate SQLite detection (GH-29507)
Co-authored-by: Christian Heimes <[email protected]>
1 parent 036fead commit 29e5874

File tree

8 files changed

+355
-106
lines changed

8 files changed

+355
-106
lines changed

Makefile.pre.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,6 +2490,7 @@ MODULE__SHA512_DEPS=$(srcdir)/Modules/hashlib.h
24902490
MODULE__SOCKET_DEPS=$(srcdir)/Modules/socketmodule.h
24912491
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
24922492
MODULE__TESTCAPI_DEPS=$(srcdir)/Modules/testcapi_long.h
2493+
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
24932494

24942495
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
24952496
# Local Variables:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The build dependencies for :mod:`sqlite3` are now detected by ``configure`` and
2+
``pkg-config``. Patch by Erlend E. Aasland.

Modules/Setup

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ time timemodule.c
227227
#_dbm _dbmmodule.c -lgdbm_compat -DUSE_GDBM_COMPAT
228228
#_gdbm _gdbmmodule.c -lgdbm
229229
#_lzma _lzmamodule.c -llzma
230-
#_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
231230
#_uuid _uuidmodule.c -luuid
232231
#zlib zlibmodule.c -lz
233232

Modules/Setup.stdlib.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,9 @@
5353

5454
# Linux and FreeBSD, needs sys/soundcard.h or linux/soundcard.h
5555
@MODULE_OSSAUDIODEV_TRUE@ossaudiodev ossaudiodev.c
56+
57+
58+
############################################################################
59+
# Modules with third party dependencies
60+
#
61+
@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

configure

Lines changed: 287 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,8 @@ ac_includes_default="\
624624

625625
ac_subst_vars='LTLIBOBJS
626626
MODULE_BLOCK
627+
MODULE__SQLITE3_FALSE
628+
MODULE__SQLITE3_TRUE
627629
MODULE__DECIMAL_FALSE
628630
MODULE__DECIMAL_TRUE
629631
MODULE__ELEMENTTREE_FALSE
@@ -669,6 +671,8 @@ DFLAGS
669671
DTRACE
670672
TCLTK_LIBS
671673
TCLTK_INCLUDES
674+
LIBSQLITE3_LIBS
675+
LIBSQLITE3_CFLAGS
672676
LIBMPDEC_INTERNAL
673677
LIBMPDEC_LDFLAGS
674678
LIBMPDEC_CFLAGS
@@ -895,7 +899,9 @@ LDFLAGS
895899
LIBS
896900
CPPFLAGS
897901
CPP
898-
PROFILE_TASK'
902+
PROFILE_TASK
903+
LIBSQLITE3_CFLAGS
904+
LIBSQLITE3_LIBS'
899905

900906

901907
# Initialize some variables set by options.
@@ -1669,6 +1675,10 @@ Some influential environment variables:
16691675
CPP C preprocessor
16701676
PROFILE_TASK
16711677
Python args for PGO generation task
1678+
LIBSQLITE3_CFLAGS
1679+
C compiler flags for LIBSQLITE3, overriding pkg-config
1680+
LIBSQLITE3_LIBS
1681+
linker flags for LIBSQLITE3, overriding pkg-config
16721682

16731683
Use these variables to override the choices made by `configure' or to help
16741684
it to find libraries and programs with nonstandard names/locations.
@@ -10930,12 +10940,229 @@ if test "$have_glibc_memmove_bug" = yes; then
1093010940
as_fn_append LIBMPDEC_CFLAGS " -U_FORTIFY_SOURCE"
1093110941
fi
1093210942

10943+
10944+
pkg_failed=no
10945+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBSQLITE3" >&5
10946+
$as_echo_n "checking for LIBSQLITE3... " >&6; }
10947+
10948+
if test -n "$LIBSQLITE3_CFLAGS"; then
10949+
pkg_cv_LIBSQLITE3_CFLAGS="$LIBSQLITE3_CFLAGS"
10950+
elif test -n "$PKG_CONFIG"; then
10951+
if test -n "$PKG_CONFIG" && \
10952+
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sqlite3 >= 3.7.15\""; } >&5
10953+
($PKG_CONFIG --exists --print-errors "sqlite3 >= 3.7.15") 2>&5
10954+
ac_status=$?
10955+
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
10956+
test $ac_status = 0; }; then
10957+
pkg_cv_LIBSQLITE3_CFLAGS=`$PKG_CONFIG --cflags "sqlite3 >= 3.7.15" 2>/dev/null`
10958+
test "x$?" != "x0" && pkg_failed=yes
10959+
else
10960+
pkg_failed=yes
10961+
fi
10962+
else
10963+
pkg_failed=untried
10964+
fi
10965+
if test -n "$LIBSQLITE3_LIBS"; then
10966+
pkg_cv_LIBSQLITE3_LIBS="$LIBSQLITE3_LIBS"
10967+
elif test -n "$PKG_CONFIG"; then
10968+
if test -n "$PKG_CONFIG" && \
10969+
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"sqlite3 >= 3.7.15\""; } >&5
10970+
($PKG_CONFIG --exists --print-errors "sqlite3 >= 3.7.15") 2>&5
10971+
ac_status=$?
10972+
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
10973+
test $ac_status = 0; }; then
10974+
pkg_cv_LIBSQLITE3_LIBS=`$PKG_CONFIG --libs "sqlite3 >= 3.7.15" 2>/dev/null`
10975+
test "x$?" != "x0" && pkg_failed=yes
10976+
else
10977+
pkg_failed=yes
10978+
fi
10979+
else
10980+
pkg_failed=untried
10981+
fi
10982+
10983+
10984+
10985+
if test $pkg_failed = yes; then
10986+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10987+
$as_echo "no" >&6; }
10988+
10989+
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
10990+
_pkg_short_errors_supported=yes
10991+
else
10992+
_pkg_short_errors_supported=no
10993+
fi
10994+
if test $_pkg_short_errors_supported = yes; then
10995+
LIBSQLITE3_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "sqlite3 >= 3.7.15" 2>&1`
10996+
else
10997+
LIBSQLITE3_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "sqlite3 >= 3.7.15" 2>&1`
10998+
fi
10999+
# Put the nasty error message in config.log where it belongs
11000+
echo "$LIBSQLITE3_PKG_ERRORS" >&5
11001+
11002+
11003+
LIBSQLITE3_LIBS="-lsqlite3"
11004+
LIBSQLITE3_CFLAGS=
11005+
11006+
11007+
elif test $pkg_failed = untried; then
11008+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
11009+
$as_echo "no" >&6; }
11010+
11011+
LIBSQLITE3_LIBS="-lsqlite3"
11012+
LIBSQLITE3_CFLAGS=
11013+
11014+
11015+
else
11016+
LIBSQLITE3_CFLAGS=$pkg_cv_LIBSQLITE3_CFLAGS
11017+
LIBSQLITE3_LIBS=$pkg_cv_LIBSQLITE3_LIBS
11018+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
11019+
$as_echo "yes" >&6; }
11020+
11021+
fi
11022+
as_fn_append LIBSQLITE3_CFLAGS ' -I$(srcdir)/Modules/_sqlite'
11023+
11024+
save_CFLAGS=$CFLAGS
11025+
save_CPPFLAGS=$CPPFLAGS
11026+
save_LDFLAGS=$LDFLAGS
11027+
save_LIBS=$LIBS
11028+
CPPFLAGS="$LIBSQLITE3_CFLAGS $CFLAGS"
11029+
LDFLAGS="$LIBSQLITE3_LIBS $LDFLAGS"
11030+
11031+
ac_fn_c_check_header_mongrel "$LINENO" "sqlite3.h" "ac_cv_header_sqlite3_h" "$ac_includes_default"
11032+
if test "x$ac_cv_header_sqlite3_h" = xyes; then :
11033+
11034+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_open_v2 in -lsqlite3" >&5
11035+
$as_echo_n "checking for sqlite3_open_v2 in -lsqlite3... " >&6; }
11036+
if ${ac_cv_lib_sqlite3_sqlite3_open_v2+:} false; then :
11037+
$as_echo_n "(cached) " >&6
11038+
else
11039+
ac_check_lib_save_LIBS=$LIBS
11040+
LIBS="-lsqlite3 $LIBS"
11041+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11042+
/* end confdefs.h. */
11043+
11044+
/* Override any GCC internal prototype to avoid an error.
11045+
Use char because int might match the return type of a GCC
11046+
builtin and then its argument prototype would still apply. */
11047+
#ifdef __cplusplus
11048+
extern "C"
11049+
#endif
11050+
char sqlite3_open_v2 ();
11051+
int
11052+
main ()
11053+
{
11054+
return sqlite3_open_v2 ();
11055+
;
11056+
return 0;
11057+
}
11058+
_ACEOF
11059+
if ac_fn_c_try_link "$LINENO"; then :
11060+
ac_cv_lib_sqlite3_sqlite3_open_v2=yes
11061+
else
11062+
ac_cv_lib_sqlite3_sqlite3_open_v2=no
11063+
fi
11064+
rm -f core conftest.err conftest.$ac_objext \
11065+
conftest$ac_exeext conftest.$ac_ext
11066+
LIBS=$ac_check_lib_save_LIBS
11067+
fi
11068+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_open_v2" >&5
11069+
$as_echo "$ac_cv_lib_sqlite3_sqlite3_open_v2" >&6; }
11070+
if test "x$ac_cv_lib_sqlite3_sqlite3_open_v2" = xyes; then :
11071+
11072+
have_sqlite3=yes
11073+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11074+
/* end confdefs.h. */
11075+
11076+
11077+
#include <sqlite3.h>
11078+
#if SQLITE_VERSION_NUMBER < 3007015
11079+
# error "SQLite 3.7.15 or higher required"
11080+
#endif
11081+
11082+
int
11083+
main ()
11084+
{
11085+
11086+
;
11087+
return 0;
11088+
}
11089+
11090+
_ACEOF
11091+
if ac_fn_c_try_compile "$LINENO"; then :
11092+
have_supported_sqlite3=yes
11093+
else
11094+
have_supported_sqlite3=no
11095+
fi
11096+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
11097+
11098+
else
11099+
have_sqlite3=no
11100+
fi
11101+
11102+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_load_extension in -lsqlite3" >&5
11103+
$as_echo_n "checking for sqlite3_load_extension in -lsqlite3... " >&6; }
11104+
if ${ac_cv_lib_sqlite3_sqlite3_load_extension+:} false; then :
11105+
$as_echo_n "(cached) " >&6
11106+
else
11107+
ac_check_lib_save_LIBS=$LIBS
11108+
LIBS="-lsqlite3 $LIBS"
11109+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11110+
/* end confdefs.h. */
11111+
11112+
/* Override any GCC internal prototype to avoid an error.
11113+
Use char because int might match the return type of a GCC
11114+
builtin and then its argument prototype would still apply. */
11115+
#ifdef __cplusplus
11116+
extern "C"
11117+
#endif
11118+
char sqlite3_load_extension ();
11119+
int
11120+
main ()
11121+
{
11122+
return sqlite3_load_extension ();
11123+
;
11124+
return 0;
11125+
}
11126+
_ACEOF
11127+
if ac_fn_c_try_link "$LINENO"; then :
11128+
ac_cv_lib_sqlite3_sqlite3_load_extension=yes
11129+
else
11130+
ac_cv_lib_sqlite3_sqlite3_load_extension=no
11131+
fi
11132+
rm -f core conftest.err conftest.$ac_objext \
11133+
conftest$ac_exeext conftest.$ac_ext
11134+
LIBS=$ac_check_lib_save_LIBS
11135+
fi
11136+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_load_extension" >&5
11137+
$as_echo "$ac_cv_lib_sqlite3_sqlite3_load_extension" >&6; }
11138+
if test "x$ac_cv_lib_sqlite3_sqlite3_load_extension" = xyes; then :
11139+
cat >>confdefs.h <<_ACEOF
11140+
#define HAVE_LIBSQLITE3 1
11141+
_ACEOF
11142+
11143+
LIBS="-lsqlite3 $LIBS"
11144+
11145+
fi
11146+
11147+
11148+
fi
11149+
11150+
11151+
11152+
CFLAGS=$save_CFLAGS
11153+
CPPFLAGS=$save_CPPFLAGS
11154+
LDFLAGS=$save_LDFLAGS
11155+
LIBS=$save_LIBS
11156+
1093311157
# Check for support for loadable sqlite extensions
1093411158
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --enable-loadable-sqlite-extensions" >&5
1093511159
$as_echo_n "checking for --enable-loadable-sqlite-extensions... " >&6; }
1093611160
# Check whether --enable-loadable-sqlite-extensions was given.
1093711161
if test "${enable_loadable_sqlite_extensions+set}" = set; then :
10938-
enableval=$enable_loadable_sqlite_extensions;
11162+
enableval=$enable_loadable_sqlite_extensions; if test "x$have_sqlite3_load_extension" = xno; then :
11163+
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Your version of SQLite does not support loadable extensions" >&5
11164+
$as_echo "$as_me: WARNING: Your version of SQLite does not support loadable extensions" >&2;}
11165+
fi
1093911166
else
1094011167
enable_loadable_sqlite_extensions=no
1094111168
fi
@@ -19431,6 +19658,56 @@ fi
1943119658
$as_echo "$py_cv_module__decimal" >&6; }
1943219659

1943319660

19661+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _sqlite3" >&5
19662+
$as_echo_n "checking for stdlib extension module _sqlite3... " >&6; }
19663+
case $py_stdlib_not_available in #(
19664+
*_sqlite3*) :
19665+
py_cv_module__sqlite3=n/a ;; #(
19666+
*) :
19667+
19668+
if test "$have_sqlite3" = "yes"; then :
19669+
if test "$have_supported_sqlite3" = "yes"; then :
19670+
py_cv_module__sqlite3=yes
19671+
else
19672+
py_cv_module__sqlite3=missing
19673+
fi
19674+
else
19675+
py_cv_module__sqlite3=disabled
19676+
19677+
fi
19678+
19679+
;;
19680+
esac
19681+
as_fn_append MODULE_BLOCK "MODULE__SQLITE3=$py_cv_module__sqlite3$as_nl"
19682+
if test "x$py_cv_module__sqlite3" = xyes; then :
19683+
19684+
as_fn_append MODULE_BLOCK "MODULE__SQLITE3_CFLAGS=$LIBSQLITE3_CFLAGS$as_nl"
19685+
as_fn_append MODULE_BLOCK "MODULE__SQLITE3_LDFLAGS=$LIBSQLITE3_LIBS$as_nl"
19686+
if true; then
19687+
MODULE__SQLITE3_TRUE=
19688+
MODULE__SQLITE3_FALSE='#'
19689+
else
19690+
MODULE__SQLITE3_TRUE='#'
19691+
MODULE__SQLITE3_FALSE=
19692+
fi
19693+
19694+
19695+
else
19696+
19697+
if false; then
19698+
MODULE__SQLITE3_TRUE=
19699+
MODULE__SQLITE3_FALSE='#'
19700+
else
19701+
MODULE__SQLITE3_TRUE='#'
19702+
MODULE__SQLITE3_FALSE=
19703+
fi
19704+
19705+
19706+
fi
19707+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $py_cv_module__sqlite3" >&5
19708+
$as_echo "$py_cv_module__sqlite3" >&6; }
19709+
19710+
1943419711
# substitute multiline block, must come after last PY_STDLIB_MOD()
1943519712

1943619713

@@ -19583,6 +19860,14 @@ if test -z "${MODULE__DECIMAL_TRUE}" && test -z "${MODULE__DECIMAL_FALSE}"; then
1958319860
as_fn_error $? "conditional \"MODULE__DECIMAL\" was never defined.
1958419861
Usually this means the macro was only invoked conditionally." "$LINENO" 5
1958519862
fi
19863+
if test -z "${MODULE__SQLITE3_TRUE}" && test -z "${MODULE__SQLITE3_FALSE}"; then
19864+
as_fn_error $? "conditional \"MODULE__SQLITE3\" was never defined.
19865+
Usually this means the macro was only invoked conditionally." "$LINENO" 5
19866+
fi
19867+
if test -z "${MODULE__SQLITE3_TRUE}" && test -z "${MODULE__SQLITE3_FALSE}"; then
19868+
as_fn_error $? "conditional \"MODULE__SQLITE3\" was never defined.
19869+
Usually this means the macro was only invoked conditionally." "$LINENO" 5
19870+
fi
1958619871

1958719872
: "${CONFIG_STATUS=./config.status}"
1958819873
ac_write_fail=0

0 commit comments

Comments
 (0)