Skip to content

Commit 6d1b69f

Browse files
committed
DOC: Rewrite installation instructions
- Put pip and conda as the most common options first - Don't distinguish Linux / Windows in the pip commands. They are equivalent and users should be able to get this right even without the distinction. - Replace the venv instructions by a general tip to use environments and link out for details. - Collect all OS-specific package manager in one section - Remove the "Windows - Other methods" secion. This is basically pip (or conda). It's beyond the scope of Sphinx to explain how to set up Python. - Move latest development release to a separate entry. *Question*: Do you still do development releases? I just got the latest stable by that.
1 parent 93e4eea commit 6d1b69f

File tree

1 file changed

+87
-115
lines changed

1 file changed

+87
-115
lines changed

doc/usage/installation.rst

Lines changed: 87 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,85 @@
22
Installing Sphinx
33
=================
44

5-
.. contents::
6-
:depth: 1
5+
Sphinx is a Python application. It can be installed in one of the ways described
6+
below.
7+
8+
.. contents:: Installation methods
9+
:depth: 2
710
:local:
811
:backlinks: none
912

1013
.. highlight:: console
1114

12-
Overview
13-
--------
15+
After installation, you can check that Sphinx is available by running ::
16+
17+
$ sphinx-build --version
18+
19+
This should print out the Sphinx version number.
20+
21+
22+
.. tip::
23+
24+
If you use Sphinx for documenting a Python library or application, it is
25+
generally recommended to install Sphinx into your development environment (
26+
`venv <https://docs.python.org/3/library/venv.html>`_ or
27+
`conda <https://conda.io/projects/conda/en/latest/user-guide/getting-started.html#creating-environments>`_
28+
environment).
29+
30+
By adding Sphinx and 3rdparty extensions or themes that you use to your dev
31+
dependencies, you make sure that you have a consistent setup for building
32+
your documentation.
33+
34+
35+
.. _install-pypi:
36+
37+
PyPI package
38+
------------
39+
40+
Sphinx packages are published on the `Python Package Index
41+
<https://pypi.org/project/Sphinx/>`_ (PyPI). The preferred tool for installing
42+
packages from *PyPI* is :command:`pip`, which is included in all modern versions of
43+
Python.
44+
45+
Run the following command::
46+
47+
$ pip install -U sphinx
48+
49+
.. _install-conda:
50+
51+
Conda package
52+
-------------
53+
To work with :command:`conda`, you need a conda-based Python distribution such as
54+
`anaconda`__, `miniconda`__, `miniforge`__ or `micromamba`__.
55+
56+
__ https://docs.anaconda.com/anaconda/
57+
__ https://docs.anaconda.com/miniconda/
58+
__ https://github.com/conda-forge/miniforge/
59+
__ https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html
1460

15-
Sphinx is written in `Python`__ and supports Python 3.9+. It builds upon the
16-
shoulders of many third-party libraries such as `Docutils`__ and `Jinja`__,
17-
which are installed when Sphinx is installed.
1861

19-
__ https://docs.python-guide.org/
20-
__ https://docutils.sourceforge.io/
21-
__ https://jinja.palletsprojects.com/
62+
Sphinx is available both via the *anaconda main* channel (maintained by Anaconda Inc.)
2263

64+
::
65+
66+
$ conda install sphinx
67+
68+
as well as via the *conda-forge* community channel ::
69+
70+
$ conda install -c conda-forge sphinx
71+
72+
OS-specific package manager
73+
---------------------------
74+
75+
You may install a global version of Sphinx into your system using OS-specific
76+
package managers. However, be aware that this is less flexible and you may run into
77+
compatibility issues if you want to work across different projects.
2378

2479
Linux
25-
-----
80+
~~~~~
2681

2782
Debian/Ubuntu
28-
~~~~~~~~~~~~~
83+
"""""""""""""
2984

3085
Install either ``python3-sphinx`` using :command:`apt-get`:
3186

@@ -36,7 +91,7 @@ Install either ``python3-sphinx`` using :command:`apt-get`:
3691
If it not already present, this will install Python for you.
3792

3893
RHEL, CentOS
39-
~~~~~~~~~~~~
94+
""""""""""""
4095

4196
Install ``python-sphinx`` using :command:`yum`:
4297

@@ -47,27 +102,24 @@ Install ``python-sphinx`` using :command:`yum`:
47102
If it not already present, this will install Python for you.
48103

49104
Other distributions
50-
~~~~~~~~~~~~~~~~~~~
105+
"""""""""""""""""""
51106

52107
Most Linux distributions have Sphinx in their package repositories. Usually
53108
the package is called ``python3-sphinx``, ``python-sphinx`` or ``sphinx``. Be
54109
aware that there are at least two other packages with ``sphinx`` in their name:
55110
a speech recognition toolkit (*CMU Sphinx*) and a full-text search database
56111
(*Sphinx search*).
57112

58-
59113
macOS
60-
-----
114+
~~~~~
61115

62-
Sphinx can be installed using `Homebrew`__, `MacPorts`__, or as part of
63-
a Python distribution such as `Anaconda`__.
116+
Sphinx can be installed using `Homebrew`__, `MacPorts`__.
64117

