|
1 | 1 | Reproducible Builds
|
2 | 2 | ===================
|
3 | 3 |
|
4 |
| -Your docs depend on tools and other dependencies to be built. |
| 4 | +Your documentation depends on a number of dependencies to be built. |
5 | 5 | If your docs don't have reproducible builds,
|
6 | 6 | an update in a dependency can break your builds when least expected,
|
7 | 7 | or make your docs look different from your local version.
|
8 |
| -This guide will help you to keep your builds working over time, and in a reproducible way. |
| 8 | +This guide will help you to keep your builds working over time, |
| 9 | +so that you can focus on content. |
9 | 10 |
|
10 | 11 | .. contents:: Contents
|
11 | 12 | :local:
|
12 | 13 | :depth: 3
|
13 | 14 |
|
14 |
| -Building your docs |
15 |
| ------------------- |
| 15 | +Use a ``.readthedocs.yaml`` configuration file |
| 16 | +---------------------------------------------- |
16 | 17 |
|
17 |
| -To test your build process, you can build them locally in a clean environment |
18 |
| -(this is without any dependencies installed). |
19 |
| -Then you should make sure you are running those same steps on Read the Docs. |
20 | 18 |
|
21 |
| -You can configure how your project is built from the web interface (:guilabel:`Admin` tab), |
22 |
| -or by :ref:`using a configuration file <guides/reproducible-builds:using a configuration file>` (recommended). |
23 |
| -If you aren't familiar with these tools, check our docs: |
| 19 | +We recommend using a :doc:`configuration file </config-file/v2>` to manage your documentation. |
| 20 | +Our config file *provides you per version settings*, |
| 21 | +and *those settings live in your Git repository*. |
24 | 22 |
|
25 |
| -- :doc:`/intro/getting-started-with-sphinx` |
26 |
| -- :doc:`/intro/getting-started-with-mkdocs` |
27 |
| -- :doc:`/config-file/v2` |
| 23 | +This allows you to validate changes using :doc:`pull requests </pull-requests>`, |
| 24 | +and ensures that all your versions can be rebuilt from a reproducible configuration. |
28 | 25 |
|
29 |
| -.. note:: |
| 26 | +Use a requirements file for Python dependencies |
| 27 | +----------------------------------------------- |
30 | 28 |
|
31 |
| - You can see the exact commands that are run on Read the Docs by going to the :guilabel:`Builds` tab of your project. |
32 |
| - |
33 |
| -Using a configuration file |
34 |
| --------------------------- |
35 |
| - |
36 |
| -If you use the web interface to configure your project, |
37 |
| -the options are applied to *all* versions and builds of your docs, |
38 |
| -and can be lost after changing them over time. |
39 |
| -Using a :doc:`configuration file </config-file/v2>` **provides you per version settings**, |
40 |
| -and **those settings live in your repository**. |
| 29 | +We recommend using a Pip :ref:`requirements file <pip:requirements-file-format>` or Conda :ref:`environment file <config-file/v2:conda.environment>` to pin Python dependencies. |
| 30 | +This ensures that top-level dependencies and extensions don't change. |
41 | 31 |
|
42 | 32 | A configuration file with explicit dependencies looks like this:
|
43 | 33 |
|
@@ -68,130 +58,27 @@ A configuration file with explicit dependencies looks like this:
|
68 | 58 | sphinx_rtd_theme==1.1.1
|
69 | 59 | readthedocs-sphinx-search==0.1.1
|
70 | 60 |
|
71 |
| -Don't rely on implicit dependencies |
72 |
| ------------------------------------ |
73 |
| - |
74 |
| -By default Read the Docs will install the tool you chose to build your docs, |
75 |
| -and other dependencies, this is done so new users can build their docs without much configuration. |
76 |
| - |
77 |
| -We highly recommend not to assume these dependencies will always be present or that their versions won't change. |
78 |
| -Always declare your dependencies explicitly using a :ref:`configuration file <guides/reproducible-builds:using a configuration file>`, |
79 |
| -for example: |
80 |
| - |
81 |
| -✅ Good: |
82 |
| - Your project is declaring the Python version explicitly, |
83 |
| - and its dependencies using a requirements file. |
84 |
| - |
85 |
| - .. code-block:: yaml |
86 |
| - :caption: .readthedocs.yaml |
87 |
| -
|
88 |
| - version: 2 |
89 |
| -
|
90 |
| - build: |
91 |
| - os: "ubuntu-22.04" |
92 |
| - tools: |
93 |
| - python: "3.11" |
94 |
| -
|
95 |
| - sphinx: |
96 |
| - configuration: docs/conf.py |
97 |
| -
|
98 |
| - python: |
99 |
| - install: |
100 |
| - - requirements: docs/requirements.txt |
101 |
| -
|
102 |
| -❌ Bad: |
103 |
| - Your project is relying on the default Python version and default installed dependencies. |
104 |
| - |
105 |
| - .. code-block:: yaml |
106 |
| - :caption: .readthedocs.yaml |
107 |
| -
|
108 |
| - version: 2 |
109 |
| -
|
110 |
| - sphinx: |
111 |
| - configuration: docs/conf.py |
112 |
| -
|
113 |
| -Pinning dependencies |
114 |
| --------------------- |
115 |
| - |
116 |
| -As you shouldn't rely on implicit dependencies, |
117 |
| -you shouldn't rely on undefined versions of your dependencies. |
118 |
| -Some examples: |
119 |
| - |
120 |
| -✅ Good: |
121 |
| - The specified versions will be used for all your builds, |
122 |
| - in all platforms, and won't be updated unexpectedly. |
123 |
| - |
124 |
| - .. code-block:: |
125 |
| - :caption: docs/requirements.txt |
126 |
| -
|
127 |
| - sphinx==5.3.0 |
128 |
| - sphinx_rtd_theme==1.1.1 |
129 |
| - readthedocs-sphinx-search==0.1.2 |
130 |
| -
|
131 |
| - .. code-block:: yaml |
132 |
| - :caption: docs/environment.yaml |
133 |
| -
|
134 |
| - name: docs |
135 |
| - channels: |
136 |
| - - conda-forge |
137 |
| - - defaults |
138 |
| - dependencies: |
139 |
| - - sphinx==5.3.0 |
140 |
| - - nbsphinx==0.8.10 |
141 |
| - - pip: |
142 |
| - - sphinx_rtd_theme==1.1.1 |
143 |
| -
|
144 |
| -❌ Bad: |
145 |
| - The latest or any other already installed version will be used, |
146 |
| - and your builds can fail or change unexpectedly any time. |
147 |
| - |
148 |
| - .. code-block:: |
149 |
| - :caption: docs/requirements.txt |
150 |
| -
|
151 |
| - sphinx |
152 |
| - sphinx_rtd_theme |
153 |
| - readthedocs-sphinx-search |
154 |
| -
|
155 |
| - .. code-block:: yaml |
156 |
| - :caption: docs/environment.yaml |
157 |
| -
|
158 |
| - name: docs |
159 |
| - channels: |
160 |
| - - conda-forge |
161 |
| - - defaults |
162 |
| - dependencies: |
163 |
| - - sphinx |
164 |
| - - nbsphinx |
165 |
| - - pip: |
166 |
| - - sphinx_rtd_theme |
167 |
| -
|
168 |
| -Check the `pip user guide`_ for more information about requirements files, |
169 |
| -or our Conda docs about :ref:`environment files <guides/conda:creating the \`\`environment.yml\`\`>`. |
170 |
| - |
171 |
| -.. _`pip user guide`: https://pip.pypa.io/en/stable/user_guide/#requirements-files |
172 |
| - |
173 | 61 | .. tip::
|
174 | 62 |
|
175 | 63 | Remember to update your docs' dependencies from time to time to get new improvements and fixes.
|
176 | 64 | It also makes it easy to manage in case a version reaches its end of support date.
|
177 | 65 |
|
178 |
| - |
179 |
| -Pinning transitive dependencies |
180 |
| -------------------------------- |
| 66 | +Pin your transitive dependencies |
| 67 | +-------------------------------- |
181 | 68 |
|
182 | 69 | Once you have pinned your own dependencies,
|
183 | 70 | the next things to worry about are the dependencies of your dependencies.
|
184 | 71 | These are called *transitive dependencies*,
|
185 | 72 | and they can upgrade without warning if you do not pin these packages as well.
|
186 | 73 |
|
187 | 74 | We recommend `pip-tools`_ to help address this problem.
|
188 |
| -It allows you to specify a ``requirements.in`` file with your first-level dependencies, |
| 75 | +It allows you to specify a ``requirements.in`` file with your top-level dependencies, |
189 | 76 | and it generates a ``requirements.txt`` file with the full set of transitive dependencies.
|
190 | 77 |
|
191 | 78 | .. _pip-tools: https://pip-tools.readthedocs.io/en/latest/
|
192 | 79 |
|
193 | 80 | ✅ Good:
|
194 |
| - All your transitive dependencies will stay defined, |
| 81 | + All your transitive dependencies are defined, |
195 | 82 | which ensures new package releases will not break your docs.
|
196 | 83 |
|
197 | 84 | .. code-block::
|
@@ -252,3 +139,27 @@ and it generates a ``requirements.txt`` file with the full set of transitive dep
|
252 | 139 | # via sphinx
|
253 | 140 | urllib3==1.26.13
|
254 | 141 | # via requests
|
| 142 | +
|
| 143 | +Check list ✅ |
| 144 | +------------- |
| 145 | + |
| 146 | +If you followed this guide, |
| 147 | +you have pinned: |
| 148 | + |
| 149 | +* tool versions (Python, Node) |
| 150 | +* top-level dependencies (Sphinx, Sphinx extensions) |
| 151 | +* transitive dependencies (Pytz, Jinja2) |
| 152 | + |
| 153 | +This will protect your builds from failures because of a random tool or dependency update. |
| 154 | + |
| 155 | +You do still need to upgrade your dependencies from time to time, |
| 156 | +but you should do that on your own schedule. |
| 157 | + |
| 158 | +.. seealso:: |
| 159 | + |
| 160 | + :doc:`/config-file/v2` |
| 161 | + Configuration file reference |
| 162 | + :doc:`/builds` |
| 163 | + Build process information |
| 164 | + :doc:`/build-customization` |
| 165 | + Customizing builds to do more |
0 commit comments