Skip to content
This repository was archived by the owner on Nov 21, 2026. It is now read-only.
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
11 changes: 11 additions & 0 deletions .github/workflows/release-python-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ jobs:
exit 1
fi

# Size policy: every wheel stays under 100 MB (decimal), also where the PyPI project's own limit is higher.
# An embedded database does not ship huge wheels; a larger one means a mistake. build.sh checks the same limit.
for WHEEL in dist/*.whl; do
SIZE=$(stat -c %s "$WHEEL")
if [ "$SIZE" -ge 100000000 ]; then
echo "❌ $WHEEL is $SIZE bytes, at or over the 100 MB size policy"
exit 1
fi
done
echo "✅ Every wheel is under 100 MB"

# Show checksums to verify wheels are different
echo ""
echo "🔐 Wheel checksums (SHA256):"
Expand Down
7 changes: 7 additions & 0 deletions bindings/python/docs/development/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ next sync.
(`sync-upstream.sh` does). If their tag is ever fetched, `git tag -a X.Y.Z` fails
with "already exists", but `git push origin X.Y.Z` still succeeds and publishes
upstream's commit. Check what a tag points to before pushing it (step 4 below).
`git config remote.upstream.tagopt --no-tags` makes `git fetch upstream` skip tags for good.

## Release Checklist (stable `X.Y.Z`)

Expand Down Expand Up @@ -58,6 +59,9 @@ uv run pytest
```

- [ ] Full test suite passes
- [ ] Every wheel is under 100 MB (`build.sh` fails a wheel at or over it, and the release workflow
checks it again before the upload; the policy holds even where the PyPI project's own limit is
higher, because an embedded database should not ship a huge wheel)
- [ ] Release notes prepared in `notes.md` (see [What the release body contains](#what-the-release-body-contains))
- [ ] Documentation updated if needed

Expand All @@ -76,6 +80,9 @@ Tags are the source of truth. Pushing `X.Y.Z`, `X.Y.Z.devN`, or `X.Y.Z.postN` tr
PyPI + docs.

```bash
# No tag of this name may exist yet, here or on origin (upstream's tags share our names)
test -z "$(git tag -l X.Y.Z)" && test -z "$(git ls-remote --tags origin X.Y.Z)" && echo "no tag yet"

git tag -a X.Y.Z -F notes.md

# The tag must point at the commit you just tested
Expand Down
10 changes: 10 additions & 0 deletions bindings/python/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,16 @@ for old in dist/*.whl; do
fi
done

# THE WHEEL SIZE POLICY: a wheel at or over 100 MB means a mistake (a whole distribution in JAR_LIB_DIR, an optional jar,
# a stale artifact), and an embedded database should not ship a huge wheel anyway. Fail it here, before anything tests
# or publishes it. The release workflow checks the same limit again before the upload.
SIZE_PY=$(command -v python3 || command -v python || true)
if [[ -z "$SIZE_PY" ]]; then
echo -e "${YELLOW}⚠️ No python found: the wheel size check was skipped${NC}"
else
"$SIZE_PY" "$SCRIPT_DIR/verify_wheel_size.py" "$NEWEST_WHEEL" || exit 1
fi

echo -e "${GREEN}🎉 Build completed successfully!${NC}"
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
Expand Down
89 changes: 89 additions & 0 deletions bindings/python/scripts/verify_wheel_size.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env python3
"""Fail a wheel that is too large for an embedded database, warn when one looks wrong.

The wheels of this project stay under 100 MB each (PyPI's default limit, and the project's own policy even where the
project's limit is higher: an embedded multi-model database should not ship huge wheels). A wheel at or over the limit
means a mistake: a whole distribution copied into JAR_LIB_DIR, an optional jar bundled by accident, a stale artifact
inside the build. The wheels of 26.9.1 are 66 to 71 MB. A wheel far below that probably lacks the engine or the JRE,
which is only a warning here because deliberately minimal wheels are built for A/B tests.

Usage:
python verify_wheel_size.py WHEEL [WHEEL ...] [--max-mb 100] [--warn-mb 90] [--min-mb 30]

The limits are decimal megabytes (1 MB = 1,000,000 bytes). ARCADEDB_WHEEL_MAX_MB overrides --max-mb for an
exceptional build (state why in the build log; the release workflow has no override).

Exit status: 0 all wheels under the limit (warnings may print), 1 a wheel is at or over the limit, 2 usage error or a
wheel that is missing or not a zip file.
"""

from __future__ import annotations

import argparse
import os
import sys
import zipfile
from pathlib import Path

MB = 1_000_000
DEFAULT_MAX_MB = 100.0 # the policy: a wheel at or over this fails
DEFAULT_WARN_MB = 90.0
DEFAULT_MIN_MB = 30.0


def _largest_members(wheel: Path, count: int = 6) -> list[tuple[str, int]]:
with zipfile.ZipFile(wheel) as zf:
members = sorted(zf.infolist(), key=lambda m: m.compress_size, reverse=True)
return [(m.filename, m.compress_size) for m in members[:count]]


def check(wheel: Path, max_mb: float, warn_mb: float, min_mb: float) -> int:
"""Print one wheel's verdict and return 0 (ok) or 1 (at or over the limit)."""
size = wheel.stat().st_size
mb = size / MB
label = f"{wheel.name}: {size:,} bytes ({mb:.1f} MB)"
if size >= max_mb * MB:
print(f"ERROR: {label} is at or over the {max_mb:g} MB limit", file=sys.stderr)
print(" largest members (compressed):", file=sys.stderr)
for name, compressed in _largest_members(wheel):
print(f" {compressed / MB:8.1f} MB {name}", file=sys.stderr)
print(
" This is probably a mistake (a whole distribution in JAR_LIB_DIR, an optional jar, "
"a stale artifact). Do not publish it.",
file=sys.stderr,
)
return 1
if size >= warn_mb * MB:
print(
f"WARNING: {label} is within {max_mb - mb:.1f} MB of the {max_mb:g} MB limit"
)
elif size < min_mb * MB:
print(
f"WARNING: {label} is below {min_mb:g} MB: is the engine or the JRE missing?"
)
else:
print(f"OK: {label}")
return 0


def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
parser.add_argument("wheels", nargs="+", type=Path)
parser.add_argument("--max-mb", type=float, default=DEFAULT_MAX_MB)
parser.add_argument("--warn-mb", type=float, default=DEFAULT_WARN_MB)
parser.add_argument("--min-mb", type=float, default=DEFAULT_MIN_MB)
args = parser.parse_args(argv)
max_mb = float(os.environ.get("ARCADEDB_WHEEL_MAX_MB") or args.max_mb)
if max_mb != args.max_mb:
print(f"NOTE: size limit set to {max_mb:g} MB by ARCADEDB_WHEEL_MAX_MB")
status = 0
for wheel in args.wheels:
if not wheel.is_file() or not zipfile.is_zipfile(wheel):
print(f"ERROR: {wheel} is not a wheel file", file=sys.stderr)
return 2
status = max(status, check(wheel, max_mb, args.warn_mb, args.min_mb))
return status


if __name__ == "__main__":
sys.exit(main())
142 changes: 142 additions & 0 deletions bindings/python/tests/test_wheel_size.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
"""The wheel size gate: a wheel at or over the limit fails the build, odd sizes warn.

The tests use small limits instead of 100 MB files, so they run in milliseconds and need no built wheel.
"""

from __future__ import annotations

import importlib.util
import os
import zipfile
from pathlib import Path

import pytest

SCRIPT_PATH = Path(__file__).resolve().parents[1] / "scripts" / "verify_wheel_size.py"


def _load():
spec = importlib.util.spec_from_file_location("verify_wheel_size", SCRIPT_PATH)
module = importlib.util.module_from_spec(spec)
assert spec.loader is not None
spec.loader.exec_module(module)
return module


def _wheel(path: Path, members: dict[str, int]) -> Path:
"""A zip file with incompressible members of the given sizes, so its size is close to their sum."""
with zipfile.ZipFile(path, "w", zipfile.ZIP_STORED) as zf:
for name, size in members.items():
zf.writestr(name, os.urandom(size))
return path


def test_a_wheel_under_the_limit_passes(tmp_path, capsys):
module = _load()
wheel = _wheel(tmp_path / "a-1-py3-none-any.whl", {"x/engine.jar": 400_000})
assert (
module.main(
[str(wheel), "--max-mb", "1", "--warn-mb", "0.9", "--min-mb", "0.1"]
)
== 0
)
assert "OK:" in capsys.readouterr().out


def test_a_wheel_at_or_over_the_limit_fails_and_names_the_largest_members(
tmp_path, capsys
):
module = _load()
wheel = _wheel(
tmp_path / "a-1-py3-none-any.whl",
{
"jars/arcadedb-gremlin.jar": 700_000,
"jars/engine.jar": 400_000,
"small.txt": 10,
},
)
assert module.main([str(wheel), "--max-mb", "1"]) == 1
err = capsys.readouterr().err
assert "over the 1 MB limit" in err
assert err.index("arcadedb-gremlin.jar") < err.index(
"engine.jar"
) # the largest first


def test_the_limit_is_a_decimal_megabyte_and_the_size_is_compared_with_at_or_over(
tmp_path,
):
module = _load()
wheel = _wheel(tmp_path / "a-1-py3-none-any.whl", {"j": 400_000})
size = wheel.stat().st_size
assert module.check(wheel, max_mb=(size + 1) / 1_000_000, warn_mb=10, min_mb=0) == 0
assert module.check(wheel, max_mb=size / 1_000_000, warn_mb=10, min_mb=0) == 1


def test_a_wheel_close_to_the_limit_warns_and_a_tiny_one_warns_differently(
tmp_path, capsys
):
module = _load()
near = _wheel(tmp_path / "near-1-py3-none-any.whl", {"j": 950_000})
assert (
module.main([str(near), "--max-mb", "1", "--warn-mb", "0.9", "--min-mb", "0.1"])
== 0
)
assert "within" in capsys.readouterr().out
tiny = _wheel(tmp_path / "tiny-1-py3-none-any.whl", {"j": 1_000})
assert (
module.main([str(tiny), "--max-mb", "1", "--warn-mb", "0.9", "--min-mb", "0.5"])
== 0
)
assert "engine or the JRE" in capsys.readouterr().out


def test_every_wheel_is_checked_and_the_worst_verdict_wins(tmp_path):
module = _load()
ok = _wheel(tmp_path / "ok-1-py3-none-any.whl", {"j": 100_000})
big = _wheel(tmp_path / "big-1-py3-none-any.whl", {"j": 900_000})
assert module.main([str(ok), str(big), "--max-mb", "0.5", "--min-mb", "0"]) == 1
assert module.main([str(ok), "--max-mb", "0.5", "--min-mb", "0"]) == 0


def test_the_environment_variable_overrides_the_limit_and_says_so(
tmp_path, capsys, monkeypatch
):
module = _load()
wheel = _wheel(tmp_path / "a-1-py3-none-any.whl", {"j": 900_000})
assert module.main([str(wheel), "--max-mb", "0.5"]) == 1
monkeypatch.setenv("ARCADEDB_WHEEL_MAX_MB", "5")
capsys.readouterr()
assert module.main([str(wheel), "--max-mb", "0.5", "--min-mb", "0"]) == 0
assert "ARCADEDB_WHEEL_MAX_MB" in capsys.readouterr().out


def test_a_missing_file_or_a_non_wheel_is_a_usage_error(tmp_path):
module = _load()
assert module.main([str(tmp_path / "nope.whl")]) == 2
not_zip = tmp_path / "x.whl"
not_zip.write_text("not a zip")
assert module.main([str(not_zip)]) == 2


def test_the_default_limit_is_the_policy_of_100_decimal_megabytes_and_main_uses_it(
tmp_path, monkeypatch
):
module = _load()
assert (module.MB, module.DEFAULT_MAX_MB) == (1_000_000, 100.0)
assert module.DEFAULT_WARN_MB < module.DEFAULT_MAX_MB
wheel = _wheel(tmp_path / "a-1-py3-none-any.whl", {"j": 900_000})
monkeypatch.setattr(
module, "DEFAULT_MAX_MB", 0.5
) # main() reads the default when it parses its arguments
assert module.main([str(wheel)]) == 1
monkeypatch.setattr(module, "DEFAULT_MAX_MB", 5.0)
monkeypatch.setattr(module, "DEFAULT_MIN_MB", 0.0)
assert module.main([str(wheel)]) == 0


def test_the_script_prints_only_ascii_so_a_windows_console_cannot_crash_it():
"""The Windows CI job failed once with a UnicodeEncodeError on an emoji in the output (cp1252 console)."""
source = SCRIPT_PATH.read_text(encoding="utf-8")
body = source.split('"""', 2)[2]
assert not [c for c in body if ord(c) > 127]
Loading