Skip to main content

a native cpython extension to parse zig object notation strings

Project description

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 pypi:

pip install zig-zon

running:

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

or, look at the test file

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.

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

zig_zon-0.2.1.tar.gz (12.5 kB view details)

Uploaded Source

File details

Details for the file zig_zon-0.2.1.tar.gz.

File metadata

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

File hashes

Hashes for zig_zon-0.2.1.tar.gz
Algorithm Hash digest
SHA256 10408c8cb995e61c63d1b06902e33f438a59cc1e439371ae8e9f541d92f633b6
MD5 6013e9a28be2d4c3f73c23c4f00e839d
BLAKE2b-256 5bfaeed06f564509d911c9df832d423e92c0767bc42542b7019722a4f8945316

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