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.0b3.tar.gz (126.4 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.0b3-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for hatch_simple_cython-0.1.0b3.tar.gz
Algorithm Hash digest
SHA256 83ca4a49e875af7c24e5ff87faa77ae842ce3e56bdf4468b28025dd6b49f9601
MD5 1d421cfdcdbb90e7af0ee68926097cfa
BLAKE2b-256 ad1b0c930cfceba69e717561665bdf51647811d91e2d8a1656460bd5686bc8ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hatch_simple_cython-0.1.0b3-py3-none-any.whl
Algorithm Hash digest
SHA256 52d198e6253232adc6192ce3be82c4facbd37f585e3bf513ddad73f1926870bd
MD5 ba4357bbbca3e348ac6e6fddc098833f
BLAKE2b-256 a16781f37d696570f3b63e7ee89b71519ab8e7b968d20c3249c148da01429817

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