Skip to main content

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

Metadata

Release files for setuptools-zig-build 0.3.1

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

Source distribution (sdist)

Source distribution for setuptools-zig-build 0.3.1
File Size Uploaded Provenance Actions
setuptools_zig_build-0.3.1.tar.gz 4.8 kB Without provenance Details for setuptools_zig_build-0.3.1.tar.gz

Release files / setuptools_zig_build-0.3.1.tar.gz

Download URL setuptools_zig_build-0.3.1.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8312aa6b3ae704f5e229b5a4e65086c57199884ec77bb191b00ffd3dc5d071fe
BLAKE2b-256 checksum
How to use checksums
d00a5b7dfc5122f204729bc1b0cd23fa6b0c0978aa016fd0a153b0db189f0a7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for setuptools-zig-build 0.3.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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