Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Embedding Cython

Typically Cython is used to create extension modules for use from Python programs. It is, however, possible to write a standalone programs in Cython. This is done via embedding the Python interpreter with the --embed option.

Background

  • See also this email thread, and also more embedding discussion here and a script to "freeze" Cython modules (like Python freeze).
  • This page is derived from David McNab's idea for embedding Pyrex. The concepts there have been implemented in the --embed flag for Cython.

Status

This has been implemented--simply run cython with the --embed option and a .c file with a main method is created which sets its module name to __main__ (just as for normal executable Python scripts). Compile the .c file and link it against the Python library. Starting the resulting binary will then execute the module code.

A complete demo can be found at at https://github.com/cython/cython/tree/master/Demos/embed.

Something went wrong with that request. Please try again.