Skip to main content

uv add nimlang

Use Nim in a Python project with nothing but uv.

nimlang is a Python package that ships the Nim compiler in its wheels and compiles C through zig cc from the ziglang package, so you need no system Nim and no C compiler.

AI disclosure: this project is mostly vibed. Currently level 7 on visidata AI scale: Human specced, bots coded.

Status: alpha. Ideas for evolution: ROADMAP.md.

Try it: a Python project with a Nim function

uv init uv-add-nimlang-demo && cd uv-add-nimlang-demo
uv add nimlang
uv run nimlang add nimpy            # Nim deps go in [tool.nimlang] in pyproject.toml
uv run nimlang info                 # bundled Nim and zig, and the project's Nim deps

slow.py, you have a slow function in Python:

def fib(n):
    return n if n < 2 else fib(n - 1) + fib(n - 2)

fast.nim, you write it in Nim:

import nimpy

proc fib(n: int): int {.exportpy.} =
  if n < 2: n else: fib(n - 1) + fib(n - 2)

fast.py, and import it in Python (it needs the extensione module built):

from fast import fib

Build the extension module and compare slow and fast versions with timeit:

uv run nimlang build-ext fast.nim   # writes nimfib.<python-tag>.so (.pyd on Windows) next to it
uv run python -m timeit -s "from slow import fib" "fib(30)"   # 2 loops, best of 5: 135 msec per loop
uv run python -m timeit -s "from fast import fib" "fib(30)"   # 20 loops, best of 5: 10.6 msec per loop

How Nim and Nim dependencies are provided

The Nim compiler comes inside the nimlang wheel for your platform (Linux x86_64/aarch64, macOS arm64/x86_64, Windows x86_64). Each nimlang release bundles one Nim version, currently 2.2.6, along with atlas. uv run nim runs it with zig cc as the C compiler and with the project's Nim dependencies on the path:

uv run nim --version         # 2.2.6
uv run nim c -r hello.nim
uv run nimlang info          # which Nim and zig are used, and the project's Nim deps

On other platforms nimlang uses $NIMLANG_NIM_HOME or a nim on PATH. Choosing the Nim version per project is on the roadmap.

The C compiler is zig cc from the ziglang package, installed as a regular dependency.

Nim dependencies are declared in pyproject.toml, next to the Python ones, and pinned in a lock file, like uv does for Python packages:

[tool.nimlang]
dependencies = ["nimpy", "cligen >= 1.7"]
uv run nimlang add nimpy     # adds it to [tool.nimlang] and syncs
uv run nimlang remove nimpy  # removes it and syncs
uv run nimlang sync          # installs exactly what nimlang.lock pins
uv run nimlang lock          # resolves again to the newest allowed versions
  • nimlang.lock records the git URL and commit of every package, including transitive ones. Commit it, so every checkout and every wheel build uses the same code.
  • Packages are cloned with the bundled atlas into .nimlang/ (git-ignored), so git is needed. Builds through nimlang see only those packages, never ~/.nimble.
  • nimlang drives atlas for you: there is no atlas command, and nimble is not shipped. [tool.nimlang] and nimlang.lock are the only places dependencies are managed.

Ship Nim code in a Python package

disclosure: have not tested this yet

[build-system]
requires = ["hatchling", "nimlang"]
build-backend = "hatchling.build"

[tool.hatch.build.hooks.nimlang]
extensions = ["src/mypkg/nimcore.nim"]  # importable as mypkg.nimcore
binaries = ["src/mypkg/mytool.nim"]     # installed as the `mytool` command
# strip = false                         # keep debug symbols (stripped by default)

[tool.nimlang]
dependencies = ["nimpy"]

uv build produces a py3-none-<platform> wheel that works on every CPython 3 version. On Linux it is manylinux-compliant out of the box, and NIMLANG_TARGET=aarch64-macos uv build cross-builds for other platforms. See examples/hello-nim.

Building nimlang wheels

python scripts/make_wheels.py --nim-dist nim-2.2.6-linux_x64.tar.xz --platform-tag manylinux_2_17_x86_64

