https://github.com/mkashirin/pyzig
Create Python native extensions using Zig and Python C API!
https://github.com/mkashirin/pyzig
c-python-extensions python python-c-api zig
Last synced: about 2 months ago
JSON representation
Create Python native extensions using Zig and Python C API!
- Host: GitHub
- URL: https://github.com/mkashirin/pyzig
- Owner: mkashirin
- Created: 2024-12-05T13:32:06.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-02-16T21:39:41.000Z (3 months ago)
- Last Synced: 2026-03-27T23:42:00.321Z (about 2 months ago)
- Topics: c-python-extensions, python, python-c-api, zig
- Language: Zig
- Homepage:
- Size: 50.8 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
PyZig
Create Python native extensions using Zig and Python C API!
## Usage
First, create and activate a virtual environment and install dev dependencies
(using UV and bash):
```sh
uv venv
source .venv/bin/activate
uv pip install -r pyproject.toml --extra dev
```
### Manual Build and Installation
Then build a shared library file by executing:
```sh
zig build
```
The Python package can be now built and installed like so (using UV):
```sh
uv build
uv pip install .
```
### Automated Build and Installation
Use `ZIG_INSTALLED` environment variable to specify what type of Zig compiler
to use (unset is for Python Zig module, 1 is for system-wide installed
binary). Then create and activate a virtual environment (example above). After
that, run the build shell script:
```sh
source install.sh
```
### Testing
Once the installation is complete, the test can be run as follows:
```sh
python tests/test_zigmodule.py
```
Have fun!
## TODOs
- Generate stubs automatically
- Build some Zig API for more convinient interaction with Python C API.