{"id":46598248,"url":"https://github.com/cofin/hatch-mojo","last_synced_at":"2026-03-07T15:08:28.011Z","repository":{"id":341450076,"uuid":"1166171444","full_name":"cofin/hatch-mojo","owner":"cofin","description":"Hatch build hook plugin for Mojo","archived":false,"fork":false,"pushed_at":"2026-03-01T19:24:34.000Z","size":483,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-01T21:51:18.648Z","etag":null,"topics":["build","hatch","mojo"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cofin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-25T00:18:09.000Z","updated_at":"2026-02-26T17:24:13.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/cofin/hatch-mojo","commit_stats":null,"previous_names":["cofin/hatch-mojo"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/cofin/hatch-mojo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cofin%2Fhatch-mojo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cofin%2Fhatch-mojo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cofin%2Fhatch-mojo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cofin%2Fhatch-mojo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cofin","download_url":"https://codeload.github.com/cofin/hatch-mojo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cofin%2Fhatch-mojo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30219525,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T14:02:48.375Z","status":"ssl_error","status_checked_at":"2026-03-07T14:02:43.192Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["build","hatch","mojo"],"created_at":"2026-03-07T15:08:27.468Z","updated_at":"2026-03-07T15:08:27.998Z","avatar_url":"https://github.com/cofin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hatch-mojo\n\nA [Hatch](https://hatch.pypa.io/) build hook plugin that compiles [Mojo](https://docs.modular.com/mojo/) sources during package builds.\n\nSupports Python extension modules and standalone artifacts (shared libraries, executables, etc.).\n\n## Installation\n\n```bash\nuv add hatch-mojo\n```\n\n## Quickstart\n\nAdd the hook to your `pyproject.toml`:\n\n```toml\n[build-system]\nbuild-backend = \"hatchling.build\"\nrequires = [\"hatchling\", \"hatch-mojo\"]\n\n[tool.hatch.build.targets.wheel.hooks.mojo]\ntargets = [\"wheel\"]\n\n[[tool.hatch.build.targets.wheel.hooks.mojo.jobs]]\nname = \"core\"\ninput = \"src/mo/my_pkg/core.mojo\"\nemit = \"python-extension\"\nmodule = \"my_pkg._core\"\ninclude-dirs = [\"src/mo\"]\n```\n\nThen build:\n\n```bash\nhatch build -t wheel\n```\n\n## Configuration\n\nAll configuration lives under `[tool.hatch.build.targets.wheel.hooks.mojo]` in `pyproject.toml`.\n\n### Global options\n\n```toml\n[tool.hatch.build.targets.wheel.hooks.mojo]\nmojo-bin = \"/opt/mojo/bin/mojo\"    # path to mojo binary (default: $HATCH_MOJO_BIN or \"mojo\")\nparallel = true                     # compile jobs in parallel\nfail-fast = true                    # stop on first failure (only with parallel)\nclean-before-build = false          # remove build-dir before compiling\nclean-after-build = false           # remove build-dir after compiling\nskip-editable = true                # skip Mojo compilation for editable installs\nbuild-dir = \"build/mojo\"            # working directory for compiled artifacts\ntargets = [\"wheel\"]                 # hatch build targets that trigger this hook\ninclude = [\"src/mo/**/*.mojo\"]      # git-style globs to include\nexclude = [\"**/experimental*.mojo\"] # git-style globs to exclude\n```\n\n### Profiles\n\nProfiles define reusable sets of job options. Jobs reference them by name, and profile values are merged into the job config.\n\n```toml\n[tool.hatch.build.targets.wheel.hooks.mojo.profiles.default]\ninclude-dirs = [\"src/mo\"]\nflags = [\"-I\", \"vendor/include\"]\n```\n\n```toml\n[[tool.hatch.build.targets.wheel.hooks.mojo.jobs]]\nname = \"core\"\nprofiles = [\"default\"]\ninput = \"src/mo/my_pkg/core.mojo\"\nemit = \"python-extension\"\nmodule = \"my_pkg._core\"\n```\n\n### Jobs\n\nEach job compiles a single Mojo source into an output artifact.\n\n**Python extension:**\n\n```toml\n[[tool.hatch.build.targets.wheel.hooks.mojo.jobs]]\nname = \"core\"\ninput = \"src/mo/my_pkg/core.mojo\"\nemit = \"python-extension\"\nmodule = \"my_pkg._core\"\ninclude-dirs = [\"src/mo\"]\n```\n\n**Non-Python artifact** (requires an `install` mapping):\n\n```toml\n[[tool.hatch.build.targets.wheel.hooks.mojo.jobs]]\nname = \"cli\"\ninput = \"src/mo/my_pkg/cli.mojo\"\nemit = \"executable\"\ninstall = { kind = \"scripts\", path = \"my-cli\" }\n```\n\n### Job options reference\n\n| Option | Type | Description |\n|---|---|---|\n| `name` | string | Unique identifier for the job |\n| `input` | string | Path to the Mojo source file (supports globs) |\n| `emit` | string | `python-extension`, `shared-lib`, `static-lib`, `object`, `executable` |\n| `output` | string | Explicit output path (overrides default) |\n| `module` | string | Dotted import path (required for `python-extension`) |\n| `install` | object | Install mapping for non-Python artifacts: `{ kind, path }` |\n| `profiles` | list | Profile names to inherit settings from |\n| `include-dirs` | list | Additional include directories passed as `-I` |\n| `defines` | list | Values passed as `-D` flags to the compiler |\n| `flags` | list | Extra flags passed to `mojo build` |\n| `env` | object | Environment variables set during compilation |\n| `platforms` | list | Restrict job to specific `sys.platform` values |\n| `arch` | list | Restrict job to specific `platform.machine()` values |\n| `marker` | string | PEP 508 marker expression for conditional inclusion |\n| `depends-on` | list | Job names that must complete before this one |\n\nSupported install kinds: `package`, `data`, `scripts`, `root`, `force-include`\n\n## Runtime library bundling\n\nWhen building wheels that include Mojo python-extensions, set `bundle-libs = true` to copy the Mojo runtime libraries into the wheel:\n\n```toml\n[tool.hatch.build.targets.wheel.hooks.mojo]\nbundle-libs = true\n```\n\nThis works on both Linux and macOS. On Linux, `patchelf` sets RPATH on each library. On macOS, `install_name_tool` rewrites dylib install names and inter-library references to use `@rpath`.\n\nA `NOTICE.mojo-runtime` file is automatically included in the wheel alongside the bundled libraries, listing the bundled files and their license terms (Modular Community License). If the SDK directory contains a `LICENSE` file, it is also copied into the wheel as `LICENSE.mojo-runtime`.\n\n### cibuildwheel\n\nWhen using [cibuildwheel](https://cibuildwheel.pypa.io/), keep the following in mind:\n\n**Linux (manylinux):** The Mojo SDK requires `manylinux_2_34` or newer due to GLIBCXX requirements. Standard `auditwheel repair` may reject the wheel — use a retag command instead:\n\n```toml\n[tool.cibuildwheel.linux]\nrepair-wheel-command = \"python -m wheel tags --remove --platform-tag manylinux_2_34_x86_64 {wheel} \u0026\u0026 mv {wheel} {dest_dir}\"\n```\n\n**macOS:** With `bundle-libs = true`, macOS wheels work with standard `delocate`. No special repair command is needed:\n\n```toml\n[tool.cibuildwheel.macos]\nrepair-wheel-command = \"delocate-wheel -w {dest_dir} {wheel}\"\n```\n\n**macOS SIP and `DYLD_LIBRARY_PATH`:** macOS System Integrity Protection (SIP) strips `DYLD_LIBRARY_PATH` from child processes. Setting it in `CIBW_ENVIRONMENT` will **not** propagate to the repair step. If you need it, pass it inline in the repair command:\n\n```toml\n[tool.cibuildwheel.macos]\nrepair-wheel-command = \"DYLD_LIBRARY_PATH=/path/to/libs delocate-wheel -w {dest_dir} {wheel}\"\n```\n\n**libstdc++ on manylinux:** If the Mojo SDK links against a newer libstdc++ than the manylinux baseline provides, you may need to bundle it from conda-forge. This is a Mojo SDK limitation, not a hatch-mojo issue.\n\n## Troubleshooting\n\n| Error | Fix |\n|---|---|\n| `mojo executable not found` | Set `mojo-bin`, `HATCH_MOJO_BIN`, or add `mojo` to `PATH` |\n| `No build jobs resolved` | Check `input` paths, `include`/`exclude` globs, and `targets` |\n| `unknown dependencies` | Ensure `depends-on` references valid job names |\n| Wheel missing binaries | Set `module` for extension jobs or `install` for non-Python jobs |\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcofin%2Fhatch-mojo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcofin%2Fhatch-mojo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcofin%2Fhatch-mojo/lists"}