diff --git a/docs/user/build-default-versions.rst b/docs/user/build-default-versions.rst index 8a232b1f45c..c353e4c6aba 100644 --- a/docs/user/build-default-versions.rst +++ b/docs/user/build-default-versions.rst @@ -47,6 +47,7 @@ Mkdocs: sphinx-rtd-theme: Projects created before October 20, 2020 (January 21, 2021 for :doc:`/commercial/index`) use ``0.4.3``. New projects use the latest version. + Projects created after August 7, 2023 won't install this dependency by default. pip: Latest version by default. @@ -54,22 +55,28 @@ pip: setuptools: Projects using ``setup.py install`` as installation method use ``58.2.0`` or older. All other projects use the latest version. + Projects created after August 7, 2023 will always use the latest version. mock: - ``1.0.1`` (could be removed in the future). + ``1.0.1``. + Projects created after August 7, 2023 won't install this dependency by default. + pillow: - ``5.4.1`` when using Python 2.7, 3.4, 3.5, 3.6, 3.7. Otherwise, its latest version - (could be removed in the future). + ``5.4.1`` when using Python 2.7, 3.4, 3.5, 3.6, 3.7. Otherwise, its latest version. + Projects created after August 7, 2023 won't install this dependency by default. alabaster: - ``0.7.x`` (could be removed in the future). + ``0.7.x``. + Projects created after August 7, 2023 won't install this dependency by default. commonmark: - ``0.8.1`` (could be removed in the future). + ``0.8.1``. + Projects created after August 7, 2023 won't install this dependency by default. recommonmark: - ``0.5.0`` (could be removed in the future). + ``0.5.0``. + Projects created after August 7, 2023 won't install this dependency by default. Conda ~~~~~ @@ -88,15 +95,19 @@ Sphinx: sphinx-rtd-theme: Latest version by default installed via ``conda``. + Projects created after August 7, 2023 won't install this dependency by default. mock: - Latest version by default installed via ``pip`` (could be removed in the future). + Latest version by default installed via ``pip``. + Projects created after August 7, 2023 won't install this dependency by default. pillow: - Latest version by default installed via ``pip`` (could be removed in the future). + Latest version by default installed via ``pip``. + Projects created after August 7, 2023 won't install this dependency by default. recommonmark: - Latest version by default installed via ``conda`` (could be removed in the future). + Latest version by default installed via ``conda``. + Projects created after August 7, 2023 won't install this dependency by default. Internal dependencies --------------------- diff --git a/readthedocs/doc_builder/python_environments.py b/readthedocs/doc_builder/python_environments.py index 0b85408400f..4b3759bfe48 100644 --- a/readthedocs/doc_builder/python_environments.py +++ b/readthedocs/doc_builder/python_environments.py @@ -163,6 +163,60 @@ def install_core_requirements(self): '--no-cache-dir', ] + if self.project.has_feature(Feature.INSTALL_LATEST_CORE_REQUIREMENTS): + self._install_latest_requirements(pip_install_cmd) + else: + self._install_old_requirements(pip_install_cmd) + + def _install_latest_requirements(self, pip_install_cmd): + """ + Install all the latest core requirements. + + By enabling the feature flag ``INSTALL_LATEST_CORE_REQUIREMENTS`` + projects will automatically get installed all the latest core + requirements: pip, setuptools, sphinx, readthedocs-sphinx-ext and mkdocs. + + This is the new behavior and where we are moving towards. + """ + # First, upgrade pip and setuptools to their latest versions + cmd = pip_install_cmd + ["pip", "setuptools"] + self.build_env.run( + *cmd, + bin_path=self.venv_bin(), + cwd=self.checkout_path, + ) + + # Second, install all the latest core requirements + requirements = [] + + if self.config.doctype == "mkdocs": + requirements.append("mkdocs") + else: + requirements.extend( + [ + "sphinx", + "readthedocs-sphinx-ext", + ] + ) + + cmd = copy.copy(pip_install_cmd) + cmd.extend(requirements) + self.build_env.run( + *cmd, + bin_path=self.venv_bin(), + cwd=self.checkout_path, + ) + + def _install_old_requirements(self, pip_install_cmd): + """ + Install old core requirements. + + There are bunch of feature flags that will be taken in consideration to + decide whether or not upgrade some of the core dependencies to their + latest versions. + + This is the old behavior and the one we want to get rid off. + """ # Install latest pip and setuptools first, # so it is used when installing the other requirements. pip_version = self.project.get_feature_value( @@ -420,7 +474,10 @@ def _append_core_requirements(self): else: # Append conda dependencies directly to ``dependencies`` and pip # dependencies to ``dependencies.pip`` - pip_requirements, conda_requirements = self._get_core_requirements() + if self.project.has_feature(Feature.INSTALL_LATEST_CORE_REQUIREMENTS): + pip_requirements, conda_requirements = self._get_new_core_requirements() + else: + pip_requirements, conda_requirements = self._get_old_core_requirements() dependencies = environment.get('dependencies', []) pip_dependencies = {'pip': pip_requirements} @@ -458,7 +515,22 @@ def _append_core_requirements(self): 'environment file.', ) - def _get_core_requirements(self): + def _get_new_core_requirements(self): + # Use conda for requirements it packages + conda_requirements = [] + + # Install pip-only things. + pip_requirements = [] + + if self.config.doctype == "mkdocs": + pip_requirements.append("mkdocs") + else: + pip_requirements.append("readthedocs-sphinx-ext") + conda_requirements.extend(["sphinx"]) + + return pip_requirements, conda_requirements + + def _get_old_core_requirements(self): # Use conda for requirements it packages conda_requirements = [ 'mock', @@ -487,7 +559,7 @@ def install_core_requirements(self): # create`` step. return - pip_requirements, conda_requirements = self._get_core_requirements() + pip_requirements, conda_requirements = self._get_old_core_requirements() # Install requirements via ``conda install`` command if they were # not appended to the ``environment.yml`` file. cmd = [ diff --git a/readthedocs/projects/models.py b/readthedocs/projects/models.py index dfa145138f8..8daa7d816ee 100644 --- a/readthedocs/projects/models.py +++ b/readthedocs/projects/models.py @@ -1930,6 +1930,7 @@ def add_features(sender, **kwargs): DEFAULT_TO_MKDOCS_0_17_3 = 'default_to_mkdocs_0_17_3' USE_MKDOCS_LATEST = 'use_mkdocs_latest' USE_SPHINX_RTD_EXT_LATEST = 'rtd_sphinx_ext_latest' + INSTALL_LATEST_CORE_REQUIREMENTS = "install_latest_core_requirements" # Search related features DISABLE_SERVER_SIDE_SEARCH = 'disable_server_side_search' @@ -2044,6 +2045,12 @@ def add_features(sender, **kwargs): USE_SPHINX_RTD_EXT_LATEST, _("Sphinx: Use latest version of the Read the Docs Sphinx extension"), ), + ( + INSTALL_LATEST_CORE_REQUIREMENTS, + _( + "Build: Install all the latest versions of Read the Docs core requirements" + ), + ), # Search related features. (