Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e9594f6

Browse files
authored
bpo-45731: Handle --enable-loadable-sqlite-extensions in configure (GH-29434)
1 parent a4774f4 commit e9594f6

File tree

7 files changed

+30
-13
lines changed

7 files changed

+30
-13
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
``configure --enable-loadable-sqlite-extensions`` is now handled by new ``PY_SQLITE_ENABLE_LOAD_EXTENSION`` macro instead of logic in setup.py.

Modules/_sqlite/clinic/connection.c.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ pysqlite_connection_set_trace_callback(pysqlite_Connection *self, PyTypeObject *
367367
return return_value;
368368
}
369369

370-
#if !defined(SQLITE_OMIT_LOAD_EXTENSION)
370+
#if defined(PY_SQLITE_ENABLE_LOAD_EXTENSION)
371371

372372
PyDoc_STRVAR(pysqlite_connection_enable_load_extension__doc__,
373373
"enable_load_extension($self, enable, /)\n"
@@ -398,9 +398,9 @@ pysqlite_connection_enable_load_extension(pysqlite_Connection *self, PyObject *a
398398
return return_value;
399399
}
400400

401-
#endif /* !defined(SQLITE_OMIT_LOAD_EXTENSION) */
401+
#endif /* defined(PY_SQLITE_ENABLE_LOAD_EXTENSION) */
402402

403-
#if !defined(SQLITE_OMIT_LOAD_EXTENSION)
403+
#if defined(PY_SQLITE_ENABLE_LOAD_EXTENSION)
404404

405405
PyDoc_STRVAR(pysqlite_connection_load_extension__doc__,
406406
"load_extension($self, name, /)\n"
@@ -440,7 +440,7 @@ pysqlite_connection_load_extension(pysqlite_Connection *self, PyObject *arg)
440440
return return_value;
441441
}
442442

443-
#endif /* !defined(SQLITE_OMIT_LOAD_EXTENSION) */
443+
#endif /* defined(PY_SQLITE_ENABLE_LOAD_EXTENSION) */
444444

445445
PyDoc_STRVAR(pysqlite_connection_execute__doc__,
446446
"execute($self, sql, parameters=<unrepresentable>, /)\n"
@@ -834,4 +834,4 @@ getlimit(pysqlite_Connection *self, PyObject *arg)
834834
#ifndef PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF
835835
#define PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF
836836
#endif /* !defined(PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF) */
837-
/*[clinic end generated code: output=0c3901153a3837a5 input=a9049054013a1b77]*/
837+
/*[clinic end generated code: output=d71bf16bef67878f input=a9049054013a1b77]*/

Modules/_sqlite/connection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,7 @@ pysqlite_connection_set_trace_callback_impl(pysqlite_Connection *self,
12251225
Py_RETURN_NONE;
12261226
}
12271227

1228-
#ifndef SQLITE_OMIT_LOAD_EXTENSION
1228+
#ifdef PY_SQLITE_ENABLE_LOAD_EXTENSION
12291229
/*[clinic input]
12301230
_sqlite3.Connection.enable_load_extension as pysqlite_connection_enable_load_extension
12311231

configure

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10913,13 +10913,20 @@ $as_echo_n "checking for --enable-loadable-sqlite-extensions... " >&6; }
1091310913
if test "${enable_loadable_sqlite_extensions+set}" = set; then :
1091410914
enableval=$enable_loadable_sqlite_extensions;
1091510915
else
10916-
enable_loadable_sqlite_extensions="no"
10916+
enable_loadable_sqlite_extensions=no
1091710917
fi
1091810918

10919-
1092010919
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_loadable_sqlite_extensions" >&5
1092110920
$as_echo "$enable_loadable_sqlite_extensions" >&6; }
1092210921

10922+
if test "x$enable_loadable_sqlite_extensions" = xyes; then :
10923+
10924+
10925+
$as_echo "#define PY_SQLITE_ENABLE_LOAD_EXTENSION 1" >>confdefs.h
10926+
10927+
10928+
fi
10929+
1092310930
# Check for --with-tcltk-includes=path and --with-tcltk-libs=path
1092410931

1092510932

configure.ac

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3199,10 +3199,14 @@ AC_ARG_ENABLE(loadable-sqlite-extensions,
31993199
AS_HELP_STRING([--enable-loadable-sqlite-extensions],
32003200
[support loadable extensions in _sqlite module, see Doc/library/sqlite3.rst (default is no)]),
32013201
[],
3202-
[enable_loadable_sqlite_extensions="no"])
3203-
3202+
[enable_loadable_sqlite_extensions=no])
32043203
AC_MSG_RESULT($enable_loadable_sqlite_extensions)
32053204

3205+
AS_VAR_IF([enable_loadable_sqlite_extensions], [yes], [
3206+
AC_DEFINE(PY_SQLITE_ENABLE_LOAD_EXTENSION, 1,
3207+
[Define to 1 to build the sqlite module with loadable extensions support.])
3208+
])
3209+
32063210
# Check for --with-tcltk-includes=path and --with-tcltk-libs=path
32073211
AC_SUBST(TCLTK_INCLUDES)
32083212
AC_SUBST(TCLTK_LIBS)

pyconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,6 +1395,9 @@
13951395
/* Define to printf format modifier for Py_ssize_t */
13961396
#undef PY_FORMAT_SIZE_T
13971397

1398+
/* Define to 1 to build the sqlite module with loadable extensions support. */
1399+
#undef PY_SQLITE_ENABLE_LOAD_EXTENSION
1400+
13981401
/* Default cipher suites list for ssl module. 1: Python's preferred selection,
13991402
2: leave OpenSSL defaults untouched, 0: custom string */
14001403
#undef PY_SSL_DEFAULT_CIPHERS

setup.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,9 +1602,11 @@ def detect_sqlite(self):
16021602

16031603
# Enable support for loadable extensions in the sqlite3 module
16041604
# if --enable-loadable-sqlite-extensions configure option is used.
1605-
if '--enable-loadable-sqlite-extensions' not in sysconfig.get_config_var("CONFIG_ARGS"):
1606-
sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1"))
1607-
elif MACOS and sqlite_incdir == os.path.join(MACOS_SDK_ROOT, "usr/include"):
1605+
if (
1606+
MACOS and
1607+
sqlite_incdir == os.path.join(MACOS_SDK_ROOT, "usr/include") and
1608+
sysconfig.get_config_var("PY_SQLITE_ENABLE_LOAD_EXTENSION")
1609+
):
16081610
raise DistutilsError("System version of SQLite does not support loadable extensions")
16091611

16101612
if MACOS:

0 commit comments

Comments
 (0)