diff --git a/.github/workflows/wheels.yaml b/.github/workflows/wheels.yaml index 41e4240..fd3b257 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,14 +164,30 @@ 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: | sudo apt update && sudo apt install ninja-build git build-essential -y - cd libmdbx && make V=1 && cd .. + cd libmdbx && make V=1 dist && cd .. 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 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 2c8a8e6..1861606 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 @@ -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( @@ -119,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/libmdbx b/libmdbx index 5315e99..a729d19 160000 --- a/libmdbx +++ b/libmdbx @@ -1 +1 @@ -Subproject commit 5315e9905b525a0a183b76fc787317c51076f944 +Subproject commit a729d19e7d67a375b802d1becf6624220b696c3d 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 cba970c..79b65a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,10 +15,16 @@ packages = [ {include = "mdbx"} ] include = [ - { path = "libmdbx/*", format = "sdist"}, + { 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" }, ] +exclude = [ + { path = "libmdbx/dist/build", format = "sdist"}, +] + [tool.poetry.build] generate-setup-file = false script = "build_mdbx.py"