Commit d41a072d authored by gabrieldemarmiesse's avatar gabrieldemarmiesse

Typos and added a note concerning the paths when using the distutils directives.

parent 1345bdd8
import rect
x0, y0, x1, y1 = 1, 2, 3, 4
rect_obj = rect.PyRectangle(x0, y0, x1, y1)
print(dir(rect_obj))
......@@ -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 objects 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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment