skillfed

hatch-cython

Cython build hooks for hatch

hatch-cython v0.6.0 198.4K downloads/30d#9,734 on PyPI37
Permissive license MIT Active released

What it is and what it does

hatch-cython is a Hatch build backend plugin that automates Cython compilation during wheel builds. It acts as a bridge between Hatch's modern build system and Cython's C extension compilation, handling the configuration and invocation of the Cython compiler as part of the standard Python package build process.

The plugin supports integration with scientific libraries (NumPy, PyArrow, Pythran) by resolving their include paths and libraries at build time. It exposes Cython compiler directives, custom compilation arguments, and macro definitions through pyproject.toml or hatch.toml configuration, eliminating the need for custom setup.py scripts. The package requires Cython, hatchling, setuptools, and typing-extensions as runtime dependencies.

Use it for:

  • Building Python packages with Cython-compiled modules using Hatch as the build backend.
  • Integrating NumPy or PyArrow headers and libraries into Cython extensions without manual path configuration.
  • Configuring Cython compiler directives (boundscheck, nonecheck, language_level) declaratively in pyproject.toml.
  • Compiling performance-critical code sections to C while maintaining a pure-Python package structure.
  • Creating wheels with C extensions for multiple Python versions (3.8–3.13) via a single build configuration.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

A Hatch build hook that integrates Cython compilation into the wheel build process, handling C extension compilation with support for NumPy, PyArrow, and other library includes.

Yes, if you are building Cython extensions with Hatch. The plugin is actively maintained, has low install friction, and eliminates boilerplate setup.py code. It is not needed if you are not using Cython or are using a different build backend. Be aware that build-time dependencies (Cython, setuptools, and any library includes) must be explicitly listed in build-system.requires.

Install

hatch-cython on PyPI

pip

pip install hatch-cython

uv

uv add hatch-cython

poetry

poetry add hatch-cython

Installing hatch-cython

Before you install

Low install friction; pure Python wheel with four runtime dependencies (cython, hatchling, setuptools, typing-extensions). Actively maintained with recent commits and passing CI/CD.

License in practice

MIT license permits commercial and private use with minimal restrictions; suitable for most projects.

Quickstart

# Add to pyproject.toml [build-system]
requires = ["hatchling", "hatch-cython", "Cython", "setuptools"]
build-backend = "hatchling.build"

# Configure in [tool.hatch.build.targets.wheel.hooks.cython.options]
[tool.hatch.build.targets.wheel.hooks.cython.options]
directives = { language_level = 3 }

Cython and setuptools must be in build-system.requires at load time, not just as hook dependencies; additional packages (numpy, pyarrow, etc.) required in build-system.requires if their include paths are used.

Verify before relying

  • Whether the hook automatically discovers .pyx/.pxd files or requires explicit file configuration.
  • Performance overhead or build-time impact compared to setuptools-only Cython builds.
  • Compatibility with editable installs and development workflows.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 4 — cython, hatchling, setuptools, typing-extensions
Maintenance actively maintained — 239 days since the last release
Last repo commit
First released
Downloads 198,359/month — #9,734 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: hatch_cython-0.6.0-py3-none-any.whl

Development Status :: 4 - BetaLicense :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Build ToolsTopic :: Software Development :: Code GeneratorsTopic :: Software Development :: Compilers

Tags

cython build hook hatchcompile cython extensions hatchc extension build toolhatch cython integrationpython c extension builder
cythonbuild-backendc-extensions

More Build Tools packages