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.0b1.tar.gz (176.7 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.0b1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for hatch_simple_cython-0.1.0b1.tar.gz
Algorithm Hash digest
SHA256 6ceb9bc1eb4126798207ee7bab669df61060b5006f681ff4d0ee8c98442c0daa
MD5 1d0153b8e615876b696e6bf40c76d2ee
BLAKE2b-256 53f8f198e96de1860e58e41f89b6706af75269e5d4236a9208d16b50ae3bd498

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hatch_simple_cython-0.1.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 e0ebbf84d577cccec20bddfb3e050264e964af1bc404b2035cc1144c13f2cf83
MD5 825435b5617904e26103e47757570a56
BLAKE2b-256 2945da06b6f14bc3ff07d71511b6616c1f922c5514bc57e4ef47d2ae1b5169fd

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