Packaging Zig as Python packages

Rust has a fantastic tool in maturin GitHub - PyO3/maturin: Build and publish crates with pyo3, cffi and uniffi bindings as well as rust binaries as python packages in order to write libraries in Rust but provide them as Python packages.

This is being used with great success by the Ruff / uv projects GitHub - astral-sh/ruff: An extremely fast Python linter and code formatter, written in Rust.

It’s fantastic since this allows your library to reach out users that otherwise wouldn’t use them. Is there anything similar for zig?

Zig already provides cross-compilation to multiple targets, so for executables this seems like a simpler problem to solve as you just need to package different executables for each target you want to support (?) but for libraries the problem seeems a bit more difficult.

Does anyone know of already existing tools? Or how easy it would be to implement something similar?

Note: interesting talk https://www.youtube.com/watch?v=O0MmmZxdct4

1 Like

I think you’re looking for Ziggy Pydust: Ziggy Pydust

Edit: seems like it won’t work with zig 0.13 just yet, due to changes in zig

Zig is available on PyPi.
See also: The Python Package Index Should Get Rid Of Its Training Wheels

1 Like

More information:

I think you are confused here. The author mentions creating Python packages written in Zig. But the title is very confusing in terms of his intent.

1 Like

His comment was incredibly useful as it led me down the path of discovering cargo-zigbuild + setuptools-rust projects, which do similar things to what I want.

Also the project he linked ends up in the zig-pypi GitHub - ziglang/zig-pypi: The Zig programming language, packaged for PyPI repository which is another repository that packages a zig project into python, in this case, the whole programming language.

3 Likes