Skip to content

Commit c063414

Browse files
committed
Build: install all the latest Python "core requirements"
I created a new feature flag called `INSTALL_LATEST_CORE_REQUIREMENTS` that does not depend on any other feature flag. Its goal is to always install the latest Python packages. We are trying to move away from pinning the dependencies on our side and telling users to do that on their side if they want to have reproducible builds over time. I think this is the best outcome for new projects since they will immediately use the latest versions of everything instead of old (and maybe broken) dependencies. I propose to set a particular date for this feature flag and make new projects to start building with all the latest dependencies. This will, at least, stop making the problem bigger. Later, we can decide how to communicate to old projects that we are going to install the latest requirements and if they don't want that, they should pin their dependencies. We can follow our new and shiny deprecation path we have built and tested in the last month. Related readthedocs/meta#8 Related #9562 Related #10402 Related #9081
1 parent 37650de commit c063414

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

readthedocs/doc_builder/python_environments.py

+61
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,67 @@ def install_core_requirements(self):
163163
'--no-cache-dir',
164164
]
165165

166+
if self.project.has_feature(Feature.INSTALL_LATEST_CORE_REQUIREMENTS):
167+
self._install_latest_requirements(pip_install_cmd)
168+
else:
169+
self._install_old_requirements(pip_install_cmd)
170+
171+
def _install_latest_requirements(self, pip_install_cmd):
172+
"""
173+
Install all the latest core requirements.
174+
175+
By enabling the feature flag ``INSTALL_LATEST_CORE_REQUIREMENTS``
176+
projects will automatically get installed all the latest core
177+
requirements: pip, sphinx, mock, alabaster, setuptools, etc.
178+
179+
This is the new behavior and where we are moving towards.
180+
"""
181+
# First, upgrade pip and setuptools to their latest versions
182+
cmd = pip_install_cmd + ["pip", "setuptools"]
183+
self.build_env.run(
184+
*cmd,
185+
bin_path=self.venv_bin(),
186+
cwd=self.checkout_path,
187+
)
188+
189+
# Second, install all the latest core requirements
190+
requirements = [
191+
"mock",
192+
"alabaster",
193+
"commonmark",
194+
"recommonmark",
195+
"setuptools",
196+
]
197+
198+
if self.config.doctype == "mkdocs":
199+
requirements.append("mkdocs")
200+
else:
201+
requirements.extend(
202+
[
203+
"sphinx",
204+
"sphinx-rtd-theme",
205+
"readthedocs-sphinx-ext",
206+
]
207+
)
208+
209+
cmd = copy.copy(pip_install_cmd)
210+
cmd.extend(requirements)
211+
self.build_env.run(
212+
*cmd,
213+
bin_path=self.venv_bin(),
214+
cwd=self.checkout_path,
215+
)
216+
217+
def _install_old_requirements(self, pip_install_cmd):
218+
"""
219+
Install old core requirements.
220+
221+
There are bunch of feature flags that will be taken in consideration to
222+
decide whether or not upgrade some of the core dependencies to their
223+
latest versions.
224+
225+
This is the old behavior and the one we want to get rid off.
226+
"""
166227
# Install latest pip and setuptools first,
167228
# so it is used when installing the other requirements.
168229
pip_version = self.project.get_feature_value(

readthedocs/projects/models.py

+7
Original file line numberDiff line numberDiff line change
@@ -1930,6 +1930,7 @@ def add_features(sender, **kwargs):
19301930
DEFAULT_TO_MKDOCS_0_17_3 = 'default_to_mkdocs_0_17_3'
19311931
USE_MKDOCS_LATEST = 'use_mkdocs_latest'
19321932
USE_SPHINX_RTD_EXT_LATEST = 'rtd_sphinx_ext_latest'
1933+
INSTALL_LATEST_CORE_REQUIREMENTS = "install_latest_core_requirements"
19331934

19341935
# Search related features
19351936
DISABLE_SERVER_SIDE_SEARCH = 'disable_server_side_search'
@@ -2044,6 +2045,12 @@ def add_features(sender, **kwargs):
20442045
USE_SPHINX_RTD_EXT_LATEST,
20452046
_("Sphinx: Use latest version of the Read the Docs Sphinx extension"),
20462047
),
2048+
(
2049+
INSTALL_LATEST_CORE_REQUIREMENTS,
2050+
_(
2051+
"Build: Install all the latest versions of Read the Docs core requirements"
2052+
),
2053+
),
20472054

20482055
# Search related features.
20492056
(

0 commit comments

Comments
 (0)