Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c7f9f2b

Browse files
committed
Document how to define extension modules in setup.cfg
1 parent a462a80 commit c7f9f2b

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

Doc/library/packaging.compiler.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,10 +569,10 @@ extension modules.
569569
.. class:: Extension
570570

571571
The Extension class describes a single C or C++ extension module. It accepts
572-
the following keyword arguments in its constructor
572+
the following keyword arguments in its constructor:
573573

574574
+------------------------+--------------------------------+---------------------------+
575-
| argument name | value | type |
575+
| argument name | value | type [#]_ |
576576
+========================+================================+===========================+
577577
| *name* | the full name of the | string |
578578
| | extension, including any | |
@@ -670,3 +670,5 @@ extension modules.
670670
| | from the source extensions if | |
671671
| | not provided. | |
672672
+------------------------+--------------------------------+---------------------------+
673+
674+
.. [#] For values documented as lists, the given type is the type of each element.

Doc/packaging/setupcfg.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ files
141141
Modules, scripts, data, documentation and other files to include in the
142142
distribution.
143143

144+
extension sections
145+
Options used to build extension modules.
146+
144147
command sections
145148
Options given for specific commands, identical to those that can be given
146149
on the command line.
@@ -736,6 +739,35 @@ We use brace expansion syntax to place all the shell and batch scripts into
736739
{scripts} category.
737740

738741

742+
Extension sections
743+
------------------
744+
745+
If a project includes extension modules written in C or C++, each one of them
746+
needs to have its options defined in a dedicated section. Here's an example::
747+
748+
[files]
749+
packages = coconut
750+
751+
[extension=_fastcoconut]
752+
name = coconut._fastcoconut
753+
language = cxx
754+
sources = cxx_src/cononut_utils.cxx
755+
cxx_src/python_module.cxx
756+
include_dirs = /usr/include/gecode
757+
/usr/include/blitz
758+
extra_compile_args =
759+
-fPIC -O2
760+
-DGECODE_VERSION=$(./gecode_version) -- sys.platform != 'win32'
761+
/DGECODE_VERSION='win32' -- sys.platform == 'win32'
762+
763+
The section name must start with ``extension=``; the righ-hand part is currently
764+
discarded. Valid fields and their values are listed in the documentation of the
765+
:class:`packaging.compiler.extension.Extension` class; values documented as
766+
Python lists translate to multi-line values in the configuration file. In
767+
addition, multi-line values accept environment markers on each line, after a
768+
``--``.
769+
770+
739771
Command sections
740772
----------------
741773

0 commit comments

Comments
 (0)