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
24 changes: 23 additions & 1 deletion .github/workflows/wheels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -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
13 changes: 10 additions & 3 deletions build_mdbx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion libmdbx
2 changes: 1 addition & 1 deletion platform_enums.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "libmdbx/mdbx.h"
#include "mdbx.h"
#include <stdio.h>

int main(void) {
Expand Down
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading