Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 76 lines (52 sloc) 2.648 kb
90b64b5 @williamstein More Pyrex/SageX --> Cython changes
williamstein authored
1 Cython - Usage Instructions
c4fa206 @williamstein Initial version
williamstein authored
2 ==========================
3
90b64b5 @williamstein More Pyrex/SageX --> Cython changes
williamstein authored
4 Building Cython extensions using distutils
c4fa206 @williamstein Initial version
williamstein authored
5 -----------------------------------------
6
90b64b5 @williamstein More Pyrex/SageX --> Cython changes
williamstein authored
7 Cython comes with an experimental distutils extension for compiling
8 Cython modules, contributed by Graham Fawcett of the University of
c4fa206 @williamstein Initial version
williamstein authored
9 Windsor (fawcett@uwindsor.ca).
10
11 The Demos directory contains a setup.py file demonstrating its use. To
12 compile the demos:
13
14 (1) cd Demos
15
16 (2) python setup.py build_ext --inplace
17
18 or
19
20 python setup.py build --build-lib=.
21
22 (You may get a screed of warnings from the C compiler, but you can
23 ignore these -- as long as there are no actual errors, things are
24 probably okay.)
25
26 Try out the extensions with:
27
28 python run_primes.py
29 python run_spam.py
30 python run_numeric_demo.py
31
32
90b64b5 @williamstein More Pyrex/SageX --> Cython changes
williamstein authored
33 Building Cython extensions by hand
c4fa206 @williamstein Initial version
williamstein authored
34 ---------------------------------
35
90b64b5 @williamstein More Pyrex/SageX --> Cython changes
williamstein authored
36 You can also invoke the Cython compiler on its own to translate a .pyx
c4fa206 @williamstein Initial version
williamstein authored
37 file to a .c file. On Unix,
38
90b64b5 @williamstein More Pyrex/SageX --> Cython changes
williamstein authored
39 cython filename.pyx
c4fa206 @williamstein Initial version
williamstein authored
40
41 On other platforms,
42
90b64b5 @williamstein More Pyrex/SageX --> Cython changes
williamstein authored
43 python cython.py filename.pyx
c4fa206 @williamstein Initial version
williamstein authored
44
45 It's then up to you to compile and link the .c file using whatever
46 procedure is appropriate for your platform. The file
47 Makefile.nodistutils in the Demos directory shows how to do this for
48 one particular Unix system.
49
50
51 Command line options
52 --------------------
53
90b64b5 @williamstein More Pyrex/SageX --> Cython changes
williamstein authored
54 The cython command supports the following options:
c4fa206 @williamstein Initial version
williamstein authored
55
56 Short Long Argument Description
57 -----------------------------------------------------------------------------
90b64b5 @williamstein More Pyrex/SageX --> Cython changes
williamstein authored
58 -v --version Display version number of cython compiler
c4fa206 @williamstein Initial version
williamstein authored
59 -l --create-listing Write error messages to a .lis file
f6762fa @robertwb Remove trailing whitespace.
robertwb authored
60 -I --include-dir <directory> Search for include files in named
90b64b5 @williamstein More Pyrex/SageX --> Cython changes
williamstein authored
61 directory (may be repeated)
c4fa206 @williamstein Initial version
williamstein authored
62 -o --output-file <filename> Specify name of generated C file (only
90b64b5 @williamstein More Pyrex/SageX --> Cython changes
williamstein authored
63 one source file allowed if this is used)
64 -p, --embed-positions If specified, the positions in Cython files of each
65 function definition is embedded in its docstring.
66 -z, --pre-import <module> If specified, assume undeclared names in this
67 module. Emulates the behavior of putting
68 "from <module> import *" at the top of the file.
c4fa206 @williamstein Initial version
williamstein authored
69
90b64b5 @williamstein More Pyrex/SageX --> Cython changes
williamstein authored
70
71 Anything else is taken as the name of a Cython source file and compiled
72 to a C source file. Multiple Cython source files can be specified
c4fa206 @williamstein Initial version
williamstein authored
73 (unless -o is used), in which case each source file is treated as the
74 source of a distinct extension module and compiled separately to
75 produce its own C file.
Something went wrong with that request. Please try again.