Skip to content

Commit 32480c2

Browse files
authored
Merge branch 'pypa:main' into patch-2
2 parents e8c91cf + a2cad18 commit 32480c2

File tree

2 files changed

+87
-7
lines changed

2 files changed

+87
-7
lines changed

source/discussions/setup-py-deprecated.rst

Lines changed: 78 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@
55
Is ``setup.py`` deprecated?
66
===========================
77

8-
No, :term:`setup.py` is not deprecated,
9-
it is a valid configuration file for :ref:`setuptools`
8+
No, :term:`setup.py` and :ref:`setuptools` are not deprecated.
9+
10+
Setuptools is perfectly usable as a :term:`build backend`
11+
for packaging Python projects.
12+
And :file:`setup.py` is a valid configuration file for :ref:`setuptools`
1013
that happens to be written in Python, instead of in *TOML* for example
1114
(a similar practice is used by other tools
1215
like *nox* and its :file:`nox.py` configuration file,
1316
or *pytest* and :file:`conftest.py`).
1417

15-
And of course *setuptools* itself is not deprecated either.
16-
17-
It is however deprecated to run ``python setup.py`` as a command line tool.
18+
However, ``python setup.py`` and the use of :file:`setup.py`
19+
as a command line tool are deprecated.
1820

19-
This means for example that the following commands **MUST NOT** be run anymore:
21+
This means that commands such as the following **MUST NOT** be run anymore:
2022

2123
* ``python setup.py install``
2224
* ``python setup.py develop``
@@ -28,7 +30,7 @@ What commands should be used instead?
2830
=====================================
2931

3032
+---------------------------------+----------------------------------------+
31-
| Deprecated | Current recommendation |
33+
| Deprecated | Recommendation |
3234
+=================================+========================================+
3335
| ``python setup.py install`` | ``python -m pip install .`` |
3436
+---------------------------------+----------------------------------------+
@@ -79,6 +81,75 @@ The command ``python setup.py install`` was deprecated
7981
in setuptools version *58.3.0*.
8082

8183

84+
What about other commands?
85+
==========================
86+
87+
What are some replacements for the other ``python setup.py`` commands?
88+
89+
90+
``python setup.py test``
91+
------------------------
92+
93+
The recommendation is to use a test runner such as pytest_.
94+
95+
.. _pytest: https://docs.pytest.org/
96+
97+
98+
``python setup.py check``, ``python setup.py register``, and ``python setup.py upload``
99+
---------------------------------------------------------------------------------------
100+
101+
A trusted replacement is :ref:`twine`:
102+
103+
* ``python -m twine check``
104+
* ``python -m twine register``
105+
* ``python -m twine upload``
106+
107+
108+
``python setup.py --version``
109+
-----------------------------
110+
111+
A possible replacement solution (among others) is to rely on setuptools-scm_:
112+
113+
* ``python -m setuptools-scm``
114+
115+
.. _setuptools-scm: https://setuptools-scm.readthedocs.io/en/latest/usage/#as-cli-tool
116+
117+
118+
Remaining commands
119+
------------------
120+
121+
This guide does not make suggestions of replacement solutions for those commands:
122+
123+
.. hlist::
124+
:columns: 4
125+
126+
* ``alias``
127+
* ``bdist``
128+
* ``bdist_dumb``
129+
* ``bdist_egg``
130+
* ``bdist_rpm``
131+
* ``build``
132+
* ``build_clib``
133+
* ``build_ext``
134+
* ``build_py``
135+
* ``build_scripts``
136+
* ``clean``
137+
* ``dist_info``
138+
* ``easy_install``
139+
* ``editable_wheel``
140+
* ``egg_info``
141+
* ``install``
142+
* ``install_data``
143+
* ``install_egg_info``
144+
* ``install_headers``
145+
* ``install_lib``
146+
* ``install_scripts``
147+
* ``rotate``
148+
* ``saveopts``
149+
* ``setopt``
150+
* ``upload_docs``
151+
152+
82153
What about custom commands?
83154
===========================
84155

source/specifications/recording-installed-packages.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,15 @@ attempt to uninstall or upgrade the package.
175175
(This restriction does not apply to tools that rely on other sources of information,
176176
such as system package managers in Linux distros.)
177177

178+
.. note::
179+
180+
It is *strongly discouraged* for an installed package to modify itself
181+
(e.g., store cache files under its namespace in ``site-packages``).
182+
Changes inside ``site-packages`` should be left to specialized installer
183+
tools such as pip. If a package is nevertheless modified in this way,
184+
then the ``RECORD`` must be updated, otherwise uninstalling the package
185+
will leave unlisted files in place (possibly resulting in a zombie
186+
namespace package).
178187

179188
The INSTALLER file
180189
==================

0 commit comments

Comments
 (0)