Skip to content

Commit 9eea382

Browse files
committed
ocs: Clarify 'setup.py' support on Quickstart (#3529)
2 parents e4bebb8 + cc2a4ef commit 9eea382

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

changelog.d/3529.doc.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Added clarification to :doc:`/userguide/quickstart` about support
2+
to ``setup.py``.

docs/userguide/quickstart.rst

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ library will be used to actually do the packaging.
5959
In addition to specifying a build system, you also will need to add
6060
some package information such as metadata, contents, dependencies, etc.
6161
This can be done in the same ``pyproject.toml`` [#beta]_ file,
62-
or in a separated one: ``setup.cfg`` or ``setup.py`` (please note however
63-
that configuring new projects via ``setup.py`` is discouraged [#setup.py]_).
62+
or in a separated one: ``setup.cfg`` or ``setup.py`` [#setup.py]_.
6463

6564
The following example demonstrates a minimum configuration
6665
(which assumes the project depends on :pypi:`requests` and
@@ -149,6 +148,27 @@ to specify to properly package your project.
149148
could have a diagram for that (explaining for example that "wheels" are
150149
built from "sdists" not the source tree).
151150
151+
.. _setuppy_discouraged:
152+
.. admonition:: Info: Using ``setup.py``
153+
:class: seealso
154+
155+
Setuptools offers first class support for ``setup.py`` files as a configuration
156+
mechanism.
157+
158+
It is important to remember, however, that running this file as a
159+
script (e.g. ``python setup.py sdist``) is strongly **discouraged**, and
160+
that the majority of the command line interfaces are (or will be) **deprecated**
161+
(e.g. ``python setup.py install``, ``python setup.py bdist_wininst``, ...).
162+
163+
We also recommend users to expose as much as possible configuration in a
164+
more *declarative* way via the :doc:`pyproject.toml <pyproject_config>` or
165+
:doc:`setup.cfg <declarative_config>`, and keep the ``setup.py`` minimal
166+
with only the dynamic parts (or even omit it completely if applicable).
167+
168+
See `Why you shouldn't invoke setup.py directly`_ for more background.
169+
170+
.. _Why you shouldn't invoke setup.py directly: https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html
171+
152172

153173
Overview
154174
========
@@ -438,14 +458,15 @@ up-to-date references that can help you when it is time to distribute your work.
438458
.. rubric:: Notes
439459

440460
.. [#setup.py]
441-
The ``setup.py`` file should be used only when custom scripting during the
442-
build is necessary.
461+
New projects are advised to avoid ``setup.py`` configurations (beyond the minimal stub)
462+
when custom scripting during the build is not necessary.
443463
Examples are kept in this document to help people interested in maintaining or
444464
contributing to existing packages that use ``setup.py``.
445465
Note that you can still keep most of configuration declarative in
446466
:doc:`setup.cfg <declarative_config>` or :doc:`pyproject.toml
447467
<pyproject_config>` and use ``setup.py`` only for the parts not
448468
supported in those files (e.g. C extensions).
469+
See :ref:`note <setuppy_discouraged>`.
449470
450471
.. [#beta]
451472
Support for adding build configuration options via the ``[tool.setuptools]``

0 commit comments

Comments
 (0)