Skip to content

Commit 3811863

Browse files
authored
windows: Sync SQLite build flags from the UNIX build (#800)
Notably this adds * SQLITE_ENABLE_FTS3_PARENTHESIS (syntax change, see #550) * SQLITE_ENABLE_DBSTAT_VTAB (#309) * SQLITE_ENABLE_GEOPOLY (historically present on UNIX, maybe see #694)
1 parent 9793ac5 commit 3811863

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

cpython-unix/build-sqlite.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ fi
2828
unset CXX
2929

3030
CC_FOR_BUILD="${HOST_CC}" \
31+
# Please try to keep these in sync with cpython-windows/build.py
3132
CFLAGS="${EXTRA_TARGET_CFLAGS} \
3233
-DSQLITE_ENABLE_DBSTAT_VTAB \
3334
-DSQLITE_ENABLE_FTS3 \

cpython-windows/build.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,36 @@ def hack_project_files(
568568
rb"<SqlitePatchVersion>%s</SqlitePatchVersion>" % sqlite3_version_parts[3],
569569
)
570570

571+
# Please try keep these in sync with cpython-unix/build-sqlite.sh
572+
sqlite_build_flags = {
573+
b"SQLITE_ENABLE_DBSTAT_VTAB",
574+
b"SQLITE_ENABLE_FTS3",
575+
b"SQLITE_ENABLE_FTS3_PARENTHESIS",
576+
b"SQLITE_ENABLE_FTS4",
577+
b"SQLITE_ENABLE_FTS5",
578+
b"SQLITE_ENABLE_GEOPOLY",
579+
b"SQLITE_ENABLE_RTREE",
580+
}
581+
with sqlite3_path.open("rb") as fh:
582+
data = fh.read()
583+
sqlite_preprocessor_regex = (
584+
rb"<PreprocessorDefinitions>(SQLITE_ENABLE.*)</PreprocessorDefinitions>"
585+
)
586+
m = re.search(sqlite_preprocessor_regex, data)
587+
if m is None:
588+
raise NoSearchStringError(
589+
"search string (%s) not in %s" % (sqlite_preprocessor_regex, sqlite3_path)
590+
)
591+
current_flags = set(m.group(1).split(b";"))
592+
data = (
593+
data[: m.start(1)]
594+
+ b";".join(sqlite_build_flags - current_flags)
595+
+ b";"
596+
+ data[m.start(1) :]
597+
)
598+
with sqlite3_path.open("wb") as fh:
599+
fh.write(data)
600+
571601
# Our version of the xz sources is newer than what's in cpython-source-deps
572602
# and the xz sources changed the path to config.h. Hack the project file
573603
# accordingly.

src/verify_distribution.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,8 @@ def test_sqlite(self):
123123
self.assertTrue(hasattr(conn, "enable_load_extension"))
124124
# Backup feature requires modern SQLite, which we always have.
125125
self.assertTrue(hasattr(conn, "backup"))
126-
# Ensure that various extensions are present. These will raise if they are not. Note that
127-
# CPython upstream carries configuration flags for the Windows build, so geopoly is missing
128-
# on all versions and rtree is missing in 3.9. On non-Windows platforms, we configure
129-
# SQLite ourselves. We might want to patch the build to enable these on Windows, see #666.
130-
extensions = ["fts3", "fts4", "fts5"]
131-
if os.name != "nt":
132-
extensions.append("geopoly")
133-
if os.name != "nt" or sys.version_info[0:2] > (3, 9):
134-
extensions.append("rtree")
126+
# Ensure that various extensions are present. These will raise if they are not.
127+
extensions = ["fts3", "fts4", "fts5", "geopoly", "rtree"]
135128
cursor = conn.cursor()
136129
for extension in extensions:
137130
with self.subTest(extension=extension):

0 commit comments

Comments
 (0)