Skip to main content

A setuptools extension, for building cpython extensions with zig build

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

setuptools_zig_build-0.2.2.tar.gz (4.8 kB view details)

Uploaded Source

File details

Details for the file setuptools_zig_build-0.2.2.tar.gz.

File metadata

  • Download URL: setuptools_zig_build-0.2.2.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for setuptools_zig_build-0.2.2.tar.gz
Algorithm Hash digest
SHA256 7928746548818aba9f076cfff9a16127cb0fca3365a2a7fd5a4dac0951f13a46
MD5 e4756494631ee59d93f3c681fa9ceb6c
BLAKE2b-256 25b7100b58a630a854c3256e23b6a3436f6d5ddabc37080ae322861d0acc3fa9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page