Repository navigation
Ship cross toolchains as separate PyPI packages - #9
Merged
Merged
Conversation
Each cross toolchain is now its own PyPI project rather than being
bundled into the base ppbt wheel. The base wheel stays lean (native
toolchain only, ~40 MiB); cross users opt in via extras:
pip install ppbt[cross-aarch64-linux-gnu]
pip install ppbt[cross-x86_64-linux-gnu]
pip install ppbt[cross-all]
The base ppbt package exposes new API for picking a toolchain by
triplet -- archive_for(triplet), toolchain_for(triplet),
available_triplets() -- and extract() / environ() take a triplet=
kwarg. Cross packages register themselves via a ppbt.toolchains
entry point so base ppbt discovers them at import time without
having to know their names.
Sibling packages:
- packages/cross-aarch64-linux-gnu/ (aarch64 target, x86_64 host)
- packages/cross-x86_64-linux-gnu/ (x86_64 target, aarch64 host)
Each ships its own crosstool-ng config + build backend, produces a
wheel tagged for its *host* arch (an aarch64 cross toolchain runs on
an x86_64 host, so the wheel is manylinux_2_17_x86_64), and has its
own RECORD-merging on extract.
CI matrix now has 4 cells (base x 2 host arches + 2 cross siblings
each on its one host), and both source + wheel upload patterns use
glob dispatch so new sibling packages fall out without wiring every
artifact name individually. Editable installs across all three
packages skip the heavy crosstool-ng build via a PEP 660
build_editable hook, so dev installs take seconds rather than hours.
2 of 4 tasks
- Pre-commit's ``Install System Deps`` step installed ``libxml2`` as a
bare package, which ubuntu-26.04 ("resolute") dropped from main.
``libxml2-dev`` alone pulls the runtime transitively, which was the
fix already used elsewhere.
- ``test_environ_defaults_to_host`` and ``test_environ_accepts_triplet``
asserted ``env["CC"].endswith("bin/<triplet>-gcc")``, but on Windows
``pathlib`` builds ``bin\<triplet>-gcc`` (backslashes), so both
failed on the Windows CI matrix. Use ``pathlib.PurePath(cc).name``
instead of a hard-coded separator substring.
Also picks up the black/isort reformats on the sibling build.py files
that had multi-line ``from ... import`` blocks collapsed by newer
black.
Black 22.6.0 calls asyncio.get_event_loop() which 3.12 removed; the pyflakes bundled with flake8-mypy-fork references ast.Str, also removed in 3.12. ubuntu-26.04's default python is 3.12, so pin 3.11 with actions/setup-python before running pre-commit. The copyright hook also wanted the 2024 headers bumped to 2024-2026 on the files touched in this PR.
GitHub retired macos-12 in late 2024 and macos-13-xlarge requires paid Apple-Silicon runners that aren't enabled on this repo, so both cells queued indefinitely on every PR run. Use macos-13 (x86) and macos-14 (Apple Silicon, generic label) instead — same coverage, no paid tier required.
ppbt ships only Linux manylinux wheels (crosstool-ng gcc toolchain targeting glibc 2.17); there's no macOS wheel to validate. The macOS cells had been queued-but-never-run for a while (macos-12 retired, macos-13-xlarge needs paid Apple Silicon runners), and macos-13 / macos-14 jobs get scheduler-cancelled on this org. Removing them rather than babysit a configuration that adds no coverage.
Self-hosted `src-build` runners weren't picking up these jobs (queued indefinitely with no runner assignment). Use ubuntu-latest for x86_64 cells and ubuntu-24.04-arm for aarch64 cells; both are free for public repos and compatible with the debian:11 container the wheel build runs inside.
Debian 11 (bullseye) is no longer served from debian-security; the pool returned 404 for every pinned security update so apt-get install failed. The target glibc (2.17) is produced by crosstool-ng inside the container, not by the container itself, so moving the host image up to bookworm doesn't change what ends up in the shipped toolchain.
Previously `src/ppbt/build.py` was both the PEP 517 build backend and part of the installed wheel. That meant anything consuming `ppbt` at runtime (notably relenv) could trip over setuptools / subprocess / tarfile machinery that only belongs at wheel-build time. Commit 09d32eb already moved setuptools imports out of ppbt.common for the same reason; this finishes the job by relocating the backend module outside `src/` entirely. - Base ppbt: `_build.py` at repo root. - Each cross sibling: `packages/cross-<triplet>/_build.py`. - All three pyprojects now set `build-backend = "_build"` and `backend-path = ["."]`. - `src/ppbt/build.py` deleted; backend duplicates the small subset of ppbt.common helpers it needs (build_arch, get_triplet, extract_archive) so it is standalone and not circular. - tests/test_build.py now loads `_build.py` by path and asserts the PEP 517 hooks are exposed.
Isort 5.12 (pre-commit-pinned) splits `from X import Y as _Y` onto its own line, which disagrees with my local isort's black profile and ping-pongs the file. Import the submodule once and dereference each PEP 517 hook off it instead; no `as` imports, no disagreement.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #8. Addresses the request for cross toolchains that don't
bloat the base
ppbtwheel.Design
Each cross toolchain is its own PyPI project rather than being bundled
into base
ppbt:ppbt— native host toolchain, ~40 MiB (unchanged from 0.1.8).ppbt-cross-aarch64-linux-gnu— aarch64 target, x86_64 host wheel.ppbt-cross-x86_64-linux-gnu— x86_64 target, aarch64 host wheel.Users opt in via extras:
Cross packages register themselves via a
ppbt.toolchainsentrypoint so base
ppbtdiscovers them at import time — no name lookupin downstream consumers.
New API
extract()/environ()defaulttriplet=to the host, sopre-0.2.0 callers keep working unchanged.
Repo layout
CI
package-action.yml: matrix has 4 cells (base x86_64,base aarch64,cross-aarch64-linux-gnu on x86_64 host,cross-x86_64-linux-gnu on aarch64 host). Each cell produces onewheel.
deploy-package-action.yml: globs allPython Wheel *artifactsinto
dist/and letspypa/gh-action-pypi-publishupload them;works for N packages without listing names.
github-release.yml: switched tosoftprops/action-gh-releasewith
files: dist/*so it uploads whatever CI built (thehard-coded 3-asset pattern couldn't scale to 7 artifacts).
PyPI trusted-publisher config (manual, before first release)
I can't create these; someone with PyPI maintainer rights has to add
two pending publishers at https://pypi.org/manage/account/publishing/:
ppbt-cross-aarch64-linux-gnusaltstackppbtdeploy-package-action.ymlreleaseppbt-cross-x86_64-linux-gnu— same except project name.Both names are currently unclaimed on PyPI (verified 404 on their
pypi.org/pypi//json).
Test plan
pytest tests/— 12 passing (newtests/test_common.pycovershost/cross resolution, entry-point discovery, archive-missing
fallback, and clear error on unregistered triplets).
pip install -e . -e packages/cross-aarch64-linux-gnu -e packages/cross-x86_64-linux-gnuppbt.available_triplets()returns[]until a tarball isstaged, then discovers both.
pre-commit run --all-filesclean (isort/black/flake8).kind=releaseworkflow dispatch publishes all 3 projects.
relenvcutover: callppbt.archive_for(triplet)from
get_toolchain(); validates the cross-build path for #37.