Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cpython-unix/build-sqlite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
30 changes: 30 additions & 0 deletions cpython-windows/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,36 @@ def hack_project_files(
rb"<SqlitePatchVersion>%s</SqlitePatchVersion>" % 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",
Comment on lines +573 to +579
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds like this list should live somewhere else!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I sort of thought it was in code somewhere already, but it's currently inline in the shell script on the UNIX side. We should maybe do something like extension-modules.yml for our native builds.

}
with sqlite3_path.open("rb") as fh:
data = fh.read()
sqlite_preprocessor_regex = (
rb"<PreprocessorDefinitions>(SQLITE_ENABLE.*)</PreprocessorDefinitions>"
)
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.
Expand Down
11 changes: 2 additions & 9 deletions src/verify_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading