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
d41a072d
Commit
d41a072d
authored
Jun 15, 2018
by
gabrieldemarmiesse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Typos and added a note concerning the paths when using the distutils directives.
parent
1345bdd8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
12 deletions
+18
-12
docs/examples/userguide/wrapping_CPlusPlus/example_usage.py
docs/examples/userguide/wrapping_CPlusPlus/example_usage.py
+0
-6
docs/src/userguide/wrapping_CPlusPlus.rst
docs/src/userguide/wrapping_CPlusPlus.rst
+18
-6
No files found.
docs/examples/userguide/wrapping_CPlusPlus/example_usage.py
deleted
100644 → 0
View file @
1345bdd8
import
rect
x0
,
y0
,
x1
,
y1
=
1
,
2
,
3
,
4
rect_obj
=
rect
.
PyRectangle
(
x0
,
y0
,
x1
,
y1
)
print
(
dir
(
rect_obj
))
docs/src/userguide/wrapping_CPlusPlus.rst
View file @
d41a072d
...
...
@@ -174,13 +174,19 @@ To compile a Cython module, it is necessary to have a :file:`setup.py` file:
.. literalinclude:: ../../examples/userguide/wrapping_CPlusPlus/setup.py
Run ``$python setup.py build_ext --inplace``
Run ``$
python setup.py build_ext --inplace``
Create :file:`test_import.py`
:
To test it, open the Python interpreter:
:
.. literalinclude:: ../../examples/userguide/wrapping_CPlusPlus/example_usage.py
>>> import rect
>>> x0, y0, x1, y1 = 1, 2, 3, 4
>>> rect_obj = rect.PyRectangle(x0, y0, x1, y1)
>>> print(dir(rect_obj))
['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__',
'__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__',
'__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__',
'__setstate__', '__sizeof__', '__str__', '__subclasshook__', 'get_area', 'get_size', 'move']
You can now test your wrapper with ``$python test_import.py``.
Advanced C++ features
======================
...
...
@@ -591,7 +597,7 @@ possible to declare them in the :file:`setup.py` file::
Cython will generate and compile the :file:`rect.cpp` file (from
:file:`rect.pyx`), then it will compile :file:`Rectangle.cpp`
(implementation of the ``Rectangle`` class) and link both object
s
files
(implementation of the ``Rectangle`` class) and link both object files
together into :file:`rect.so`, which you can then import in Python using
``import rect`` (if you forget to link the :file:`Rectangle.o`, you will
get missing symbols while importing the library in Python).
...
...
@@ -635,6 +641,12 @@ any source code, to compile it in C++ mode and link it statically against the
# distutils: language = c++
# distutils: sources = Rectangle.cpp
.. note::
When using distutils directives, the paths are relative to the working
directory of the distutils run (which is usually the
project root where the :file:`setup.py` resides).
To compile manually (e.g. using ``make``), the ``cython`` command-line
utility can be used to generate a C++ ``.cpp`` file, and then compile it
into a python extension. C++ mode for the ``cython`` command is turned
...
...
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