1
1
Fork
You've already forked setuptools-zig-build
0
A setuptools extension, for building cpython extensions with zig build, enabling source-only pip distributions that compile at install time.
  • Python 50.9%
  • Zig 49.1%
2026年06月21日 20:24:58 +02:00
src upgrade the runner to zig 16 2026年06月21日 20:24:58 +02:00
.gitignore add zig code 2025年12月01日 19:41:43 +01:00
build.zig move addVersion from python-zon in here 2025年12月06日 00:29:50 +01:00
build.zig.zon upgrade to zig 0.16.0 2026年06月21日 16:10:23 +02:00
LICENSE add first code 2025年12月01日 19:22:51 +01:00
README.md move addVersion from python-zon in here 2025年12月06日 00:29:50 +01:00
setup.py upgrade to zig 0.16.0 2026年06月21日 16:10:23 +02:00
setuptools_zig_build.py add integration to store dependencies in sdist 2025年12月05日 19:17:22 +01:00

Setuptools zig build

A setuptools extension, for building cpython extensions with zig build, enabling simple source-only pip distributions that compile at install time. This is my take on deinventing the wheel

check out zig-zon for a full example.

Example

Your project needs to have:

  • setup.py to configure this setuptools extension to run during python's wheel build
  • build.zig to configure the build of the shared library
  • build.zig.zon optionally - to specify zig dependencies
from setuptools import Extension
from setuptools import setup
setup(
 name='zig-zon',
 packages=[],
 zig_build={
 # stores zig's depdendency pacakges in python's sdist. This requires a call to
 # CPython.addSdistList(b); in `build.zig`
 # If set to False, potential dependencies will be downloaded by zig instead.
 "sdist": True,
 # tries to import 'ziglang' to get a zig compiler when building wheel
 "use_ziglang_python_package": True,
 # passes -Doptimize= to zig build
 "optimize": "ReleaseSmall",
 # passes -Dversion=<pip package version> to zig build
 "pass_version_option": True,
 # extra arguments to zig build. In this case we pass the `install` and `test` steps
 'extra_args': [
 "install", "test",
 ],
 },
 # Names of the libraries your `build.zig` will produce, and this module will install
 ext_modules=[Extension('zig_zon', [])],
)

References

@ruamel and setuptools-zig