diff --git a/cpython-unix/build-sqlite.sh b/cpython-unix/build-sqlite.sh
index 596ceae9..780e8270 100755
--- a/cpython-unix/build-sqlite.sh
+++ b/cpython-unix/build-sqlite.sh
@@ -28,6 +28,7 @@ fi
unset CXX
CC_FOR_BUILD="${HOST_CC}" \
+# Please try to keep these in sync with cpython-windows/build.py
CFLAGS="${EXTRA_TARGET_CFLAGS} \
-DSQLITE_ENABLE_DBSTAT_VTAB \
-DSQLITE_ENABLE_FTS3 \
diff --git a/cpython-windows/build.py b/cpython-windows/build.py
index 26023247..f8902132 100644
--- a/cpython-windows/build.py
+++ b/cpython-windows/build.py
@@ -568,6 +568,36 @@ def hack_project_files(
rb"%s" % sqlite3_version_parts[3],
)
+ # Please try keep these in sync with cpython-unix/build-sqlite.sh
+ sqlite_build_flags = {
+ b"SQLITE_ENABLE_DBSTAT_VTAB",
+ b"SQLITE_ENABLE_FTS3",
+ b"SQLITE_ENABLE_FTS3_PARENTHESIS",
+ b"SQLITE_ENABLE_FTS4",
+ b"SQLITE_ENABLE_FTS5",
+ b"SQLITE_ENABLE_GEOPOLY",
+ b"SQLITE_ENABLE_RTREE",
+ }
+ with sqlite3_path.open("rb") as fh:
+ data = fh.read()
+ sqlite_preprocessor_regex = (
+ rb"(SQLITE_ENABLE.*)"
+ )
+ m = re.search(sqlite_preprocessor_regex, data)
+ if m is None:
+ raise NoSearchStringError(
+ "search string (%s) not in %s" % (sqlite_preprocessor_regex, sqlite3_path)
+ )
+ current_flags = set(m.group(1).split(b";"))
+ data = (
+ data[: m.start(1)]
+ + b";".join(sqlite_build_flags - current_flags)
+ + b";"
+ + data[m.start(1) :]
+ )
+ with sqlite3_path.open("wb") as fh:
+ fh.write(data)
+
# Our version of the xz sources is newer than what's in cpython-source-deps
# and the xz sources changed the path to config.h. Hack the project file
# accordingly.
diff --git a/src/verify_distribution.py b/src/verify_distribution.py
index 16901883..9968606f 100644
--- a/src/verify_distribution.py
+++ b/src/verify_distribution.py
@@ -123,15 +123,8 @@ def test_sqlite(self):
self.assertTrue(hasattr(conn, "enable_load_extension"))
# Backup feature requires modern SQLite, which we always have.
self.assertTrue(hasattr(conn, "backup"))
- # Ensure that various extensions are present. These will raise if they are not. Note that
- # CPython upstream carries configuration flags for the Windows build, so geopoly is missing
- # on all versions and rtree is missing in 3.9. On non-Windows platforms, we configure
- # SQLite ourselves. We might want to patch the build to enable these on Windows, see #666.
- extensions = ["fts3", "fts4", "fts5"]
- if os.name != "nt":
- extensions.append("geopoly")
- if os.name != "nt" or sys.version_info[0:2] > (3, 9):
- extensions.append("rtree")
+ # Ensure that various extensions are present. These will raise if they are not.
+ extensions = ["fts3", "fts4", "fts5", "geopoly", "rtree"]
cursor = conn.cursor()
for extension in extensions:
with self.subTest(extension=extension):