Skip to content

Commit c5e3614

Browse files
authored
Merge pull request #2604 from cansjt/fix-inaccurate-entrypoint-doc
Entrypoints in declarative config are now supported
2 parents a5131f0 + d339125 commit c5e3614

File tree

2 files changed

+95
-57
lines changed

2 files changed

+95
-57
lines changed

changelog.d/2604.doc.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Revamped the backward/cross tool compatibility section to remove
2+
some confusion.
3+
Add some examples and the version since when ``entry_points`` are
4+
supported in declarative configuration.
5+
Tried to make the reading flow a bit leaner, gather some informations
6+
that were a bit dispersed.

docs/userguide/declarative_config.rst

Lines changed: 89 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,7 @@ to the ``setup()`` function (declarative config).
1818
This approach not only allows automation scenarios but also reduces
1919
boilerplate code in some cases.
2020

21-
.. note::
22-
23-
This implementation has limited compatibility with the distutils2-like
24-
``setup.cfg`` sections used by the ``pbr`` and ``d2to1`` packages.
25-
26-
Namely: only metadata-related keys from ``metadata`` section are supported
27-
(except for ``description-file``); keys from ``files``, ``entry_points``
28-
and ``backwards_compat`` are not supported.
29-
21+
.. _example-setup-config:
3022

3123
.. code-block:: ini
3224
@@ -58,6 +50,10 @@ boilerplate code in some cases.
5850
* = *.txt, *.rst
5951
hello = *.msg
6052
53+
[options.entry_points]
54+
console_scripts =
55+
executable-name = package.module:function
56+
6157
[options.extras_require]
6258
pdf = ReportLab>=1.2; RXP
6359
rest = docutils>=0.3; pack ==1.1, ==1.3
@@ -156,10 +152,9 @@ Special directives:
156152

157153
* ``file:`` - Value is read from a list of files and then concatenated
158154

159-
160-
.. note::
161-
The ``file:`` directive is sandboxed and won't reach anything outside
162-
the directory containing ``setup.py``.
155+
.. note::
156+
The ``file:`` directive is sandboxed and won't reach anything outside
157+
the directory containing ``setup.py``.
163158

164159

165160
Metadata
@@ -169,11 +164,11 @@ Metadata
169164
The aliases given below are supported for compatibility reasons,
170165
but their use is not advised.
171166

