Skip to content

Commit 94955ce

Browse files
authored
[Docs] Move command description to the deprecated practice section (#3371)
2 parents ea38135 + ddcfdfa commit 94955ce

File tree

6 files changed

+61
-25
lines changed

6 files changed

+61
-25
lines changed

changelog.d/3371.doc.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Moved documentation from ``/userguide/commands`` to ``/depracted/commands``.
2+
This change was motived by the fact that running ``python setup.py`` directly is
3+
considered a deprecated practice.

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
extensions += ['sphinx_reredirects']
134134
redirects = {
135135
"userguide/keywords": "/deprecated/changed_keywords.html",
136+
"userguide/commands": "/deprecated/commands.html",
136137
}
137138

138139
# Add support for inline tabs

docs/userguide/commands.rst renamed to docs/deprecated/commands.rst

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,59 @@
1+
===============================
2+
Running ``setuptools`` commands
3+
===============================
4+
5+
Historically, ``setuptools`` allowed running commands via a ``setup.py`` script
6+
at the root of a Python project, as indicated in the examples below::
7+
8+
python setup.py --help
9+
python setup.py --help-commands
10+
python setup.py --version
11+
python setup.py sdist
12+
python setup.py bdist_wheel
13+
14+
You could also run commands in other circumstances:
15+
16+
* ``setuptools`` projects without ``setup.py`` (e.g., ``setup.cfg``-only)::
17+
18+
python -c "import setuptools; setup()" --help
19+
20+
* ``distutils`` projects (with a ``setup.py`` importing ``distutils``)::
21+
22+
python -c "import setuptools; with open('setup.py') as f: exec(compile(f.read(), 'setup.py', 'exec'))" develop
23+
24+
That is, you can simply list the normal setup commands and options following the quoted part.
25+
26+
.. warning::
27+
While it is perfectly fine that users write ``setup.py`` files to configure
28+
a package build (e.g. to specify binary extensions or customize commands),
29+
on recent versions of ``setuptools``, running ``python setup.py`` directly
30+
as a script is considered **deprecated**. This also means that users should
31+
avoid running commands directly via ``python setup.py <command>``.
32+
33+
If you want to create :term:`sdist <Source Distribution (or "sdist")>` or :term:`wheel`
34+
distributions the recommendation is to use the command line tool provided by :pypi:`build`::
35+
36+
pip install build # needs to be installed first
37+
38+
python -m build # builds both sdist and wheel
39+
python -m build --sdist
40+
python -m build --wheel
41+
42+
Build will automatically download ``setuptools`` and build the package in an
43+
isolated environment. You can also specify specific versions of
44+
``setuptools``, by setting the :doc:`build requirements in pyproject.toml
45+
</build_meta>`.
46+
47+
If you want to install a package, you can use :pypi:`pip` or :pypi:`installer`::
48+
49+
pip install /path/to/wheel/file.whl
50+
pip install /path/to/sdist/file.tar.gz
51+
pip install . # replacement for python setup.py install
52+
pip install --editable . # replacement for python setup.py develop
53+
54+
pip install installer # nees to be installed first
55+
python -m installer /path/to/wheel/file.whl
56+
157
-----------------
258
Command Reference
359
-----------------

docs/deprecated/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ objectives.
2222
distutils/index
2323
distutils-legacy
2424
functionalities
25-
running_commands
25+
commands

docs/deprecated/running_commands.rst

Lines changed: 0 additions & 23 deletions
This file was deleted.

docs/userguide/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ Contents
3535
extension
3636
declarative_config
3737
pyproject_config
38-
commands
3938
miscellaneous
4039

4140
---

0 commit comments

Comments
 (0)