]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45731: Handle --enable-loadable-sqlite-extensions in configure (GH-29434)
authorChristian Heimes <christian@python.org>
Sat, 6 Nov 2021 09:30:37 +0000 (11:30 +0200)
committerGitHub <noreply@github.com>
Sat, 6 Nov 2021 09:30:37 +0000 (10:30 +0100)
Misc/NEWS.d/next/Build/2021-11-05-20-56-29.bpo-45731.9SDnDf.rst [new file with mode: 0644]
Modules/_sqlite/clinic/connection.c.h
Modules/_sqlite/connection.c
configure
configure.ac
pyconfig.h.in
setup.py

diff --git a/Misc/NEWS.d/next/Build/2021-11-05-20-56-29.bpo-45731.9SDnDf.rst b/Misc/NEWS.d/next/Build/2021-11-05-20-56-29.bpo-45731.9SDnDf.rst
new file mode 100644 (file)
index 0000000..1e490fa
--- /dev/null
@@ -0,0 +1 @@
+``configure --enable-loadable-sqlite-extensions`` is now handled by new ``PY_SQLITE_ENABLE_LOAD_EXTENSION`` macro instead of logic in setup.py.
index f9323eb21d6f454a43d45ca105729d565deb152c..4e5ee500ad18e6d149e7f1e774f75636fea152c2 100644 (file)
@@ -367,7 +367,7 @@ exit:
     return return_value;
 }
 
-#if !defined(SQLITE_OMIT_LOAD_EXTENSION)
+#if defined(PY_SQLITE_ENABLE_LOAD_EXTENSION)
 
 PyDoc_STRVAR(pysqlite_connection_enable_load_extension__doc__,
 "enable_load_extension($self, enable, /)\n"
@@ -398,9 +398,9 @@ exit:
     return return_value;
 }
 
-#endif /* !defined(SQLITE_OMIT_LOAD_EXTENSION) */
+#endif /* defined(PY_SQLITE_ENABLE_LOAD_EXTENSION) */
 
-#if !defined(SQLITE_OMIT_LOAD_EXTENSION)
+#if defined(PY_SQLITE_ENABLE_LOAD_EXTENSION)
 
 PyDoc_STRVAR(pysqlite_connection_load_extension__doc__,
 "load_extension($self, name, /)\n"
@@ -440,7 +440,7 @@ exit:
     return return_value;
 }
 
-#endif /* !defined(SQLITE_OMIT_LOAD_EXTENSION) */
+#endif /* defined(PY_SQLITE_ENABLE_LOAD_EXTENSION) */
 
 PyDoc_STRVAR(pysqlite_connection_execute__doc__,
 "execute($self, sql, parameters=<unrepresentable>, /)\n"
@@ -834,4 +834,4 @@ exit:
 #ifndef PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF
     #define PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF
 #endif /* !defined(PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF) */
-/*[clinic end generated code: output=0c3901153a3837a5 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=d71bf16bef67878f input=a9049054013a1b77]*/
index f913267e1560e8020c1c7acf68fb9a4c9fd370c1..964673a6125f34df4e5eb642b5bb18b98c44e51e 100644 (file)
@@ -1225,7 +1225,7 @@ pysqlite_connection_set_trace_callback_impl(pysqlite_Connection *self,
     Py_RETURN_NONE;
 }
 
-#ifndef SQLITE_OMIT_LOAD_EXTENSION
+#ifdef PY_SQLITE_ENABLE_LOAD_EXTENSION
 /*[clinic input]
 _sqlite3.Connection.enable_load_extension as pysqlite_connection_enable_load_extension
 
index 00bea712b06332dee20207f9e23823c5fb3ff95f..1eea2d13205789dc020a54f47bd5041cd60c848a 100755 (executable)
--- a/configure
+++ b/configure
@@ -10913,13 +10913,20 @@ $as_echo_n "checking for --enable-loadable-sqlite-extensions... " >&6; }
 if test "${enable_loadable_sqlite_extensions+set}" = set; then :
   enableval=$enable_loadable_sqlite_extensions;
 else
-  enable_loadable_sqlite_extensions="no"
+  enable_loadable_sqlite_extensions=no
 fi
 
-
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_loadable_sqlite_extensions" >&5
 $as_echo "$enable_loadable_sqlite_extensions" >&6; }
 
+if test "x$enable_loadable_sqlite_extensions" = xyes; then :
+
+
+$as_echo "#define PY_SQLITE_ENABLE_LOAD_EXTENSION 1" >>confdefs.h
+
+
+fi
+
 # Check for --with-tcltk-includes=path and --with-tcltk-libs=path
 
 
index ea119085ab15755ba640bb5c0094cd8db8c1c2b2..8895818d19da6c6a221331d1678cafd28c1950d2 100644 (file)
@@ -3199,10 +3199,14 @@ 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)]),
               [],
-              [enable_loadable_sqlite_extensions="no"])
-
+              [enable_loadable_sqlite_extensions=no])
 AC_MSG_RESULT($enable_loadable_sqlite_extensions)
 
+AS_VAR_IF([enable_loadable_sqlite_extensions], [yes], [
+  AC_DEFINE(PY_SQLITE_ENABLE_LOAD_EXTENSION, 1,
+  [Define to 1 to build the sqlite module with loadable extensions support.])
+])
+
 # Check for --with-tcltk-includes=path and --with-tcltk-libs=path
 AC_SUBST(TCLTK_INCLUDES)
 AC_SUBST(TCLTK_LIBS)
index b89377dc1b44d8e36ce26ced54fe6d7ef3cc50a3..0c149e24bca5f1efae4d04cce88831437e58407a 100644 (file)
 /* Define to printf format modifier for Py_ssize_t */
 #undef PY_FORMAT_SIZE_T
 
+/* Define to 1 to build the sqlite module with loadable extensions support. */
+#undef PY_SQLITE_ENABLE_LOAD_EXTENSION
+
 /* Default cipher suites list for ssl module. 1: Python's preferred selection,
    2: leave OpenSSL defaults untouched, 0: custom string */
 #undef PY_SSL_DEFAULT_CIPHERS
index 22c5ccf0a073a958672f0a4b78598075ba50f1e3..b6bf8e129373b45eb6214847ca9679bc9662ff71 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1602,9 +1602,11 @@ class PyBuildExt(build_ext):
 
             # Enable support for loadable extensions in the sqlite3 module
             # if --enable-loadable-sqlite-extensions configure option is used.
-            if '--enable-loadable-sqlite-extensions' not in sysconfig.get_config_var("CONFIG_ARGS"):
-                sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1"))
-            elif MACOS and sqlite_incdir == os.path.join(MACOS_SDK_ROOT, "usr/include"):
+            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")
 
             if MACOS: