From 9b05e68d5544f92226cfb128a3c08fed41e51972 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Fri, 5 Nov 2021 20:58:29 +0100 Subject: [PATCH 1/2] bpo-45731: Handle --enable-loadable-sqlite-extensions in configure Signed-off-by: Christian Heimes --- .../Build/2021-11-05-20-56-29.bpo-45731.9SDnDf.rst | 1 + Modules/_sqlite/clinic/connection.c.h | 10 +++++----- Modules/_sqlite/connection.c | 2 +- configure | 11 +++++++++-- configure.ac | 8 ++++++-- pyconfig.h.in | 3 +++ setup.py | 8 +++++--- 7 files changed, 30 insertions(+), 13 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2021-11-05-20-56-29.bpo-45731.9SDnDf.rst 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 index 00000000000000..91361d8561fdb7 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2021-11-05-20-56-29.bpo-45731.9SDnDf.rst @@ -0,0 +1 @@ +``configure --enable-loadable-sqlite-extensions`` is now handled by new ``PY_SQLITE_ENABLE_LOADABLE_EXTENSION`` instead of logic in setup.py. diff --git a/Modules/_sqlite/clinic/connection.c.h b/Modules/_sqlite/clinic/connection.c.h index f9323eb21d6f45..d0c4d24af3de69 100644 --- a/Modules/_sqlite/clinic/connection.c.h +++ b/Modules/_sqlite/clinic/connection.c.h @@ -367,7 +367,7 @@ pysqlite_connection_set_trace_callback(pysqlite_Connection *self, PyTypeObject * return return_value; } -#if !defined(SQLITE_OMIT_LOAD_EXTENSION) +#if defined(PY_SQLITE_ENABLE_LOADABLE_EXTENSION) PyDoc_STRVAR(pysqlite_connection_enable_load_extension__doc__, "enable_load_extension($self, enable, /)\n" @@ -398,9 +398,9 @@ pysqlite_connection_enable_load_extension(pysqlite_Connection *self, PyObject *a return return_value; } -#endif /* !defined(SQLITE_OMIT_LOAD_EXTENSION) */ +#endif /* defined(PY_SQLITE_ENABLE_LOADABLE_EXTENSION) */ -#if !defined(SQLITE_OMIT_LOAD_EXTENSION) +#if defined(PY_SQLITE_ENABLE_LOADABLE_EXTENSION) PyDoc_STRVAR(pysqlite_connection_load_extension__doc__, "load_extension($self, name, /)\n" @@ -440,7 +440,7 @@ pysqlite_connection_load_extension(pysqlite_Connection *self, PyObject *arg) return return_value; } -#endif /* !defined(SQLITE_OMIT_LOAD_EXTENSION) */ +#endif /* defined(PY_SQLITE_ENABLE_LOADABLE_EXTENSION) */ PyDoc_STRVAR(pysqlite_connection_execute__doc__, "execute($self, sql, parameters=, /)\n" @@ -834,4 +834,4 @@ getlimit(pysqlite_Connection *self, PyObject *arg) #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=38de40d9c6fa2220 input=a9049054013a1b77]*/ diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index f913267e1560e8..9eeca23d50268f 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -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_LOADABLE_EXTENSION /*[clinic input] _sqlite3.Connection.enable_load_extension as pysqlite_connection_enable_load_extension diff --git a/configure b/configure index 00bea712b06332..89edac4f4084ad 100755 --- 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_LOADABLE_EXTENSION 1" >>confdefs.h + + +fi + # Check for --with-tcltk-includes=path and --with-tcltk-libs=path diff --git a/configure.ac b/configure.ac index ea119085ab1575..cc1448e2e05e67 100644 --- a/configure.ac +++ b/configure.ac @@ -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_LOADABLE_EXTENSION, 1, + [Define to 1 to build sqlite module with loadable extensions.]) +]) + # Check for --with-tcltk-includes=path and --with-tcltk-libs=path AC_SUBST(TCLTK_INCLUDES) AC_SUBST(TCLTK_LIBS) diff --git a/pyconfig.h.in b/pyconfig.h.in index b89377dc1b44d8..1749e89ef9265a 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -1395,6 +1395,9 @@ /* Define to printf format modifier for Py_ssize_t */ #undef PY_FORMAT_SIZE_T +/* Define to 1 to build sqlite module with loadable extensions. */ +#undef PY_SQLITE_ENABLE_LOADABLE_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 diff --git a/setup.py b/setup.py index 22c5ccf0a073a9..7fa810e7371036 100644 --- a/setup.py +++ b/setup.py @@ -1602,9 +1602,11 @@ def detect_sqlite(self): # 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_LOADABLE_EXTENSION") + ): raise DistutilsError("System version of SQLite does not support loadable extensions") if MACOS: From 8555e2e319bf1564bf5d85a16ff50634948e8f93 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Fri, 5 Nov 2021 21:57:39 +0100 Subject: [PATCH 2/2] Rename macro to PY_SQLITE_ENABLE_LOAD_EXTENSION --- .../Build/2021-11-05-20-56-29.bpo-45731.9SDnDf.rst | 2 +- Modules/_sqlite/clinic/connection.c.h | 10 +++++----- Modules/_sqlite/connection.c | 2 +- configure | 2 +- configure.ac | 4 ++-- pyconfig.h.in | 4 ++-- setup.py | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) 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 index 91361d8561fdb7..1e490fac6ee5d0 100644 --- 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 @@ -1 +1 @@ -``configure --enable-loadable-sqlite-extensions`` is now handled by new ``PY_SQLITE_ENABLE_LOADABLE_EXTENSION`` instead of logic in setup.py. +``configure --enable-loadable-sqlite-extensions`` is now handled by new ``PY_SQLITE_ENABLE_LOAD_EXTENSION`` macro instead of logic in setup.py. diff --git a/Modules/_sqlite/clinic/connection.c.h b/Modules/_sqlite/clinic/connection.c.h index d0c4d24af3de69..4e5ee500ad18e6 100644 --- a/Modules/_sqlite/clinic/connection.c.h +++ b/Modules/_sqlite/clinic/connection.c.h @@ -367,7 +367,7 @@ pysqlite_connection_set_trace_callback(pysqlite_Connection *self, PyTypeObject * return return_value; } -#if defined(PY_SQLITE_ENABLE_LOADABLE_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 @@ pysqlite_connection_enable_load_extension(pysqlite_Connection *self, PyObject *a return return_value; } -#endif /* defined(PY_SQLITE_ENABLE_LOADABLE_EXTENSION) */ +#endif /* defined(PY_SQLITE_ENABLE_LOAD_EXTENSION) */ -#if defined(PY_SQLITE_ENABLE_LOADABLE_EXTENSION) +#if defined(PY_SQLITE_ENABLE_LOAD_EXTENSION) PyDoc_STRVAR(pysqlite_connection_load_extension__doc__, "load_extension($self, name, /)\n" @@ -440,7 +440,7 @@ pysqlite_connection_load_extension(pysqlite_Connection *self, PyObject *arg) return return_value; } -#endif /* defined(PY_SQLITE_ENABLE_LOADABLE_EXTENSION) */ +#endif /* defined(PY_SQLITE_ENABLE_LOAD_EXTENSION) */ PyDoc_STRVAR(pysqlite_connection_execute__doc__, "execute($self, sql, parameters=, /)\n" @@ -834,4 +834,4 @@ getlimit(pysqlite_Connection *self, PyObject *arg) #ifndef PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF #define PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF #endif /* !defined(PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF) */ -/*[clinic end generated code: output=38de40d9c6fa2220 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=d71bf16bef67878f input=a9049054013a1b77]*/ diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 9eeca23d50268f..964673a6125f34 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -1225,7 +1225,7 @@ pysqlite_connection_set_trace_callback_impl(pysqlite_Connection *self, Py_RETURN_NONE; } -#ifdef PY_SQLITE_ENABLE_LOADABLE_EXTENSION +#ifdef PY_SQLITE_ENABLE_LOAD_EXTENSION /*[clinic input] _sqlite3.Connection.enable_load_extension as pysqlite_connection_enable_load_extension diff --git a/configure b/configure index 89edac4f4084ad..1eea2d13205789 100755 --- a/configure +++ b/configure @@ -10922,7 +10922,7 @@ $as_echo "$enable_loadable_sqlite_extensions" >&6; } if test "x$enable_loadable_sqlite_extensions" = xyes; then : -$as_echo "#define PY_SQLITE_ENABLE_LOADABLE_EXTENSION 1" >>confdefs.h +$as_echo "#define PY_SQLITE_ENABLE_LOAD_EXTENSION 1" >>confdefs.h fi diff --git a/configure.ac b/configure.ac index cc1448e2e05e67..8895818d19da6c 100644 --- a/configure.ac +++ b/configure.ac @@ -3203,8 +3203,8 @@ AC_ARG_ENABLE(loadable-sqlite-extensions, AC_MSG_RESULT($enable_loadable_sqlite_extensions) AS_VAR_IF([enable_loadable_sqlite_extensions], [yes], [ - AC_DEFINE(PY_SQLITE_ENABLE_LOADABLE_EXTENSION, 1, - [Define to 1 to build sqlite module with loadable extensions.]) + 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 diff --git a/pyconfig.h.in b/pyconfig.h.in index 1749e89ef9265a..0c149e24bca5f1 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -1395,8 +1395,8 @@ /* Define to printf format modifier for Py_ssize_t */ #undef PY_FORMAT_SIZE_T -/* Define to 1 to build sqlite module with loadable extensions. */ -#undef PY_SQLITE_ENABLE_LOADABLE_EXTENSION +/* 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 */ diff --git a/setup.py b/setup.py index 7fa810e7371036..b6bf8e129373b4 100644 --- a/setup.py +++ b/setup.py @@ -1605,7 +1605,7 @@ def detect_sqlite(self): if ( MACOS and sqlite_incdir == os.path.join(MACOS_SDK_ROOT, "usr/include") and - sysconfig.get_config_var("PY_SQLITE_ENABLE_LOADABLE_EXTENSION") + sysconfig.get_config_var("PY_SQLITE_ENABLE_LOAD_EXTENSION") ): raise DistutilsError("System version of SQLite does not support loadable extensions")