@@ -9,23 +9,110 @@ Installing Sphinx
9
9
10
10
.. highlight :: console
11
11
12
- Overview
13
- --------
12
+ Sphinx is a Python application.
14
13
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.
14
+ .. note ::
15
+
16
+ If you use Sphinx for documenting a Python library or application, it is
17
+ generally recommended to install Sphinx into your dev environment.
18
+ By adding Sphinx and 3rdparty extensions or themes that you use to your dev
19
+ dependencies, you make sure that you have a consistent setup for building
20
+ your documentation.
21
+
22
+ .. _install-pypi :
23
+
24
+ PyPI packages
25
+ -------------
26
+
27
+ Sphinx packages are published on the `Python Package Index
28
+ <https://pypi.org/project/Sphinx/> `_. The preferred tool for installing
29
+ packages from *PyPI * is :command: `pip `, which is included in all modern versions of
30
+ Python.
31
+
32
+ On Linux or MacOS, you should open your terminal and run the following command.
33
+
34
+ ::
35
+
36
+ $ pip install -U sphinx
37
+
38
+ On Windows, you should open *Command Prompt * (:kbd: `⊞Win - r ` and type
39
+ :command: `cmd `) and run the same command.
40
+
41
+ .. code-block :: doscon
42
+
43
+ C:\> pip install -U sphinx
44
+
45
+ After installation, type :command: `sphinx-build --version ` on the command
46
+ prompt. If everything worked fine, you will see the version number for the
47
+ Sphinx package you just installed.
48
+
49
+ .. note ::
50
+
51
+ Installation from *PyPI * also allows you to install the latest development
52
+ release. You will not generally need (or want) to do this, but it can be
53
+ useful if you see a possible bug in the latest stable release. To do this,
54
+ use the ``--pre `` flag::
55
+
56
+ $ pip install -U --pre sphinx
57
+
58
+ Using virtual environments
59
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
60
+
61
+ When installing Sphinx using pip, it is highly recommended to use *virtual
62
+ environments *, which isolate the installed packages from the system packages,
63
+ thus removing the need to use administrator privileges. To create a virtual
64
+ environment in the ``.venv `` directory, use the following command.
65
+
66
+ ::
67
+
68
+ $ python -m venv .venv
69
+
70
+ .. seealso :: :mod:`venv` -- creating virtual environments
71
+
72
+ .. warning ::
73
+
74
+ Note that in some Linux distributions, such as Debian and Ubuntu,
75
+ this might require an extra installation step as follows.
76
+
77
+ .. code-block :: console
78
+
79
+ $ apt-get install python3-venv
80
+
81
+ .. _install-conda :
82
+
83
+ Conda packages
84
+ --------------
85
+ To work with :command: `conda `, you need a conda-based Python distribution such as
86
+ `anaconda `__, `miniconda `__, `miniforge `__ or `micromamba `__.
87
+
88
+ __ https://docs.anaconda.com/anaconda/
89
+ __ https://docs.anaconda.com/miniconda/
90
+ __ https://github.com/conda-forge/miniforge/
91
+ __ https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html
92
+
93
+
94
+ Sphinx is available both via the *anaconda main * channel (maintained by Anaconda Inc.)
95
+
96
+ ::
97
+
98
+ $ conda install sphinx
99
+
100
+ as well as via the *conda-forge * community channel ::
18
101
19
- __ https://docs.python-guide.org/
20
- __ https://docutils.sourceforge.io/
21
- __ https://jinja.palletsprojects.com/
102
+ $ conda install -c conda-forge sphinx
22
103
104
+ OS-specific package managers
105
+ ----------------------------
106
+
107
+ You may install a global version of Sphinx into your system using OS-specific package
108
+ managers. However, be aware that this is less flexible and you may run into
109
+ compatibility issues if you want to work across different projects.
23
110
24
111
Linux
25
- -----
112
+ ~~~~~
26
113
27
114
Debian/Ubuntu
28
- ~~~~~~~~~~~~~
115
+ """""""""""""
29
116
30
117
Install either ``python3-sphinx `` using :command: `apt-get `:
31
118
@@ -36,7 +123,7 @@ Install either ``python3-sphinx`` using :command:`apt-get`:
36
123
If it not already present, this will install Python for you.
37
124
38
125
RHEL, CentOS
39
- ~~~~~~~~~~~~
126
+ """"""""""""
40
127
41
128
Install ``python-sphinx `` using :command: `yum `:
42
129
@@ -47,7 +134,7 @@ Install ``python-sphinx`` using :command:`yum`:
47
134
If it not already present, this will install Python for you.
48
135
49
136
Other distributions
50
- ~~~~~~~~~~~~~~~~~~~
137
+ """""""""""""""""""
51
138
52
139
Most Linux distributions have Sphinx in their package repositories. Usually
53
140
the package is called ``python3-sphinx ``, ``python-sphinx `` or ``sphinx ``. Be
@@ -57,17 +144,15 @@ a speech recognition toolkit (*CMU Sphinx*) and a full-text search database
57
144
58
145
59
146
macOS
60
- -----
147
+ ~~~~~
61
148
62
- Sphinx can be installed using `Homebrew `__, `MacPorts `__, or as part of
63
- a Python distribution such as `Anaconda `__.
149
+ Sphinx can be installed using `Homebrew `__, `MacPorts `__.
64
150
65
151
__ https://brew.sh/
66
152
__ https://www.macports.org/
67
- __ https://www.anaconda.com/download
68
153
69
154
Homebrew
70
- ~~~~~~~~
155
+ """"""""
71
156
72
157
::
73
158
@@ -78,7 +163,7 @@ For more information, refer to the `package overview`__.
78
163
__ https://formulae.brew.sh/formula/sphinx-doc
79
164
80
165
MacPorts
81
- ~~~~~~~~
166
+ """"""""
82
167
83
168
Install either ``python3x-sphinx `` using :command: `port `:
84
169
@@ -97,23 +182,16 @@ For more information, refer to the `package overview`__.
97
182
98
183
__ https://www.macports.org/ports.php?by=library&substr=py39-sphinx
99
184
100
- Anaconda
101
- ~~~~~~~~
102
-
103
- ::
104
-
105
- $ conda install sphinx
106
-
107
185
Windows
108
- -------
186
+ ~~~~~~~
109
187
110
188
Sphinx can be install using `Chocolatey `__ or
111
189
:ref: `installed manually <windows-other-method >`.
112
190
113
191
__ https://chocolatey.org/
114
192
115
193
Chocolatey
116
- ~~~~~~~~~~
194
+ """"""""""
117
195
118
196
::
119
197
@@ -127,88 +205,6 @@ For more information, refer to the `chocolatey page`__.
127
205
128
206
__ https://chocolatey.org/packages/sphinx/
129
207
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
208
213
209
Docker
214
210
------
0 commit comments