mojox-build
PEP 517 + PEP 660 build backend that compiles Mojo libraries into platform-tagged wheels.
Declare it in [build-system] and let uv build or pip wheel handle the rest.
Quickstart
# pyproject.toml
[project]
name = "boucle"
version = "0.2.0"
description = "Async event loop primitives for Mojo"
readme = "README.md"
license = "Apache-2.0"
requires-python = ">=3.10"
dependencies = ["mojox", "mojo-compiler>=1.0,<2"]
[build-system]
requires = ["mojox-build>=0.4", "mojo-compiler>=1.0,<2"]
build-backend = "mojox_build"
[tool.mojox]
packages = ["boucle"]
uv build # -> dist/boucle-0.2.0-py3-none-manylinux_2_43_x86_64.whl
uv publish # uploads to PyPI
The wheel places compiled .mojoc packages under mojo_packages/, which mojox discovers at runtime.
[tool.mojox] reference
The full [tool.mojox] table is owned by mojox-core and shared with the CLI. Keys relevant to the build backend:
| Key | Type | Default | Purpose |
|---|---|---|---|
package-root |
str | "src" |
Directory containing top-level package dirs to compile |
packages |
list[str] | (auto-scan package-root) |
Explicit list of source directories. Each becomes one .mojoc |
build-profile |
str | "release" |
Which profile to use for wheel builds |
native-libs |
list[str] | [] |
Pre-built .so/.dylib files to copy into mojo_packages/lib/ |
defines |
table | {} |
-D KEY=VALUE flags passed to mojo precompile |
flags |
list[str] | [] |
Extra flags appended to every compile invocation |
source-include |
list[str] | (sensible default) | Glob patterns of files to include in the sdist |
source-exclude |
list[str] | [] |
Glob patterns to exclude from the sdist |
wheel-exclude |
list[str] | [] |
Glob patterns to exclude from the wheel |
How it works
- A PEP 517 frontend (
uv build,pip wheel) callsbuild_wheel(),build_sdist(), orbuild_editable(). - The hook reads
pyproject.tomlviamojox-core's manifest parser. - Policy is resolved from the active build profile (defaults to
release). mojo precompileruns for each package directory, producing.mojocfiles.- The compiled packages, native libs, and metadata are assembled into a wheel tagged with the host platform.
Architecture
Five modules, roughly 1100 lines total:
__init__.pyre-exports the PEP 517 hook surface._hooks.pyimplements PEP 517 + PEP 660 hooks (thin glue that wires config, preflight, and build together)._build.pyhandles compilation, wheel assembly, sdist assembly, and editable installs._metadata.pyrenders PEP 621 / PEP 643 METADATA and PEP 427 WHEEL files._preflight.pyvalidates the build environment before compilation starts.
Config parsing, policy resolution, and toolchain detection live in mojox-core (0.6.x required, installed automatically). The only other runtime dependency beyond the stdlib is packaging (for platform tags).
Features
- Platform-tagged wheels. Compiled packages are native code. Wheels are tagged with the host platform (
manylinux_2_34_x86_64,macosx_13_0_arm64, etc.), so cross-platform installs are correctly rejected by the resolver. - Native lib bundling. List
.so/.dylibpaths innative-libs. They ship inmojo_packages/lib/, wheremojoxadds them toLD_LIBRARY_PATHat runtime. - PEP 660 editable installs.
uv pip install -e .works. For rebuild-on-change semantics, addcache-keys = [{ file = "pyproject.toml" }, { file = "**/*.mojo" }]to[tool.uv]. - Per-distribution editable files. Two mojox projects installed editable into the same venv do not clobber each other.
- Reproducible builds. ZIP and tar timestamps respect
SOURCE_DATE_EPOCH. - Parallel compilation. Multi-package repos compile concurrently, capped at 8 workers.
- Preflight checks. Missing
mojo, missing dirs, missing native libs, bad config -- one clean error message, not a compiler stderr dump. - Full PEP 621 / PEP 639 metadata. Authors, maintainers, urls, keywords, classifiers, optional-dependencies, license-files all flow into wheel METADATA.
- Compiler pin. When packages are compiled,
Requires-Dist: mojo-compiler==<version>is emitted in the wheel METADATA so the resolver enforces compiler compatibility. - Content-based platform tags. Wheels with native libs or binaries get a platform tag; pure-metadata wheels stay
any. --config-setting verbose=true. Streams compiler output during builds for debugging.
Limitations
- Dynamic
project.versionis not supported. Declare it statically. - Editable installs rebuild the full wheel on every invocation. There is no source-import fast path because the package is compiled bytecode.
- Cross-compilation is not exposed. Wheels are host-platform only.
See also
- mojox-core -- manifest parsing, policy resolution, toolchain detection
- mojox -- CLI for running, testing, and managing Mojo projects
License
MIT
Metadata
Release files for mojox-build 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mojox_build-0.6.0.tar.gz | 15.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mojox_build-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.6 kB
Release files / mojox_build-0.6.0.tar.gz
| Download URL | mojox_build-0.6.0.tar.gz |
|---|---|
| Size | 15.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8dd8a7981655d76d89ec5106fdbd9d09b748d4943e6710d59f151892716407d1
|
|
BLAKE2b-256 checksum How to use checksums |
6eb5f679e746a91b620c098e752780350e11fd6baa8a1e251436c1ebe311c738
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / mojox_build-0.6.0-py3-none-any.whl
| Download URL | mojox_build-0.6.0-py3-none-any.whl |
|---|---|
| Size | 14.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c38f24b1eb3214de4c25e1d0dccc16262e93a4af052783d3ca1c7b1e62787a48
|
|
BLAKE2b-256 checksum How to use checksums |
716f7043ab96f6fce20218acf23a6d35655f5ce772a885159815d19b719ef2ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.20 {"installer":{"name":"uv","version":"0.12.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|