From e954945550cce8a1a2fcfa926806c88277e29565 Mon Sep 17 00:00:00 2001 From: Stefan de Konink Date: Sat, 25 Jul 2026 22:08:19 +0200 Subject: [PATCH 1/5] Move the libmdbx repository to lts/0.13 solving the Win32 issues. --- .github/workflows/wheels.yaml | 2 +- .gitmodules | 2 +- build_mdbx.py | 2 +- libmdbx | 2 +- pyproject.toml | 6 +++++- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/wheels.yaml b/.github/workflows/wheels.yaml index 08016cd..e65312c 100644 --- a/.github/workflows/wheels.yaml +++ b/.github/workflows/wheels.yaml @@ -162,7 +162,7 @@ jobs: - name: Build SDist run: | sudo apt update && sudo apt install ninja-build git build-essential -y - cd libmdbx && git fetch --tags && make V=1 && cd .. + cd libmdbx && git fetch --tags && make V=1 dist && cd .. python3 -m pip install -U pip build python3 -m build --sdist diff --git a/.gitmodules b/.gitmodules index c70f584..6f54bc3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "libmdbx"] path = libmdbx - url = https://gitflic.ru/project/erthink/libmdbx.git + url = https://github.com/Mithril-mine/libmdbx-devel.git diff --git a/build_mdbx.py b/build_mdbx.py index 5aae3b6..d4b4cac 100644 --- a/build_mdbx.py +++ b/build_mdbx.py @@ -39,7 +39,7 @@ def build(setup_kws: dict): # If there is already dist if not dist_folder.exists(): if sys.platform in ["linux", "linux2"]: - subprocess.check_call(["make"], cwd=libmdbx_source) + subprocess.check_call(["make", "dist"], cwd=libmdbx_source) if have_git() and (libmdbx_source / ".git").exists(): source_folder = libmdbx_source diff --git a/libmdbx b/libmdbx index 5315e99..a729d19 160000 --- a/libmdbx +++ b/libmdbx @@ -1 +1 @@ -Subproject commit 5315e9905b525a0a183b76fc787317c51076f944 +Subproject commit a729d19e7d67a375b802d1becf6624220b696c3d diff --git a/pyproject.toml b/pyproject.toml index cba970c..f59c714 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,10 +15,14 @@ packages = [ {include = "mdbx"} ] include = [ - { path = "libmdbx/*", format = "sdist"}, + { path = "libmdbx/dist/*", format = "sdist"}, { path = "mdbx/lib/*", format = "wheel" }, ] +exclude = [ + { path = "libmdbx/dist/build", format = "sdist"}, +] + [tool.poetry.build] generate-setup-file = false script = "build_mdbx.py" From 937a3706a4c81cb50e47008b1d75f3fe1327fbbb Mon Sep 17 00:00:00 2001 From: lazymio Date: Sun, 26 Jul 2026 11:13:56 +0000 Subject: [PATCH 2/5] CI(full): Fetch tags so the libmdbx devel tree can describe itself Every job on this branch fails, all with the same cause: version.c:7:2: error: "API version mismatch! Had `git fetch --tags` done?" and on Linux, where `make dist` runs first: fatal: No tags can describe 'a729d19e7d67a375b802d1becf6624220b696c3d'. mdbx.c:37661:28: error: operator '!=' has no right operand libmdbx-devel is the non-amalgamated tree and carries no VERSION.json, so GNUmakefile derives MDBX_GIT_* from `git describe --tags` and substitutes them into src/version.c.in. actions/checkout clones submodules with --depth=1, which brings no tags, so those expansions come out empty and `#if MDBX_VERSION_MAJOR != ` fails to parse. Setting fetch-depth: 0 drops the --depth from the submodule clone, so the tags come along. Doing it at checkout rather than re-adding a `git fetch` to CIBW_BEFORE_BUILD keeps the build itself offline. The full clone is only 14 MiB. Verified locally: with tags, `make dist` ends in "VERIFY amalgamated sources... Ok" and emits VERSION.json with semver 0.13.12.15. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/wheels.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/wheels.yaml b/.github/workflows/wheels.yaml index 0163a7f..2451404 100644 --- a/.github/workflows/wheels.yaml +++ b/.github/workflows/wheels.yaml @@ -33,6 +33,9 @@ jobs: uses: actions/checkout@v4 with: submodules: "recursive" + # libmdbx derives its version from `git describe`, and a shallow + # submodule clone carries no tags. + fetch-depth: 0 - name: '🛠️ Win MSVC 64 setup' if: contains(matrix.config.os, 'windows') @@ -106,6 +109,9 @@ jobs: uses: actions/checkout@v4 with: submodules: "recursive" + # libmdbx derives its version from `git describe`, and a shallow + # submodule clone carries no tags. + fetch-depth: 0 - name: '🛠️ Setup Dependency' if: contains(matrix.config.os, 'ubuntu') @@ -158,6 +164,9 @@ jobs: - uses: actions/checkout@v4 with: submodules: "recursive" + # libmdbx derives its version from `git describe`, and a shallow + # submodule clone carries no tags. + fetch-depth: 0 - name: Build SDist run: | From b27cb598e60f5970813bc9ca19f937908b2da4c5 Mon Sep 17 00:00:00 2001 From: lazymio Date: Sun, 26 Jul 2026 11:21:19 +0000 Subject: [PATCH 3/5] CI(full): Do not build libmdbx's own test suite With the devel tree, msbuild builds every target in libmdbx.sln, which now includes libmdbx's test suite. That does not compile with MSVC: test\extra\rename_dbi.c(28,1): error C1083: Cannot open include file: 'unistd.h': No such file or directory The amalgamated tarball never carried test/, which is why this only shows up after moving to libmdbx-devel. We only ever consume the library, so turn the tests off: -DMDBX_ENABLE_TESTS=OFF drops all 18 test targets while keeping mdbx and mdbx-static, and it is accepted (and irrelevant) on the amalgamated tree too, so the sdist build path is unaffected. Co-Authored-By: Claude Opus 5 (1M context) --- build_mdbx.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build_mdbx.py b/build_mdbx.py index 1b3f851..576b8c1 100644 --- a/build_mdbx.py +++ b/build_mdbx.py @@ -80,7 +80,11 @@ def build(setup_kws: dict): ] cmake_gen += [ - "-S", str(source_folder.absolute()), "-B", str(tmpdir_path.absolute()) + "-S", str(source_folder.absolute()), "-B", str(tmpdir_path.absolute()), + # The non-amalgamated tree builds libmdbx's own test suite by default, + # which does not compile with MSVC: test/extra/rename_dbi.c wants + # unistd.h. We only ever consume the library itself. + "-DMDBX_ENABLE_TESTS=OFF" ] cmake_gen += build_type subprocess.check_call( From c40c545c282f687f9349df18571f7b1498e57ab1 Mon Sep 17 00:00:00 2001 From: lazymio Date: Sun, 26 Jul 2026 11:21:39 +0000 Subject: [PATCH 4/5] CI(full): Ship platform_enums.c in the sdist and find mdbx.h next to it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Installing the sdist has been broken since #16 added platform_enums.c: the file is at the project root, which poetry does not pick up, so the build died right after libmdbx compiled with cc1: fatal error: platform_enums.c: No such file or directory Adding it to include[] is not enough on its own, because it does `#include "libmdbx/mdbx.h"`. That path only exists in a git checkout; the sdist ships the amalgamated tree, where the header is at libmdbx/dist/mdbx.h: platform_enums.c:1:10: fatal error: libmdbx/mdbx.h: No such file or directory So include "mdbx.h" and point the compiler at whichever tree build_mdbx.py picked — libmdbx/ for a checkout, libmdbx/dist/ for an sdist. Not a regression from the lts move; the published 0.3.1 sdist has the same root file list, it just predates platform_enums.c and so still built. CI never notices because make_sdist only builds the tarball, it never installs from it. Verified end to end: from a clean venv, `pip install libmdbx-0.3.1.tar.gz` now succeeds and the repo test suite passes 23/23 against the installed package. The checkout build path still works too. Co-Authored-By: Claude Opus 5 (1M context) --- build_mdbx.py | 5 ++++- platform_enums.c | 2 +- pyproject.toml | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/build_mdbx.py b/build_mdbx.py index 576b8c1..1861606 100644 --- a/build_mdbx.py +++ b/build_mdbx.py @@ -123,12 +123,15 @@ def build(setup_kws: dict): # Compile with MSVC subprocess.check_call([ "cl", str(platform_enums), + f"/I{source_folder.absolute()}", f"/Fe{enum_exe}" ], cwd=tmpdir_path) else: # Compile with GCC/Clang subprocess.check_call([ - "gcc", str(platform_enums), "-o", str(enum_exe) + "gcc", str(platform_enums), + f"-I{source_folder.absolute()}", + "-o", str(enum_exe) ], cwd=tmpdir_path) output = subprocess.check_output([str(enum_exe)], text=True) diff --git a/platform_enums.c b/platform_enums.c index 446f284..af78e61 100644 --- a/platform_enums.c +++ b/platform_enums.c @@ -1,4 +1,4 @@ -#include "libmdbx/mdbx.h" +#include "mdbx.h" #include int main(void) { diff --git a/pyproject.toml b/pyproject.toml index f59c714..79b65a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,8 @@ packages = [ ] include = [ { path = "libmdbx/dist/*", format = "sdist"}, + # build_mdbx.py compiles this to generate the platform error codes + { path = "platform_enums.c", format = "sdist"}, { path = "mdbx/lib/*", format = "wheel" }, ] From 243d246eae7a9f482dc9372f76a357333e6244f3 Mon Sep 17 00:00:00 2001 From: lazymio Date: Sun, 26 Jul 2026 11:32:45 +0000 Subject: [PATCH 5/5] CI(full): Check that the sdist actually installs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit make_sdist only built the tarball and uploaded it straight to the publish job, so nothing ever exercised the sdist install path — every wheel job builds from the git checkout instead. That is how the missing platform_enums.c stayed invisible from #16 until now. Install the freshly built tarball into a clean venv and run the test suite against it. The tests run from /tmp rather than the workspace, because ./mdbx would otherwise shadow the installed package and we would just be testing the checkout a second time. Confirmed to be a real guard, not a no-op: against a tarball without the preceding fix this step fails at "cc1: fatal error: platform_enums.c: No such file or directory", and against the fixed one it installs and passes 23/23. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/wheels.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/wheels.yaml b/.github/workflows/wheels.yaml index 2451404..fd3b257 100644 --- a/.github/workflows/wheels.yaml +++ b/.github/workflows/wheels.yaml @@ -175,6 +175,19 @@ jobs: python3 -m pip install -U pip build python3 -m build --sdist + # Building the tarball says nothing about whether it installs: the wheel + # jobs all build from the git checkout, so anything the sdist fails to + # ship goes unnoticed until someone pip installs it. + - name: Check SDist installs + run: | + python3 -m venv /tmp/sdist-venv + /tmp/sdist-venv/bin/python -m pip install -U pip pytest + /tmp/sdist-venv/bin/python -m pip install dist/*.tar.gz + # Run outside the source tree, otherwise ./mdbx shadows the installed + # package and we would just be testing the checkout again. + mkdir -p /tmp/sdist-check && cp -r tests /tmp/sdist-check/ + cd /tmp/sdist-check && /tmp/sdist-venv/bin/python -m pytest tests -q + - uses: actions/upload-artifact@v4 with: name: sdist-archive