Skip to content

Commit 96e4493

Browse files
committed
DOC: Rewrite installation instructions
- Put pip and conda as the most common options first - 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 - 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 96e4493

File tree

1 file changed

+99
-113
lines changed

1 file changed

+99
-113
lines changed

doc/usage/installation.rst

Lines changed: 99 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,94 @@
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 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+
On Linux or MacOS, you should open your terminal and run the following command.
46+
47+
::
48+
49+
$ pip install -U sphinx
50+
51+
On Windows, you should open *Command Prompt* (:kbd:`⊞Win-r` and type
52+
:command:`cmd`) and run the same command.
53+
54+
.. code-block:: doscon
55+
56+
C:\> pip install -U sphinx
57+
58+
.. _install-conda:
59+
60+
Conda package
61+
-------------
62+
To work with :command:`conda`, you need a conda-based Python distribution such as
63+
`anaconda`__, `miniconda`__, `miniforge`__ or `micromamba`__.
64+
65+
__ https://docs.anaconda.com/anaconda/
66+
__ https://docs.anaconda.com/miniconda/
67+
__ https://github.com/conda-forge/miniforge/
68+
__ https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html
69+
70+
71+
Sphinx is available both via the *anaconda main* channel (maintained by Anaconda Inc.)
72+
73+
::
74+
75+
$ conda install sphinx
1476

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.
77+
as well as via the *conda-forge* community channel ::
1878

19-
__ https://docs.python-guide.org/
20-
__ https://docutils.sourceforge.io/
21-
__ https://jinja.palletsprojects.com/
79+
$ conda install -c conda-forge sphinx
2280

81+
OS-specific package manager
82+
---------------------------
83+
84+
You may install a global version of Sphinx into your system using OS-specific package
85+
managers. However, be aware that this is less flexible and you may run into
86+
compatibility issues if you want to work across different projects.
2387

2488
Linux
25-
-----
89+
~~~~~
2690

2791
Debian/Ubuntu
28-
~~~~~~~~~~~~~
92+
"""""""""""""
2993

3094
Install either ``python3-sphinx`` using :command:`apt-get`:
3195

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

38102
RHEL, CentOS
39-
~~~~~~~~~~~~
103+
""""""""""""
40104

41105
Install ``python-sphinx`` using :command:`yum`:
42106

@@ -47,7 +111,7 @@ Install ``python-sphinx`` using :command:`yum`:
47111
If it not already present, this will install Python for you.
48112

49113
Other distributions
50-
~~~~~~~~~~~~~~~~~~~
114+
"""""""""""""""""""
51115

52116
Most Linux distributions have Sphinx in their package repositories. Usually
53117
the package is called ``python3-sphinx``, ``python-sphinx`` or ``sphinx``. Be
@@ -57,17 +121,15 @@ a speech recognition toolkit (*CMU Sphinx*) and a full-text search database
57121

58122

59123
macOS
60-
-----
124+
~~~~~
61125

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

65128
__ https://brew.sh/
66129
__ https://www.macports.org/
67-
__ https://www.anaconda.com/download
68130

69131
Homebrew
70-
~~~~~~~~
132+
""""""""
71133

72134
::
73135

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

80142
MacPorts
81-
~~~~~~~~
143+
""""""""
82144

83145
Install either ``python3x-sphinx`` using :command:`port`:
84146

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

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

100-
Anaconda
101-
~~~~~~~~
102-
103-
::
104-
105-
$ conda install sphinx
106-
107162
Windows
108-
-------
163+
~~~~~~~
109164

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

113167
__ https://chocolatey.org/
114168

115169
Chocolatey
116-
~~~~~~~~~~
170+
""""""""""
117171

118172
::
119173

@@ -127,88 +181,6 @@ For more information, refer to the `chocolatey page`__.
127181

128182
__ https://chocolatey.org/packages/sphinx/
129183

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
212184

213185
Docker
214186
------
@@ -252,6 +224,20 @@ For more details, please read `README file`__ of docker images.
252224
.. __: https://hub.docker.com/r/sphinxdoc/sphinx
253225

254226

227+
Installation of the latest development release
228+
----------------------------------------------
229+
230+
You can install the latest development from *PyPI* using the ``--pre`` flag::
231+
232+
$ pip install -U --pre sphinx
233+
234+
.. warning::
235+
236+
You will not generally need (or want) to do this, but it can be
237+
useful if you see a possible bug in the latest stable release.
238+
239+
240+
255241
Installation from source
256242
------------------------
257243

0 commit comments

Comments
 (0)