mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00

Document behaviour of single-phase init. Call it "legacy". Reorganize PyModule docs. Move PyInit_modulename docs from the tutorial to reference documentation. Move PyMODINIT_FUNC docs from generic macros to the new page. Add doc stubs for `PYTHON_API_VERSION` & `PYTHON_ABI_VERSION` Remove incorrect refcounts.dat entry for `PyModuleDef_Init`. This removes the "Return value: Borrowed reference." note. Instead, note that the function sometimes returns a borrowed reference, sometimes as strong one. (IMO, it's best to not think of `PyModuleDef` as a `PyObject` at all, and act like it can't be reference-counted.) Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
30 lines
860 B
ReStructuredText
30 lines
860 B
ReStructuredText
.. highlight:: c
|
|
|
|
.. _building:
|
|
|
|
*****************************
|
|
Building C and C++ Extensions
|
|
*****************************
|
|
|
|
A C extension for CPython is a shared library (for example, a ``.so`` file on
|
|
Linux, ``.pyd`` on Windows), which exports an *initialization function*.
|
|
|
|
See :ref:`extension-modules` for details.
|
|
|
|
|
|
.. highlight:: c
|
|
|
|
.. _install-index:
|
|
.. _setuptools-index:
|
|
|
|
Building C and C++ Extensions with setuptools
|
|
=============================================
|
|
|
|
|
|
Building, packaging and distributing extension modules is best done with
|
|
third-party tools, and is out of scope of this document.
|
|
One suitable tool is Setuptools, whose documentation can be found at
|
|
https://setuptools.pypa.io/en/latest/setuptools.html.
|
|
|
|
The :mod:`distutils` module, which was included in the standard library
|
|
until Python 3.12, is now maintained as part of Setuptools.
|