Skip to main content

A simplified Cython build hook plugin for Hatch

Project description

hatch-simple-cython

PyPI - Version PyPI - Python Version GitHub GitHub Workflow Status

A minimalist Hatch plugin for building Cython extensions, optimized for uv projects.

Features

  • Zero-config - Auto-discovers and compiles .pyx files
  • 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 .py files to binary extensions
  • simple_example/ - Basic Cython usage with .pyx files
  • numpy_example/ - Cython with NumPy integration

MIT License

See LICENSE file for details.

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

hatch_simple_cython-0.1.0b2.tar.gz (178.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hatch_simple_cython-0.1.0b2-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file hatch_simple_cython-0.1.0b2.tar.gz.

File metadata

File hashes

Hashes for hatch_simple_cython-0.1.0b2.tar.gz
Algorithm Hash digest
SHA256 a323352ef6938cdbff0948ebe4e9f1d4d1a2fa23936db337e76a5ca64d057e95
MD5 a25d3c187a7e72cd752e629962131942
BLAKE2b-256 6cdb52a01934791b7fb1e5f2cfbb246365f5bd966cd5bd5faa6a1b5f2c3ef7bc

See more details on using hashes here.

File details

Details for the file hatch_simple_cython-0.1.0b2-py3-none-any.whl.

File metadata

File hashes

Hashes for hatch_simple_cython-0.1.0b2-py3-none-any.whl
Algorithm Hash digest
SHA256 2766c8dd4c17bf37eb86c11eb68b334b485f10363f9217e56b408c32316ca4a7
MD5 ada560df01752bb719d688cb26d4ea96
BLAKE2b-256 26738fd3e945de5b180246f3f2a4c483882f24ddd57c16e2660b74681035cee3

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