Skip to main content

PEP 517 / PEP 660 build backend for Mojo libraries (compiles .mojo packages into wheels).

Project description

mojox-build

PEP 517 + PEP 660 build backend that compiles a Mojo library into a .whl.

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.0b2,<2"]

[build-system]
requires      = ["mojox-build>=0.4", "mojo-compiler>=1.0.0b2,<2"]
build-backend = "mojox_build"

[tool.mojox-build]
# Either a src/ layout (default):
package-root = "src"
# Or an explicit list of packages at the repo root:
# packages = ["boucle"]

uv build produces dist/boucle-0.2.0-py3-none-<platform>.whl containing boucle.mojoc at boucle-0.2.0.data/platlib/mojo_packages/boucle.mojoc (.mojopkg on Mojo < 1.0). When installed, it lands in the venv's site-packages/mojo_packages/, which mojox discovers automatically.

[tool.mojox-build] reference

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 compiled package (.mojoc, or .mojopkg on Mojo < 1.0).
native-libs list[str] [] Pre-built .so / .dylib files to copy into mojo_packages/lib/.
defines table {} -D KEY=VALUE flags passed to the package compile (mojo precompile).
flags list[str] [] Extra flags appended to every package-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.

What you get

  • Platform-tagged wheels. The compiled package is native code, so wheels are tagged with the host platform (e.g. manylinux_2_34_x86_64, macosx_13_0_arm64). Cross-platform installs are correctly rejected by uv/pip.
  • Native lib bundling. Drop .so / .dylib paths in native-libs; they ride along in mojo_packages/lib/, where mojox's runtime adds them to LD_LIBRARY_PATH.
  • 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].
  • Reproducible builds. ZIP and tar timestamps respect SOURCE_DATE_EPOCH.
  • Parallel compilation. Multi-package repos compile their packages in parallel (capped at 8 workers).
  • Preflight checks. Missing mojo, missing dirs, missing native libs, dynamic-version configs → one clean error message, not a stderr dump.
  • Full PEP 621 / PEP 639 metadata. authors, maintainers, urls, keywords, classifiers, optional-dependencies, license-files (copied into .dist-info/licenses/) all flow into the wheel METADATA.
  • --config-setting verbose=true. Streams compiler output during builds when you need to debug.

How it works (architecture in five lines)

__init__.py re-exports the hook surface. _hooks is thin glue that calls into _config (parse pyproject), _preflight (environment checks), _build (compile + assemble), and _metadata (METADATA/WHEEL rendering). The whole backend has only one runtime dep beyond the stdlib: packaging for platform tags.

Limitations / known gaps

  • Dynamic project.version is not supported. Declare it statically.
  • Editable installs rebuild the full wheel on every invocation; there's no source-import fast path because the package is compiled bytecode.
  • Cross-compilation (--target per platform) is not exposed yet. Today's wheels are host-platform only.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mojox_build-0.4.0.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mojox_build-0.4.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file mojox_build-0.4.0.tar.gz.

File metadata

  • Download URL: mojox_build-0.4.0.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","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}

File hashes

Hashes for mojox_build-0.4.0.tar.gz
Algorithm Hash digest
SHA256 fb8a882fa0aa5d149316a5aa88fb7bc00d855d040319748e8354092be2726465
MD5 b6469812616f5c69e94e4e0997aa87db
BLAKE2b-256 b480ac0fca7a4ec96dcf7f593f35df10cee8e2e7c3785369da43965a5cc5b499

See more details on using hashes here.

File details

Details for the file mojox_build-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: mojox_build-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","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}

File hashes

Hashes for mojox_build-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 98065ce89cb81a1e4eb47d890393e6937b46784d1f2a1d279cdffc9e64c9f5ec
MD5 02feeb781fa61951b5105fedee087442
BLAKE2b-256 e29382dd02c88fdf659916e7c31988eb195dc6f44c0f27520dcad7d6d1fdad5c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page