Skip to main content

Cython setuptools integration

Project description

cython-setuptools

Build Status

Easier distribution and development of Cython modules.

Features:

  • 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)

Installation

$ pip install cython-setuptools

Usage

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 setup.py.

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

Then use cython-setuptools' setup() in your setup.py:

from cysetuptools import setup

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.

[metadata]
name = your-python-project
version = 1.0

[options]
packages = find:
install_requires = cython

[options.extras_require]
dev = cython

[cython-defaults]
include_dirs = include/

[cython-module: foo.bar]
sources = foo.pyx
          bar.cpp
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 setup.py 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 setup.py 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.2.tar.gz (6.9 kB view details)

Uploaded Source

File details

Details for the file cython-setuptools-0.2.2.tar.gz.

File metadata

  • Download URL: cython-setuptools-0.2.2.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/2.7.17

File hashes

Hashes for cython-setuptools-0.2.2.tar.gz
Algorithm Hash digest
SHA256 8977527e01e5712fbbe47fb0aa83cb0f363669491c19bfbb9e87d3681b744b83
MD5 3e86ad461eb28af9368de760c8d0c701
BLAKE2b-256 28fb56df5252f8e6e41432826d2a86d4406c422eb49393c1551351421450479e

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