Scroll to navigation

CYTHON(1) User Commands CYTHON(1)

NAME

cython - compile Cython code (.pyx) into C to build a Python extension

DESCRIPTION

usage: cython [-h] [-V] [-l] [-I INCLUDE_PATH] [-o OUTPUT_FILE] [-t] [-f] [-v]

[-p] [--cleanup GENERATE_CLEANUP_CODE] [--cache] [-w WORKING_PATH] [--gdb] [--gdb-outdir GDB_OUTDIR] [-D] [-a] [--annotate-fullc] [--annotate-coverage ANNOTATE_COVERAGE_XML] [--line-directives] [-+] [--embed] [-2] [-3] [--3str] [--lenient] [--capi-reexport-cincludes] [--fast-fail] [-Werror] [-Wextra] [-X NAME=VALUE,...] [-E NAME=VALUE,...] [--module-name MODULE_NAME] [-M] [--generate-shared SHARED_C_FILE_PATH] [--shared SHARED_UTILITY_QUALIFIED_NAME] [sources ...]

Cython (https://cython.org/) is a compiler for code written in the Cython language. Cython is based on Pyrex by Greg Ewing.

positional arguments:

sources

options:

show this help message and exit
Display version number of cython compiler
Write error messages to a listing file
Search for include files in named directory (multiple include directories are allowed).
Specify name of generated C file
Only compile newer source files
Compile all source files (overrides implied -t)
Be verbose, print file names on multiple compilation
If specified, the positions in Cython files of each function definition is embedded in its docstring.
Release interned objects on python exit, for memory debugging. Level indicates aggressiveness, default 0 releases nothing.
Enables Cython compilation cache.
Sets the working directory for Cython (the directory modules are searched from)
Output debug information for cygdb
Specify gdb debug information output directory. Implies --gdb.
Strip docstrings from the compiled module.
Produce a colorized HTML version of the source.
Produce a colorized HTML version of the source which includes entire generated C/C++-code.
Annotate and include coverage information from cov.xml.
Produce #line directives pointing to the .pyx source
-+, --cplus
Output a C++ rather than C file.
Generate a main() function that embeds the Python interpreter. Pass --embed=<method_name> for a name other than main().
-2
Compile based on Python-2 syntax and code semantics.
-3
Compile based on Python-3 syntax and code semantics.
--3str
Compile based on Python-3 syntax and code semantics (same as -3 since Cython 3.1).
Change some compile time errors to runtime errors to improve Python compatibility
Add cincluded headers to any auto-generated header files.
Abort the compilation on the first error
Make all warnings into errors
Enable extra warnings
Overrides a compiler directive
Provides compile time env like DEF would do.
Fully qualified module name. If not given, is deduced from the import path if source file is in a package, or equals the filename otherwise.
produce depfiles for the sources
Generates shared module with specified name.
Imports utility code from shared module specified by fully qualified module name.

Environment variables:

CYTHON_CACHE_DIR: the base directory containing Cython's caches.
October 2025 Cython 3.1.6