CI builds them for Linux (x86_64, aarch64), macOS (arm64, x86_64) and Windows x86_64, and publishes to PyPI when a v* tag is pushed.

Escape hatch: your own C compiler

If zig cc can't build something, NIMLANG_CC=system makes Nim use its default C compiler (gcc, clang or MSVC) instead. It is not tested in CI and cannot cross-compile, so it can't build wheels on Linux, where they always target glibc 2.17.

Metadata

Release files for nimlang 0.0.2

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

Source distribution (sdist)

Source distribution for nimlang 0.0.2
File Size Uploaded
nimlang-0.0.2.tar.gz 36.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for nimlang 0.0.2
File
nimlang-0.0.2-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
nimlang-0.0.2-py3-none-manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details
nimlang-0.0.2-py3-none-manylinux_2_17_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details
nimlang-0.0.2-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
nimlang-0.0.2-py3-none-macosx_10_13_x86_64.whl Python 3 none macOS 10.13+ x86-64 Details

Total release size: 46.4 MB

Release files / nimlang-0.0.2.tar.gz

Download URL nimlang-0.0.2.tar.gz
Size 36.3 kB
Tags Source
SHA-256 checksum
How to use checksums
589b719a74429387bf6ad2c2488fffb1c00f7e45a208480405f0c8072fb8d145
BLAKE2b-256 checksum
How to use checksums
11031ebe71ee95abacd3216361ee07fcefb93fa10848c803862a68167f637b4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 6, 2026.

Transparency log

Release files / nimlang-0.0.2-py3-none-win_amd64.whl

Download URL nimlang-0.0.2-py3-none-win_amd64.whl
Size 13.6 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
bf73bdca6cf98f860cc78f79a2ba71fa34d43d2e977c5e1cfc08c9d803fcba71
BLAKE2b-256 checksum
How to use checksums
491e9af93d58a13729dc6dd03e03ffd4ab8ebd430c48cac75386538b94ab9b95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 6, 2026.

Transparency log

Release files / nimlang-0.0.2-py3-none-manylinux_2_17_x86_64.whl

Download URL nimlang-0.0.2-py3-none-manylinux_2_17_x86_64.whl
Size 7.4 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
b21998cbb712577844f6e48ec4d0c8e141e399fd7aeb5eb181fcfc7b97c6223a
BLAKE2b-256 checksum
How to use checksums
29be8acc323220f3e828c37a5fb8d6977759e4ea2446f85c1da6fad3fcc6d429
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 6, 2026.

Transparency log

Release files / nimlang-0.0.2-py3-none-manylinux_2_17_aarch64.whl

Download URL nimlang-0.0.2-py3-none-manylinux_2_17_aarch64.whl
Size 16.1 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
fddd99b8d6df508e2553c9e27bb015f1b10804e425dd173017321c93ade9a183
BLAKE2b-256 checksum
How to use checksums
d921ef0a96db60c3dc52a3d45850ec9e2b81a46451bf2fe5901c98b648e7aeb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 6, 2026.

Transparency log

Release files / nimlang-0.0.2-py3-none-macosx_11_0_arm64.whl

Download URL nimlang-0.0.2-py3-none-macosx_11_0_arm64.whl
Size 4.5 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8e5a3644dc6718a4bcb09bcb15875b5a25614e42fdbb3ff0414da09ab9060da3
BLAKE2b-256 checksum
How to use checksums
fa869415bfc170760e9968bad9e1687d83e0be43f6f6e61e3fd0f583d20ca28c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 6, 2026.

Transparency log

Release files / nimlang-0.0.2-py3-none-macosx_10_13_x86_64.whl

Download URL nimlang-0.0.2-py3-none-macosx_10_13_x86_64.whl
Size 4.8 MB
Tags Python 3 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
a19b241f603ee2e68f937f69cfd1b591d6abd5c1de5b59147ef8d475eba58239
BLAKE2b-256 checksum
How to use checksums
eba7bbfcb6092f7861b862566cc8458c8690f93a8971e51fffe40c21fc0e0d24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 6, 2026.

Transparency log

Release history Release notifications | RSS feed

0.0.3

6 release files

This release

0.0.2 This release

6 release files

0.0.1

6 release files

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