xmojo
xmojo is an interactive Mojo environment built on Modular's ORC execution
engine. One command provides a terminal REPL, native compilation, package
precompilation, and a Jupyter kernel with persistent state and rich display.
Install
xmojo currently supports Apple Silicon:
uv pip install xmojo
The wheel is self-contained. It includes the Mojo compiler, runtime, and standard library used by xmojo, so it does not require a Modular checkout, Bazel, or a separate Mojo installation. It also installs a Jupyter kernelspec.
Each xmojo release targets one exact Mojo nightly. Its numeric release component
ends with that nightly's timestamp; a .postN suffix denotes packaging or
documentation updates for the same build.
Commands
xmojo # interactive ORC REPL
xmojo -e 'print("hello")' # evaluate one cell
xmojo example.mojo # execute a Mojo file
xmojo build hello.mojo -o hello # build a native executable
xmojo precompile mypackage -o mypackage.mojoc # precompile a package
xmojo kernel -f connection.json # run as a Jupyter kernel
xmojo --version
REPL
Run xmojo without arguments. A blank line submits each cell:
$ xmojo
Mojo ORC REPL
Expressions are delimited by a blank line. :quit exits.
1> def answer() -> Int:
.. return 42
..
2> print(answer())
..
42
Declarations and variables persist between cells:
var total = 40
total += 2
total
The final expression produces Int(42) in Jupyter. Persistent variables keep
their original type and cannot be redeclared. They must own their data or refer
only to static storage; copy borrowed views into an owned value before
persisting them.
Build executables
xmojo build uses Modular's native Mojo build driver with an ordinary stdlib,
so compiled programs retain normal standalone I/O behavior:
hello.mojo:
def main():
print("Hello from Mojo")
xmojo build hello.mojo -o hello
./hello
Hello from Mojo
Precompile packages
Precompile a directory containing __init__.mojo and other Mojo modules:
xmojo precompile mypackage -o mypackage.mojoc
The result can be supplied to Mojo through its normal import paths.
Jupyter notebooks
Install xmojo in the environment used by Jupyter, start your preferred Jupyter frontend, and select Mojo (xmojo):
uv pip install xmojo jupyterlab
jupyter lab
The kernel provides:
- persistent functions, types, and typed top-level variables;
- exact streaming of
stdoutandstderr; - automatic display of a cell's final expression;
- explicit rich display with textual MIME bundles;
- compiler-backed completion, inspection, and input completeness;
- source-mapped compiler diagnostics and Mojo runtime stack traces; and
- continued use of the session after ordinary compilation or runtime errors.
Compilation failures execute nothing and add no names. Mutations completed before a runtime error remain visible, while new variables from the raising cell are not persisted.
Rich display
display() publishes explicit output. Mojo repr traits provide
compiler-checked HTML, Markdown, SVG, LaTeX, or complete MIME-bundle
representations:
from xmojo import HTMLRepr, display
@fieldwise_init
struct HTML(HTMLRepr):
var source: String
def _repr_html_(self) -> String:
return self.source
display(HTML("<b>explicit display</b>"))
HTML("<b>automatic final-expression result</b>")
The other traits are MarkdownRepr, SVGRepr, LaTeXRepr, and
MIMEBundleRepr. A Writable value also receives a text/plain
representation; other values receive a type-name fallback.
Modular GPU
GPU sessions use the exactly matched official Mojo compiler and MAX runtime. Install the optional dependency from Modular's nightly package index:
uv pip install --prerelease=allow \
--extra-index-url https://whl.modular.com/nightly/simple/ \
'xmojo[modular-gpu]'
On Apple Silicon, install Xcode's optional Metal toolchain once:
xcodebuild -downloadComponent MetalToolchain
Start a GPU-enabled REPL with:
xmojo --modular-gpu
The launcher detects the local accelerator and supplies the matched compiler, MAX imports, and AsyncRT runtime automatically. Compile and launch an ordinary top-level Mojo function:
from std.gpu import global_idx
from max.gpu.host import DeviceContext
from xmojo.gpu import compile
def increment(output: Pointer[Float32, MutAnyOrigin], size: Int32):
var i = global_idx.x
if i < Int(size):
output[unsafe_offset=i] += 1
with DeviceContext() as context:
var buffer = context.enqueue_create_buffer[DType.float32](256)
var kernel = compile[increment](context)
kernel.enqueue(buffer, Int32(256), grid_dim=1, block_dim=256)
context.synchronize()
compile[...] caches device objects under ~/Library/Caches/xmojo/gpu.
Set XMOJO_GPU_CACHE_DIR to choose another directory. Kernels must currently
be top-level, nonparameterized, noncapturing functions with an ordinary name.
Launch argument count and device types are checked while compiling the cell.
The installed Jupyter kernelspec is CPU-only. To add a separate GPU kernel:
gpu_kernel="$(jupyter --data-dir)/kernels/xmojo-gpu"
mkdir -p "$gpu_kernel"
cat > "$gpu_kernel/kernel.json" <<'JSON'
{
"argv": ["xmojo", "--modular-gpu", "kernel", "-f", "{connection_file}"],
"display_name": "Mojo (xmojo, Modular GPU)",
"language": "mojo"
}
JSON
Select Mojo (xmojo, Modular GPU) in Jupyter.
Current limitations
- Published wheels currently support Apple Silicon only.
- Interrupting a running cell is not yet supported.
- Rich display currently supports textual MIME data, without binary buffers, display metadata, or transient display IDs.
- Persistent variables cannot be redeclared or implicitly captured by functions defined in other cells.
- GPU support is opt-in and currently targets top-level noncapturing kernels.
See DEV.md for architecture, source builds, dependency revisions, testing, and contributor workflow.
License
Apache License v2.0 with LLVM Exceptions. See LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xmojo-0.0.2026082005.post1-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: xmojo-0.0.2026082005.post1-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 47.8 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b8e3d7aa8453e5e702fb004f49bac23cf8f099cda4951eaf9fec9a61522bde3
|
|
| MD5 |
4b3050a518d191fcc1468ba3838276a3
|
|
| BLAKE2b-256 |
66ea7fcfadbb52f23773b644e4c077a311479329538084859f376d8356979397
|