Support the ziglang python package
Brought to you by:
anthon
Hi anthon,
could this (optionally) support the Ziglang Python Package,
instead of setting PY_ZIG on the environment?
Hi Tobias,
I somehow missed that the Zig compiler package (
ziglang) had been uploaded to PyPI when I made the 0.2.0 release. I have considered this before, but never got to a decision, primarily because I don't want to force people to installziglangto every virtual environment, if they already have the file somewhere global.Reconsidering this, making the package optional is probably the way to go (i.e.
pip install setuptools-zig[ziglang])setuptools-zig[ziglang]as a requirement and get a matching compiler (e.g.ziglang==0.10.1.post1forsetuptools-zig==0.2.1)zigfails, erroring while displaing the message to runpip install setuptools-zig[ziglang]/opt/zig/{0.10.1,0.11.0,...,0.15.2}) that the latest patch version of the required major.minor version matching thesetuptools-zigis used.I should also make sure things are working with the latest version (and maybe intermediate versions between 0.10 and 0.15, depending on the amount of work) as well.
So thanks for reminding, and and feel free to comment on the above approach. Are you using setuptools-zig in some package?
Hi,
I have done some testing, and would prefer not to couple
ziglangandsetuptools-zigversions tightly.Rather leave it to the consuming package and have it as a separate
build-dependency next to it.
So my idea was to add a boolean option on the
build_zigconfig to usewhatever version is installed alongside setuptools-zig and keep the PY_ZIG
usage the default.
Something like this:
dasimmet / setuptools-zig - Code / [5d9822] /setuptools_zig.py
https://sourceforge.net/u/dasimmet/setuptools-zig/ci/default/tree/setuptools_zig.py#l31
zig 0.15.2 is not out on pypi yet, i raised a ticket there, to have it
added.
Also at some point @cInclude will be removed from the zig language, at that
point it would make sense to support
build.zigor havezig translate-crun separately
I'm looking into creating a lib to parse zig's
.zoninto pythondictionaries, but i'm new to native python extension amd its not published
yet.
Am Di., 11. Nov. 2025 um 09:47 Uhr schrieb Anthon van der Neut anthon@users.sourceforge.net:
Related
Tickets: #3
I have been working on this, making sure Python 3.9-3.14 work with the examples and wilth Zig 0.11-0.15, which it now does.
Since all the combinations work, and I don't have to have a specific version of
zigwith a specificsetuptools-zig(or vv.), I decided against the optional extension for now. A user has to specify the build dependency anyway and it doesn't really differ to have:instead of
and with the former you can easily do
'ziglang<0.15', if you program requires that.The way I implemented the (minor) changes to
setuptools-zigby trying toimport ziglangand if that works add the path of the loaded module tosys.path(and toos.environ['PATH']as well, just in case).Now I still have to check the
sum.candc_int.c+sum.zigin the README need updating. Once the readme is done I'll post a new version.As for parsing
.zonfiles, I am not even sure if the zig code for that is a library. If it does and has a not to complex list internal datastructures, it may be possible to "wrap" each of this with aPyObject.