65118
__ https://brew.sh/
66119
__ https://www.macports.org/
67-
__ https://www.anaconda.com/download
68120

69121
Homebrew
70-
~~~~~~~~
122+
""""""""
71123

72124
::
73125

@@ -78,7 +130,7 @@ For more information, refer to the `package overview`__.
78130
__ https://formulae.brew.sh/formula/sphinx-doc
79131

80132
MacPorts
81-
~~~~~~~~
133+
""""""""
82134

83135
Install either ``python3x-sphinx`` using :command:`port`:
84136

@@ -97,23 +149,15 @@ For more information, refer to the `package overview`__.
97149

98150
__ https://www.macports.org/ports.php?by=library&substr=py39-sphinx
99151

100-
Anaconda
101-
~~~~~~~~
102-
103-
::
104-
105-
$ conda install sphinx
106-
107152
Windows
108-
-------
153+
~~~~~~~
109154

110-
Sphinx can be install using `Chocolatey`__ or
111-
:ref:`installed manually <windows-other-method>`.
155+
Sphinx can be install using `Chocolatey`__.
112156

113157
__ https://chocolatey.org/
114158

115159
Chocolatey
116-
~~~~~~~~~~
160+
""""""""""
117161

118162
::
119163

@@ -127,89 +171,6 @@ For more information, refer to the `chocolatey page`__.
127171

128172
__ https://chocolatey.org/packages/sphinx/
129173

130-
.. _windows-other-method:
131-
132-
Other Methods
133-
~~~~~~~~~~~~~
134-
135-
Most Windows users do not have Python installed by default, so we begin with
136-
the installation of Python itself. To check if you already have Python
137-
installed, open the *Command Prompt* (:kbd:`⊞Win-r` and type :command:`cmd`).
138-
Once the command prompt is open, type :command:`python --version` and press
139-
Enter. If Python is installed, you will see the version of Python printed to
140-
the screen. If you do not have Python installed, refer to the `Hitchhikers
141-
Guide to Python's`__ Python on Windows installation guides. You must install
142-
`Python 3`__.
143-
144-
Once Python is installed, you can install Sphinx using :command:`pip`. Refer
145-
to the :ref:`pip installation instructions <install-pypi>` below for more
146-
information.
147-
148-
__ https://docs.python-guide.org/
149-
__ https://docs.python-guide.org/starting/install3/win/
150-
151-
152-
.. _install-pypi:
153-
154-
Installation from PyPI
155-
----------------------
156-
157-
Sphinx packages are published on the `Python Package Index
158-
<https://pypi.org/project/Sphinx/>`_. The preferred tool for installing
159-
packages from *PyPI* is :command:`pip`. This tool is provided with all modern
160-
versions of Python.
161-
162-
On Linux or MacOS, you should open your terminal and run the following command.
163-
164-
::
165-
166-
$ pip install -U sphinx
167-
168-
On Windows, you should open *Command Prompt* (:kbd:`⊞Win-r` and type
169-
:command:`cmd`) and run the same command.
170-
171-
.. code-block:: doscon
172-
173-
C:\> pip install -U sphinx
174-
175-
After installation, type :command:`sphinx-build --version` on the command
176-
prompt. If everything worked fine, you will see the version number for the
177-
Sphinx package you just installed.
178-
179-
Installation from *PyPI* also allows you to install the latest development
180-
release. You will not generally need (or want) to do this, but it can be
181-
useful if you see a possible bug in the latest stable release. To do this, use
182-
the ``--pre`` flag.
183-
184-
::
185-
186-
$ pip install -U --pre sphinx
187-
188-
Using virtual environments
189-
~~~~~~~~~~~~~~~~~~~~~~~~~~
190-
191-
When installing Sphinx using pip,
192-
it is highly recommended to use *virtual environments*,
193-
which isolate the installed packages from the system packages,
194-
thus removing the need to use administrator privileges.
195-
To create a virtual environment in the ``.venv`` directory,
196-
use the following command.
197-
198-
::
199-
200-
$ python -m venv .venv
201-
202-
.. seealso:: :mod:`venv` -- creating virtual environments
203-
204-
.. warning::
205-
206-
Note that in some Linux distributions, such as Debian and Ubuntu,
207-
this might require an extra installation step as follows.
208-
209-
.. code-block:: console
210-
211-
$ apt-get install python3-venv
212-
213174
Docker
214175
------
215176

@@ -251,6 +212,17 @@ For more details, please read `README file`__ of docker images.
251212

252213
.. __: https://hub.docker.com/r/sphinxdoc/sphinx
253214

215+
Installation of the latest development release
216+
----------------------------------------------
217+
218+
You can install the latest development from *PyPI* using the ``--pre`` flag::
219+
220+
$ pip install -U --pre sphinx
221+
222+
.. warning::
223+
224+
You will not generally need (or want) to do this, but it can be
225+
useful if you see a possible bug in the latest stable release.
254226

255227
Installation from source
256228
------------------------

0 commit comments

Comments
 (0)