From bf2f6ee3c44b0d2d21c569328ac733c786c4396b Mon Sep 17 00:00:00 2001 From: Jeremy Howard Date: Mon, 31 Aug 2026 09:25:03 +1000 Subject: [PATCH] Separate fast local and optimized distribution builds --- .github/workflows/ci.yml | 8 ++++---- Cargo.toml | 12 ++++++++++++ DEV.md | 2 +- tools/stage_binaries.py | 5 +++-- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0eda8f8..eaec393 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,13 +38,13 @@ jobs: - name: Stage native binary if: runner.os != 'Linux' run: | - cargo build --release --bins - python tools/stage_binaries.py + cargo build --profile dist --bins + python tools/stage_binaries.py dist - uses: PyO3/maturin-action@v1 with: - args: --release --out dist -i python3.10 -i python3.11 -i python3.12 -i python3.13 -i python3.14 + args: --profile dist --out dist -i python3.10 -i python3.11 -i python3.12 -i python3.13 -i python3.14 manylinux: auto - before-script-linux: cargo build --release --bins && python3.10 tools/stage_binaries.py + before-script-linux: cargo build --profile dist --bins && python3.10 tools/stage_binaries.py dist - uses: actions/upload-artifact@v7 with: name: wheels-${{ matrix.os }} diff --git a/Cargo.toml b/Cargo.toml index d49c93e..199efd7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,10 +20,22 @@ path = "src/bin/fbz.rs" test = false [profile.release] +lto = false +codegen-units = 16 + +[profile.release.package.fbz] +incremental = true + +[profile.dist] +inherits = "release" lto = true +incremental = false codegen-units = 1 strip = true +[profile.dist.package.fbz] +incremental = false + [dependencies] blake3 = "1.8.7" clap = { version = "4.6.6", features = ["derive"] } diff --git a/DEV.md b/DEV.md index 11ef5c7..96c6c5d 100644 --- a/DEV.md +++ b/DEV.md @@ -369,7 +369,7 @@ CI tests and builds Linux on x86-64 and ARM64, and macOS on ARM64. macOS Intel r The canonical version lives in `Cargo.toml`. `pyproject.toml` gets the Python package version from Cargo via `dynamic = ["version"]`. -The thin PEP 517 backend delegates to Maturin after building and staging the native executable, so repository and editable builds contain the same native CLI as CI-built wheels. Releases publish platform wheels rather than a Python sdist; the Rust source package is published separately to crates.io. +The thin PEP 517 backend delegates to Maturin after building and staging the native executable, so repository and editable builds contain the same native CLI as CI-built wheels. Ordinary builds use the incremental `release` profile; CI builds distributed wheels and executables with the full-LTO, single-codegen-unit, stripped `dist` profile. Releases publish platform wheels rather than a Python sdist; the Rust source package is published separately to crates.io. ## Release diff --git a/tools/stage_binaries.py b/tools/stage_binaries.py index 204040c..2222d62 100644 --- a/tools/stage_binaries.py +++ b/tools/stage_binaries.py @@ -1,8 +1,9 @@ -import os, shutil +import os, shutil, sys from pathlib import Path root = Path(__file__).resolve().parents[1] -source = root / "target" / "release" +profile = sys.argv[1] if len(sys.argv) > 1 else "release" +source = root / "target" / profile destination = root / "target" / "wheel-data" / "scripts" destination.mkdir(parents=True, exist_ok=True) suffix = ".exe" if os.name == "nt" else ""