Skip to main content

mojox

CLI and execution layer for Mojo build tooling.

mojox reads your pyproject.toml manifest (via mojox-core), discovers targets, builds an execution plan, and runs mojo commands with structured output. It handles profile resolution, local settings (.mojox/config.toml), diagnostic formatting, and a compiled-binary cache so unchanged tests and programs are not rebuilt.

Install

uv add mojox "mojo-compiler==1.0.0"    # in a project
uv tool install mojox                      # globally

Subcommands

test

Run test targets (dev profile by default). Each test file is built to a binary, then executed.

mojox test                                    # all test targets
mojox test -k "parse" tests/unit/             # filter by name + path
mojox test --output-format json               # NDJSON to stdout (CI)
mojox test --no-fail-fast                     # run all tests even after failures
mojox test --failure-output final             # show failing output after all tests
mojox test --bundle -k "parse"                # one harness binary, filter test functions
mojox test --no-bundle                        # one binary per test file, even when test-bundle is set
mojox test --examples                         # also compile-check examples/*/main.mojo

Test-specific flags:

Flag Default Description
--output-format {human,json} human Output format; json emits NDJSON to stdout
--fail-fast / --no-fail-fast --fail-fast Stop after first failure
--success-output {immediate,final,never} never When to show passing test output
--failure-output {immediate,final,never} immediate When to show failing test output
-k / --filter PATTERN Filter tests by name (case-insensitive substring); see --bundle
--bundle / --no-bundle test-bundle, else off Compile every test_* function into a single harness binary, or one binary per test file
--examples off Also compile-check examples/*/main.mojo
--no-cache off Always rebuild; cached test binaries are left untouched, precompiled packages are rebuilt in place and lose their cache entry
paths (positional) Filter tests by file or directory prefix

Examples are not checked unless you pass --examples or a path under examples/. They are compiled, never executed.

With --bundle, test files without test_* functions are left out of the bundle (with a note on stderr), and -k matches test function names inside the harness at runtime, so a pattern that matches nothing still builds the harness. Without it, -k matches test file paths.

Bundle mode can be the project's default: set test-bundle = true in [tool.mojox], or in one profile only (for example [tool.mojox.profile.ci]); --bundle and --no-bundle override it for one run. It cannot be set in .mojox/config.toml or through the environment. A bundle run builds and runs the harness as one command, with the libraries compiled from source, then checks the examples (with --examples) as mojox test does without --bundle. A line under Starting says what goes into the harness and which timeout applies: the timeout covers the harness compile and every test in it. -j sets the workers for the example checks only (it has no effect without --examples), and --fail-fast skips the examples when the harness does not pass; it never stops between tests inside the harness. --dry-run lists the harness build and any example checks. When the harness crashes, times out or fails before printing its summary, mojox suggests rerunning with --no-bundle to find the test. In JSON output the harness is one command event, and the suite started event carries "mode": "bundle" ("files" otherwise).

Binary cache

Build outputs live under .mojox/cache/: test binaries in bin/, their cache keys in meta/, example builds in examples/. A test is rebuilt only when its key changes. The key covers the test source, the project's library and test trees, every include dir passed via -I, including dependency dirs and -I entries in manifest, profile or --flag flags (file size and mtime, not content), the compiler flags, the settings env table and the toolchain (the compiler, and the real path of the cc it links with and NIX_CC). Host variables such as TMPDIR or the locale never enter the key. mojox cache clean deletes .mojox/cache/, .mojox/bundle/ and .mojox/build/pkg/.

Precompiled library packages (.mojox/build/pkg/<hash>/, one directory per distinct input set; mojox cache clean removes them) are cached too, by test, build and check alike: a lib is precompiled again only when its sources, the dependency include dirs, the precompile arguments, the settings env table or the toolchain change, or when its package is missing.

mojo and the test binaries run with an allowlisted environment, not yours. Forwarded: the process PATH (absolute entries only, none inside the project, the mojo directory first), CC, CXX, AR, LD, PKG_CONFIG_PATH, CARGO_HOME, CARGO_TARGET_DIR, RUSTFLAGS, SSL_CERT_FILE, TMPDIR, SOURCE_DATE_EPOCH and the Nix compiler-wrapper variables (NIX_CC, NIX_LDFLAGS, ...). LD_LIBRARY_PATH, PYTHONPATH, NIX_CONFIG and everything else are not. A value in a settings file's env table wins over a forwarded one. mojox metadata lists the forwarded names, never the values.

Add .mojox/ to your .gitignore.

run

Build a single .mojo file, then execute the binary (dev profile by default).

mojox run src/main.mojo
mojox run --no-cache src/main.mojo            # always rebuild

The binary goes through the same .mojox/cache/bin cache as mojox test, so a second run of an unchanged file skips the build. Editing the file, a sibling module or a dependency triggers a rebuild. Output is captured and replayed once the program exits, not streamed. The timeout (--timeout, MOJOX_TIMEOUT, local settings, or timeout in [tool.mojox] or the profile) covers the build and the run.

Exit code: the program's own code; 128 + N if it is killed by signal N; 1 if the build fails (compiler crash included) or the timeout is hit.

build

Compile binary targets (the manifest's build-profile by default, else release).

mojox build

check

Validate the manifest, run lints, and compile library packages when a compiler is available (manifest-only otherwise). Exits 1 on a compile failure, 2 on an invalid manifest.

mojox check

metadata

Output the build plan as JSON. policy.test_bundle says whether mojox test runs in bundle mode; commands is always the per-file plan, marked by "commands_mode": "files".

mojox metadata

cache clean

Delete .mojox/cache/ (cached binaries and their metadata). Safe to run when there is no cache.

mojox cache clean

Common flags

These flags are available on every subcommand except cache:

Flag Description
--profile PROFILE Build profile (dev, release, or user-defined); build defaults to build-profile
-j / --jobs N Maximum concurrent compilations
--compile-threads N Threads each mojo build may use (overrides compile-threads from [tool.mojox], the profile, settings and MOJOX_COMPILE_THREADS)
--timeout SECONDS Per-target timeout (overrides timeout from [tool.mojox], the profile, settings and MOJOX_TIMEOUT)
--dry-run Show planned commands without executing
-v / --verbose Expand grouped output
--no-config Disable .mojox/config.toml discovery
--config-file PATH Explicit config file path
-D / --define KEY=VALUE Define a compile-time variable (repeatable)
--flag VALUE Extra flag passed through to the compiler (repeatable; use --flag=VALUE for dash-prefixed flags)

Unknown keys in [tool.mojox], its profile tables and .mojox/config.toml are errors that suggest the closest valid key, or name where a misplaced key belongs. A settings file rejects keys it cannot set (such as optimize or defines), and a settings file that is not valid TOML is an error naming the file. The env tables of the user and project settings files merge key by key. mojox metadata reports where each resolved value came from under policy.origins (unstable).

How it works

  1. Parses pyproject.toml via mojox-core (manifest model layer)
  2. Reads .mojox/config.toml local settings, if present (TOCTOU-safe via openat)
  3. Resolves policy: profile, defines, flags, CLI overrides
  4. Discovers targets and builds a plan (pure -- returns commands as data)
  5. Executes the plan: runs mojo commands, collects outcomes, formats output
  6. For tests and run, builds each file to a binary (reusing a cached one when its key matches), then executes it

Exit codes

mojox test:

Code Meaning
0 Success
1 Test failure(s), including a test file that fails to build
2 Library or example compilation failure, or configuration error
130 Interrupted (Ctrl+C)

mojox run:

Code Meaning
any The program's own exit code
128 + N The program was killed by signal N
1 Build failure or timeout
2 Toolchain not found

See also

  • mojox-core -- manifest parsing, target discovery, and build planning (pure model layer)
  • mojox-build -- PEP 517 build backend for packaging Mojo libraries as wheels

License

MIT

Metadata

Release files for mojox 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 0.7.0
File Size Uploaded Provenance Actions
mojox-0.7.0.tar.gz 106.5 kB With provenance Details for mojox-0.7.0.tar.gz

Built distribution (wheel)

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

Total release size: 160.9 kB

Release files / mojox-0.7.0.tar.gz

Download URL mojox-0.7.0.tar.gz
Size 106.5 kB
Tags Source
SHA-256 checksum
How to use checksums
09c08ebf0d6bfca18aa5d8b0feb0315bed5b4577d8bba899531fee2e13f72d8e
BLAKE2b-256 checksum
How to use checksums
320f47d0b9a3e6948d188dacec7b28863dd404f17f3d9ee15a7d334502aaf057
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-0.7.0-py3-none-any.whl

Download URL mojox-0.7.0-py3-none-any.whl
Size 54.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7faf5d59f772893854610eba2fa27bc9006824d93f7c25926145098016bc5da3
BLAKE2b-256 checksum
How to use checksums
97b58ae03f138a6c5e6f9cb63561b8521eb1650f3142069d2ce834d25af82e43
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 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-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