Skip to main content

Python Zig Zon Parser

A native python extension built with zig to parse zig-object-notation strings into python objects.

On PyPi it is only distributed in source, and built during install. It therefore needs to download the ziglang python package.

Depending on your OS, you may need the python development headers (e.g. python3-dev) installed.

Usage

install from source on https://pypi.org/project/zig-zon:

pip install zig-zon

running:

>>> import zig_zon
>>> parsed = zig_zon.parse('.{.allyourcode = .are_belong_to_us, .asd = 123}')
>>> print(parsed)
{'allyourcode': 'are_belong_to_us', 'asd': 123}

or, look at the test file

Supported values and their python type

  • structs -> dict
  • tuples -> list
  • integer literals -> int
  • hex literals -> int
  • float literals -> float
  • booleans -> bool
  • null -> None
  • string literals -> str
  • bare enum literals -> str
  • quoted enum literals -> str

Not supported values

  • bigint

How it works

The zig build commands produces a python source distribution archive ready for uploading to Pypi. It includes the sources of zig-python-sdist and a custom setup.py that handles the build of the cpython extension.

When you run pip install, the source distribution is downloaded, and since this source distribution depends on the ziglang python package at build time, a zig build command is used to compile the extension.

Developing

as opposed to other solutions for building cpython extensions in zig, i want to develop this using:

zig build

for linking against the local python installation zig-python-sdist runs a python script that imports the cpython headers into zig's build cache, run translate-c on the result and offers a cpython module to import in our zig code. On windows, the extension library is also linked against the python runtime static lib and renamed to a .pyd file for importing.

Metadata

Release files for zig-zon 0.2.6

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

Source distribution (sdist)

Source distribution for zig-zon 0.2.6
File Size Uploaded Provenance Actions
zig_zon-0.2.6.tar.gz 27.5 kB Without provenance Details for zig_zon-0.2.6.tar.gz

Release files / zig_zon-0.2.6.tar.gz

Download URL zig_zon-0.2.6.tar.gz
Size 27.5 kB
Tags Source
SHA-256 checksum
How to use checksums
464e66f0f4710f76edd40f10553708185ad26ee2b8b59ef8e4754d3ce79f4a45
BLAKE2b-256 checksum
How to use checksums
07c8ffb08d22a840cb89d641ccb5388d2acfcc68ac52fb6be1681df153c5e5d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for zig-zon 0.2.6

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