You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/sphinx/source/cpp_and_numpy.rst
+97
Original file line number
Diff line number
Diff line change
@@ -188,3 +188,100 @@ Supposing you have laid out your source code in the following fashion::
188
188
This is a hybrid of the above and typical for CPython C++ extensions where ``module.c`` contains the CPython code that allows Python to access the pure C++ code.
189
189
190
190
The code in ``class.h`` and ``class.cpp`` is unchanged and the code in ``module.c`` is essentially the same as that of a CPython module as described above where ``import_array()`` is called from within the ``PyInit_<module>`` function.
191
+
192
+
193
+
How These Macros Work Together
194
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
195
+
196
+
The two macros ``PY_ARRAY_UNIQUE_SYMBOL`` and ``NO_IMPORT_ARRAY`` work together as follows:
If you are linking to the system Python this may not have numpy installed, here is a way to cope with that. Create a virtual environment from the system python and install numpy:
220
+
221
+
.. code-block:: bash
222
+
223
+
python -m venv <PATH_TO_VIRTUAL_ENVIRONMENT>
224
+
pip install numpy
225
+
226
+
Then in your C++ entry point add this function that manipulates ``sys.path``:
227
+
228
+
.. code-block:: cpp
229
+
230
+
/** Takes a path and adds it to sys.paths by calling PyRun_SimpleString.
231
+
* This does rather laborious C string concatenation so that it will work in
Copy file name to clipboardExpand all lines: doc/sphinx/source/debugging/debug_in_ide.rst
+27
Original file line number
Diff line number
Diff line change
@@ -356,6 +356,33 @@ And you should get something like this:
356
356
357
357
The full code for this is in *src/debugging/XcodeExample/PythonSubclassList/*.
358
358
359
+
360
+
--------------------------------------------
361
+
Using a Debug Version of Python C with Xcode
362
+
--------------------------------------------
363
+
364
+
To get Xcode to use a debug version of Python first build Python from source assumed here to be ``<SOURCE_DIR>`` with, as a minimum, ``--with-pydebug``. This example is using Python 3.6:
* add ``/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m/`` to "Header Search Paths". Alternatively add both ``<SOURCE_DIR>/Include`` *and* ``<SOURCE_DIR>/debug-framework`` to "Header Search Paths", the latter is needed for ``pyconfig.h``.
382
+
* add ``<SOURCE_DIR>/debug-framework`` to "Library Search Paths".
383
+
384
+
Now you should be able to step into the CPython code.
Copy file name to clipboardExpand all lines: src/debugging/XcodeExample/PythonSubclassList/PythonSubclassList.xcodeproj/xcuserdata/paulross.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
0 commit comments