Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] Move command description to the deprecated practice section #3371

Merged
merged 4 commits into from Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.d/3371.doc.rst
@@ -0,0 +1,3 @@
Moved documentation from ``/userguide/commands`` to ``/depracted/commands``.
This change was motived by the fact that running ``python setup.py`` directly is
considered a deprecated practice.
1 change: 1 addition & 0 deletions docs/conf.py
Expand Up @@ -133,6 +133,7 @@
extensions += ['sphinx_reredirects']
redirects = {
"userguide/keywords": "/deprecated/changed_keywords.html",
"userguide/commands": "/deprecated/commands.html",
}

# Add support for inline tabs
Expand Down
56 changes: 56 additions & 0 deletions docs/userguide/commands.rst → docs/deprecated/commands.rst
@@ -1,3 +1,59 @@
===============================
Running ``setuptools`` commands
===============================

Historically, ``setuptools`` allowed running commands via a ``setup.py`` script
at the root of a Python project, as indicated in the examples below::

python setup.py --help
python setup.py --help-commands
python setup.py --version
python setup.py sdist
python setup.py bdist_wheel

You could also run commands in other circumstances:

* ``setuptools`` projects without ``setup.py`` (e.g., ``setup.cfg``-only)::

python -c "import setuptools; setup()" --help

* ``distutils`` projects (with a ``setup.py`` importing ``distutils``)::

python -c "import setuptools; with open('setup.py') as f: exec(compile(f.read(), 'setup.py', 'exec'))" develop

That is, you can simply list the normal setup commands and options following the quoted part.

.. warning::
While it is perfectly fine that users write ``setup.py`` files to configure
a package build (e.g. to specify binary extensions or customize commands),
on recent versions of ``setuptools``, running ``python setup.py`` directly
as a script is considered **deprecated**. This also means that users should
avoid running commands directly via ``python setup.py <command>``.

If you want to create :term:`sdist <Source Distribution (or "sdist")>` or :term:`wheel`
distributions the recommendation is to use the command line tool provided by :pypi:`build`::

pip install build # needs to be installed first

python -m build # builds both sdist and wheel
python -m build --sdist
python -m build --wheel

Build will automatically download ``setuptools`` and build the package in an
isolated environment. You can also specify specific versions of
``setuptools``, by setting the :doc:`build requirements in pyproject.toml
</build_meta>`.

If you want to install a package, you can use :pypi:`pip` or :pypi:`installer`::

pip install /path/to/wheel/file.whl
pip install /path/to/sdist/file.tar.gz
pip install . # replacement for python setup.py install
pip install --editable . # replacement for python setup.py develop

pip install installer # nees to be installed first
python -m installer /path/to/wheel/file.whl

-----------------
Command Reference
-----------------
Expand Down
2 changes: 1 addition & 1 deletion docs/deprecated/index.rst
Expand Up @@ -22,4 +22,4 @@ objectives.
distutils/index
distutils-legacy
functionalities
running_commands
commands
23 changes: 0 additions & 23 deletions docs/deprecated/running_commands.rst

This file was deleted.

1 change: 0 additions & 1 deletion docs/userguide/index.rst
Expand Up @@ -34,7 +34,6 @@ Contents
extension
declarative_config
pyproject_config
commands
miscellaneous

---
Expand Down