172-
============================== ================= ================= =============== =====
167+
============================== ================= ================= =============== ==========
173168
Key Aliases Type Minimum Version Notes
174-
============================== ================= ================= =============== =====
169+
============================== ================= ================= =============== ==========
175170
name str
176-
version attr:, file:, str 39.2.0 (1)
171+
version attr:, file:, str 39.2.0 [#meta-1]_
177172
url home-page str
178173
download_url download-url str
179174
project_urls dict 38.3.0
@@ -192,28 +187,29 @@ platforms platform list-comma
192187
provides list-comma
193188
requires list-comma
194189
obsoletes list-comma
195-
============================== ================= ================= =============== =====
190+
============================== ================= ================= =============== ==========
196191

197-
.. note::
198-
A version loaded using the ``file:`` directive must comply with PEP 440.
199-
It is easy to accidentally put something other than a valid version
200-
string in such a file, so validation is stricter in this case.
192+
**Notes**:
193+
194+
.. [#meta-1] The ``version`` file attribute has only been supported since 39.2.0.
195+
196+
A version loaded using the ``file:`` directive must comply with PEP 440.
197+
It is easy to accidentally put something other than a valid version
198+
string in such a file, so validation is stricter in this case.
201199
202-
Notes:
203-
1. The ``version`` file attribute has only been supported since 39.2.0.
204200
205201
Options
206202
-------
207203

208-
======================= =================================== =============== =====
204+
======================= =================================== =============== =========
209205
Key Type Minimum Version Notes
210-
======================= =================================== =============== =====
206+
======================= =================================== =============== =========
211207
zip_safe bool
212208
setup_requires list-semi
213209
install_requires list-semi
214-
extras_require section
210+
extras_require section [#opt-2]_
215211
python_requires str
216-
entry_points file:, section
212+
entry_points file:, section 51.0.0
217213
use_2to3 bool
218214
use_2to3_fixers list-comma
219215
use_2to3_exclude_fixers list-comma
@@ -223,38 +219,74 @@ eager_resources list-comma
223219
dependency_links list-comma
224220
tests_require list-semi
225221
include_package_data bool
226-
packages find:, find_namespace:, list-comma
222+
packages find:, find_namespace:, list-comma [#opt-3]_
227223
package_dir dict
228-
package_data section (1)
224+
package_data section [#opt-1]_
229225
exclude_package_data section
230226
namespace_packages list-comma
231227
py_modules list-comma
232228
data_files dict 40.6.0
233-
======================= =================================== =============== =====
234-
235-
.. note::
236-
237-
**packages** - The ``find:`` and ``find_namespace:`` directive can be further configured
238-
in a dedicated subsection ``options.packages.find``. This subsection
239-
accepts the same keys as the ``setuptools.find_packages`` and the
240-
``setuptools.find_namespace_packages`` function:
241-
``where``, ``include``, and ``exclude``.
242-
243-
**find_namespace directive** - The ``find_namespace:`` directive is supported since Python >=3.3.
244-
245-
246-
Notes:
247-
1. In the ``package_data`` section, a key named with a single asterisk (``*``)
248-
refers to all packages, in lieu of the empty string used in ``setup.py``.
249-
250-
2. In the ``extras_require`` section, values are parsed as ``list-semi``. This implies that in
251-
order to include markers, they **must** be *dangling*:
252-
253-
.. code-block:: ini
254-
255-
[options.extras_require]
256-
rest = docutils>=0.3; pack ==1.1, ==1.3
257-
pdf =
258-
ReportLab>=1.2
259-
RXP
260-
importlib-metadata; python_version < "3.8"
229+
======================= =================================== =============== =========
230+
231+
**Notes**:
232+
233+
.. [#opt-1] In the ``package_data`` section, a key named with a single asterisk
234+
(``*``) refers to all packages, in lieu of the empty string used in ``setup.py``.
235+
236+
.. [#opt-2] In the ``extras_require`` section, values are parsed as ``list-semi``.
237+
This implies that in order to include markers, they **must** be *dangling*:
238+
239+
.. code-block:: ini
240+
241+
[options.extras_require]
242+
rest = docutils>=0.3; pack ==1.1, ==1.3
243+
pdf =
244+
ReportLab>=1.2
245+
RXP
246+
importlib-metadata; python_version < "3.8"
247+
248+
.. [#opt-3] The ``find:`` and ``find_namespace:`` directive can be further configured
249+
in a dedicated subsection ``options.packages.find``. This subsection accepts the
250+
same keys as the ``setuptools.find_packages`` and the
251+
``setuptools.find_namespace_packages`` function:
252+
``where``, ``include``, and ``exclude``.
253+
254+
The ``find_namespace:`` directive is supported since Python >=3.3.
255+
256+
257+
Compatibility with other tools
258+
==============================
259+
260+
Historically, several tools explored declarative package configuration
261+
in parallel. And several of them chose to place the packaging
262+
configuration within the project's :file:`setup.cfg` file.
263+
One of the first was ``distutils2``, which development has stopped in
264+
2013. Other include ``pbr`` which is still under active development or
265+
``d2to1``, which was a plug-in that backports declarative configuration
266+
to ``distutils``, but has had no release since Oct. 2015.
267+
As a way to harmonize packaging tools, ``setuptools``, having held the
268+
position of *de facto* standard, has gradually integrated those
269+
features as part of its core features.
270+
271+
Still this has lead to some confusion and feature incompatibilities:
272+
273+
- some tools support features others don't;
274+
- some have similar features but the declarative syntax differs;
275+
276+
The table below tries to summarize the differences. But, please, refer
277+
to each tool documentation for up-to-date information.
278+
279+
=========================== ========== ========== ===== ===
280+
feature setuptools distutils2 d2to1 pbr
281+
=========================== ========== ========== ===== ===
282+
[metadata] description-file S Y Y Y
283+
[files] S Y Y Y
284+
entry_points Y Y Y S
285+
[backwards_compat] N Y Y Y
286+
=========================== ========== ========== ===== ===
287+
288+
Y: supported, N: unsupported, S: syntax differs (see
289+
:ref:`above example<example-setup-config>`).
290+
291+
Also note that some features were only recently added to ``setuptools``.
292+
Please refer to the previous sections to find out when.

0 commit comments

Comments
 (0)