Thank you for your interest in contributing to pyz3!
-
Clone the repository
git clone https://github.com/pyz3-project/pyz3.git cd pyz3 -
Install dependencies (using uv)
uv sync # or using make make install -
Run tests
make test-all # or uv run pytest test/
Some files are auto-generated and should not be committed:
pyz3.build.zig- Auto-generated frompyz3/src/pyz3.build.zig- Automatically created when you run any build command
- Listed in
.gitignore - If missing, run any build command to regenerate it
Don't worry if you see this error:
error: unable to load 'pyz3.build.zig': FileNotFound
Solution: Just run any build command:
uv sync
# or
make installThe file will be auto-generated and the error will disappear.
When adding new dependencies to pyproject.toml:
-
Add the dependency
uv add <package-name>
-
Sync the environment
uv sync
-
Commit changes
git add pyproject.toml uv.lock git commit -m "Add <package-name> dependency"
We provide convenient make targets for common tasks:
make test- Run Python testsmake test-zig- Run Zig testsmake test-all- Run all tests
make build- Build packagemake clean- Clean build artifactsmake install- Install in development modemake sync- Sync dependenciesmake stubs- Generate Python stub files (.pyi)make check-stubs- Verify stub files are up to date
make lint- Run ruff lintermake format- Format code with ruff
-
Run all tests
make test-all
-
Check code formatting
make lint
-
Format code if needed
make format
-
Update stub files if Zig modules changed
make stubs
Install pre-commit hooks for automatic checks:
uv pip install pre-commit
pre-commit installUpdate stub files (.pyi) when you:
- Add new Zig extension modules
- Add/modify/remove public functions in Zig modules
- Change function signatures in Zig modules
How to update:
make stubs
git add example/*.pyi
git commit -m "Update stub files"Verify stubs are current:
make check-stubsWe follow a conventional commit style:
<type>: <description>
[optional body]
[optional footer]
Types:
feat:- New featurefix:- Bug fixdocs:- Documentation changeschore:- Maintenance taskstest:- Test additions or fixesrefactor:- Code refactoring
Example:
feat: Add NumPy integration
- Added numpy wrapper module
- Created comprehensive test suite
- Updated documentation
Closes #123
-
Fork the repository and create a new branch
git checkout -b feature/my-new-feature
-
Make your changes and commit them
git commit -m "feat: Add my new feature" -
Ensure all tests pass
make test-all
-
Push to your fork and create a Pull Request
git push origin feature/my-new-feature
-
Wait for CI to pass - All tests must pass before merge
Our CI pipeline automatically:
- Runs all tests on Python 3.11, 3.12, 3.13
- Tests on Ubuntu and macOS
- Checks code formatting with ruff
- Builds the package
- Generates documentation
pyz3/
├── pyz3/ # Python package
│ ├── src/ # Zig source code
│ │ ├── pyz3.zig # Main module exports
│ │ ├── types/ # Python type wrappers
│ │ └── ...
│ ├── __init__.py # Package metadata
│ ├── config.py # Configuration loader
│ ├── buildzig.py # Build system
│ └── ...
├── example/ # Example Zig modules
├── test/ # Python tests
├── docs/ # Documentation
└── pyproject.toml # Project configuration
- Check TODO.md for known issues and planned features
- Open an issue for bugs or feature requests
- Read the documentation at the repository
By contributing to pyz3, you agree that your contributions will be licensed under the Apache 2.0 License.