Skip to main content

Cython setuptools integration

Project description


Build Status

Easier distribution and development of Cython modules.


  • Two distribution models: with C/C++ files included in the package, and without
  • Cython modules are defined in setup.cfg
  • Install directly from Cython sources, without installing Cython in the target environment (Cython is only included in install_requires)


$ pip install cython-setuptools


Here is an example Python package using the default distribution model (only Cython files are included in the source package).

First install the cython-setuptools vendor module in the package, next to

$ cd your-python-project/
$ cython-setuptools install

Then use cython-setuptools' setup() in your

from cysetuptools import setup


Note that we keep the default cythonize=True argument of setup() here, meaning that C files are compiled from Cython files automatically. setup(cythonize=False) would mean we would need to distribute the C/C++ files compiled from Cython in the source package.

Define your Cython modules in setup.cfg.

name = your-python-project
version = 1.0

packages = find:
install_requires = cython

dev = cython

include_dirs = include/

sources = foo.pyx
include_dirs = eval(__import__('numpy').get_include())
language = c++
pkg_config_packages = opencv

Then your Cython modules can be compiled and tested in-place with:

$ python build_ext --inplace

This automatically compile outdated Cython files. If setup(cythonize=False) is used, you have to specifically tell the setup to recompile outdated Cython files:

$ CYTHONIZE=1 python build_ext --inplace

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

cython-setuptools-0.2.3.tar.gz (6.9 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page