Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
8b287aa9
Commit
8b287aa9
authored
Apr 30, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up compilation documentation
parent
152fa006
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
27 deletions
+9
-27
docs/src/reference/compilation.rst
docs/src/reference/compilation.rst
+9
-27
No files found.
docs/src/reference/compilation.rst
View file @
8b287aa9
...
...
@@ -34,7 +34,8 @@ system. Python documentation for writing extension modules should
have some details for your system. Here we give an example on a Linux
system::
$ gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing -I/usr/include/python2.5 -o yourmod.so yourmod.c
$ gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing \
-I/usr/include/python2.5 -o yourmod.so yourmod.c
[``gcc`` will need to have paths to your included header files and
paths to libraries you need to link with]
...
...
@@ -46,43 +47,25 @@ Compiling with ``distutils``
============================
First, make sure that ``distutils`` package is installed in your
system. The following assumes a Cython file to be compiled called
system. It normally comes as part of the standard library.
The following assumes a Cython file to be compiled called
*hello.pyx*. Now, create a ``setup.py`` script::
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [Extension("spam", ["spam.pyx"]),
Extension("ham", ["ham.pyx"])]
# You can add directives for each extension too
# by attaching the `pyrex_directives`
for e in ext modules:
e.pyrex_directives = {"boundscheck": False}
from Cython.Build import cythonize
setup(
name = "My hello app",
cmdclass = {"build_ext": build_ext},
ext_modules = ext_modules
ext_modules = cythonize('hello.pyx'), # accepts a glob pattern
)
Run the command ``python setup.py build_ext --inplace`` in your
system's command shell and you are done. Import your new extension
module into your python shell or script as normal.
Cython provides utility code to automatically generate lists of
Extension objects from ```.pyx`` files, so one can write::
from distutils.core import setup
from Cython.Build import cythonize
setup(
name = "My hello app",
ext_modules = cythonize("*.pyx"),
)
to compile all ``.pyx`` files in a given directory.
The ``cythonize`` command also allows for multi-threaded compilation and
dependency resolution.
dependency resolution. Recompilation will be skipped if the target file
is up to date with its main source file and dependencies.
Compiling with ``pyximport``
=============================
...
...
@@ -213,7 +196,6 @@ Cython code. Here is the list of currently supported directives:
setting from the module being compiled, unless they explicitly
set their own language level.
How to set directives
---------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment