Skip to main content

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" Profile for wheel builds and mojox build (--profile overrides)
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

Unknown keys print a warning during builds instead of failing, so a project using a newer key still builds with an older mojox-build.

How it works

  1. A PEP 517 frontend (uv build, pip wheel) calls build_wheel(), build_sdist(), or build_editable().
  2. The hook reads pyproject.toml via mojox-core's manifest parser.
  3. Policy is resolved from the active build profile (defaults to release).
  4. mojo precompile runs for each package directory, producing .mojoc files.
  5. 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__.py re-exports the PEP 517 hook surface.
  • _hooks.py implements PEP 517 + PEP 660 hooks (thin glue that wires config, preflight, and build together).
  • _build.py handles compilation, wheel assembly, sdist assembly, and editable installs.
  • _metadata.py renders PEP 621 / PEP 643 METADATA and PEP 427 WHEEL files.
  • _preflight.py validates the build environment before compilation starts.

Config parsing, policy resolution, and toolchain detection live in mojox-core (0.7.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/.dylib paths in native-libs. They ship in mojo_packages/lib/, where mojox adds them to LD_LIBRARY_PATH at runtime.
  • PEP 660 editable installs. uv pip install -e . works. For rebuild-on-change semantics, add cache-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.version is 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.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mojox-build 0.7.0
File Size Uploaded Provenance Actions
mojox_build-0.7.0.tar.gz 18.2 kB With provenance Details for mojox_build-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mojox-build 0.7.0
File Interpreter ABI Platform Actions
mojox_build-0.7.0-py3-none-any.whl Python 3 none any Details for mojox_build-0.7.0-py3-none-any.whl

Total release size: 33.2 kB

Release files / mojox_build-0.7.0.tar.gz

Download URL mojox_build-0.7.0.tar.gz
Size 18.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ab5d33291cccb5a3d86d3ee8419a64a1ed3125454d7ae68abb9077fde0941cc3
BLAKE2b-256 checksum
How to use checksums
4052dddbb4c7963d6d6ee37418166f5b617e87274dd4acffdf93710e97860c1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / mojox_build-0.7.0-py3-none-any.whl

Download URL mojox_build-0.7.0-py3-none-any.whl
Size 15.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c74312dfaa0129110a465aa1e2c25adeac56f43e104cdf5a0336ab75448047a5
BLAKE2b-256 checksum
How to use checksums
d512c196988aad548be1d127bdf15f1b654d4e9030266ecf901e884a3dfa76ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Security for mojox-build 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mojox_build-0.7.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page