A simplified Cython build hook plugin for Hatch
Project description
hatch-simple-cython
A minimalist Hatch plugin for building Cython extensions, optimized for uv projects.
Features
- Zero-config - Auto-discovers and compiles
.pyxfiles - Simple - Focused on core functionality without complex configuration
- Full Cython support - Compiler directives, include directories, and linking options
- uv-friendly - Perfect integration with uv workflow
Installation
uv add --dev hatch-simple-cython
Quick Start
Add to your pyproject.toml:
[build-system]
requires = ["hatchling", "hatch-simple-cython", "Cython>=3.0.0", "setuptools"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel.hooks.simple-cython]
That's it! The plugin will automatically discover and compile your .pyx files.
Configuration
Basic Example
[tool.hatch.build.targets.wheel.hooks.simple-cython]
directives = { language_level = "3", boundscheck = false }
compile_args = ["-O3"]
include_dirs = ["include"]
compile_py = false # Only compile .pyx files by default
NumPy Support
[tool.hatch.build.targets.wheel.hooks.simple-cython]
include_numpy = true
All Options
| Option | Type | Default | Description |
|---|---|---|---|
directives |
dict | {language_level: 3} |
Cython compiler directives |
compile_args |
list[str] | ["-O2"] |
Compiler arguments |
link_args |
list[str] | [] |
Linker arguments |
include_dirs |
list[str] | [] |
Include directories |
libraries |
list[str] | [] |
Libraries to link |
library_dirs |
list[str] | [] |
Library search directories |
define_macros |
list | [] |
Preprocessor macro definitions |
compile_py |
bool | false |
Compile .py files |
include_numpy |
bool | false |
Include NumPy headers |
cythonize_kwargs |
dict | {} |
Additional cythonize() kwargs |
Examples
See the examples/ directory for complete example projects:
pure_python/- Compiling.pyfiles to binary extensionssimple_example/- Basic Cython usage with.pyxfilesnumpy_example/- Cython with NumPy integration
MIT License
See LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hatch_simple_cython-0.1.0b2.tar.gz.
File metadata
- Download URL: hatch_simple_cython-0.1.0b2.tar.gz
- Upload date:
- Size: 178.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a323352ef6938cdbff0948ebe4e9f1d4d1a2fa23936db337e76a5ca64d057e95
|
|
| MD5 |
a25d3c187a7e72cd752e629962131942
|
|
| BLAKE2b-256 |
6cdb52a01934791b7fb1e5f2cfbb246365f5bd966cd5bd5faa6a1b5f2c3ef7bc
|
File details
Details for the file hatch_simple_cython-0.1.0b2-py3-none-any.whl.
File metadata
- Download URL: hatch_simple_cython-0.1.0b2-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2766c8dd4c17bf37eb86c11eb68b334b485f10363f9217e56b408c32316ca4a7
|
|
| MD5 |
ada560df01752bb719d688cb26d4ea96
|
|
| BLAKE2b-256 |
26738fd3e945de5b180246f3f2a4c483882f24ddd57c16e2660b74681035cee3
|