From 494df115a922bc6a43dee5c01daf036fa6af0159 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 3 Aug 2022 16:55:24 +0200 Subject: [PATCH 1/6] Build: unpin Pillow for unsupported Python versions Pillow supports specific versions of Python. They are shown in this table: https://pillow.readthedocs.io/en/stable/installation.html#python-support For unsupported Python versions, they don't offer wheels. Meaning that Read the Docs needs to compile the Pillow version on each build. Ideally, we should unpin Pillow completely and install always the latest version that's supported for this particular Python (as we do with other requirements like Sphinx or MkDocs). However, this commit kept old Python versions to keep using `Pillow==5.4.1`. --- readthedocs/doc_builder/python_environments.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/readthedocs/doc_builder/python_environments.py b/readthedocs/doc_builder/python_environments.py index 86db7acb894..8723b5ace87 100644 --- a/readthedocs/doc_builder/python_environments.py +++ b/readthedocs/doc_builder/python_environments.py @@ -171,12 +171,18 @@ def install_core_requirements(self): requirements = [ 'mock==1.0.1', - 'pillow==5.4.1', 'alabaster>=0.7,<0.8,!=0.7.5', 'commonmark==0.8.1', 'recommonmark==0.5.0', ] + # Avoid re-compiling Pillow on newer Python versions + # https://pillow.readthedocs.io/en/stable/installation.html#python-support + if self.config.python.version in ("2.7", "3.4", "3.5", "3.6", "3.7"): + requirements.append("pillow==5.4.1") + else: + requirements.append("pillow") + if self.config.doctype == 'mkdocs': requirements.append( self.project.get_feature_value( From 1ff50a4b0fe12ee514fde75323eda1d399ce4056 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 3 Aug 2022 17:41:34 +0200 Subject: [PATCH 2/6] Test: pip install command requires a specific order I'm putting `pillow` first to be able to compare it when running the tests. --- readthedocs/doc_builder/python_environments.py | 16 ++++++++++------ readthedocs/rtd_tests/tests/test_doc_building.py | 6 +++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/readthedocs/doc_builder/python_environments.py b/readthedocs/doc_builder/python_environments.py index 8723b5ace87..cec1c20a648 100644 --- a/readthedocs/doc_builder/python_environments.py +++ b/readthedocs/doc_builder/python_environments.py @@ -169,12 +169,7 @@ def install_core_requirements(self): *cmd, bin_path=self.venv_bin(), cwd=self.checkout_path ) - requirements = [ - 'mock==1.0.1', - 'alabaster>=0.7,<0.8,!=0.7.5', - 'commonmark==0.8.1', - 'recommonmark==0.5.0', - ] + requirements = [] # Avoid re-compiling Pillow on newer Python versions # https://pillow.readthedocs.io/en/stable/installation.html#python-support @@ -183,6 +178,15 @@ def install_core_requirements(self): else: requirements.append("pillow") + requirements.extend( + [ + "mock==1.0.1", + "alabaster>=0.7,<0.8,!=0.7.5", + "commonmark==0.8.1", + "recommonmark==0.5.0", + ] + ) + if self.config.doctype == 'mkdocs': requirements.append( self.project.get_feature_value( diff --git a/readthedocs/rtd_tests/tests/test_doc_building.py b/readthedocs/rtd_tests/tests/test_doc_building.py index f1b2d570bad..dffbf295d2a 100644 --- a/readthedocs/rtd_tests/tests/test_doc_building.py +++ b/readthedocs/rtd_tests/tests/test_doc_building.py @@ -368,9 +368,9 @@ def setUp(self): self.build_env_mock = Mock() self.base_requirements = [ - 'mock', - 'pillow', - 'alabaster', + "pillow", + "mock", + "alabaster", ] self.base_conda_requirements = [ 'mock', From 05ce462f3197f8787e95d1ff046bda195f73f30a Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 3 Aug 2022 17:42:16 +0200 Subject: [PATCH 3/6] Test: show the argument not matching when failing --- readthedocs/rtd_tests/tests/test_doc_building.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readthedocs/rtd_tests/tests/test_doc_building.py b/readthedocs/rtd_tests/tests/test_doc_building.py index dffbf295d2a..6d1642780e9 100644 --- a/readthedocs/rtd_tests/tests/test_doc_building.py +++ b/readthedocs/rtd_tests/tests/test_doc_building.py @@ -395,7 +395,7 @@ def assertArgsStartsWith(self, args, call): for arg, arg_mock in zip_longest(args, args_mock): if arg is not mock.ANY: self.assertIsNotNone(arg_mock) - self.assertTrue(arg_mock.startswith(arg)) + self.assertTrue(arg_mock.startswith(arg), arg) @patch('readthedocs.projects.models.Project.checkout_path') def test_install_core_requirements_sphinx(self, checkout_path): From 04f81ab7df093e99714acc75fc7c7b79f52d69e1 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 3 Aug 2022 17:59:18 +0200 Subject: [PATCH 4/6] Test: order pip packages on test case --- readthedocs/projects/tests/test_build_tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readthedocs/projects/tests/test_build_tasks.py b/readthedocs/projects/tests/test_build_tasks.py index f4222bb8396..21f8f2243ad 100644 --- a/readthedocs/projects/tests/test_build_tasks.py +++ b/readthedocs/projects/tests/test_build_tasks.py @@ -579,8 +579,8 @@ def test_build_commands_executed(self, load_yaml_config): "install", "--upgrade", "--no-cache-dir", + "pillow", "mock==1.0.1", - "pillow==5.4.1", "alabaster>=0.7,<0.8,!=0.7.5", "commonmark==0.8.1", "recommonmark==0.5.0", From c8dade0b9b5dbfe6f0730e8e392f0f90a7888db4 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Mon, 8 Aug 2022 11:49:31 +0200 Subject: [PATCH 5/6] Docs: update document to mention the versions of pillow --- docs/user/build-default-versions.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/user/build-default-versions.rst b/docs/user/build-default-versions.rst index bb9a426c7a7..b6b961a45ef 100644 --- a/docs/user/build-default-versions.rst +++ b/docs/user/build-default-versions.rst @@ -58,7 +58,8 @@ mock: ``1.0.1`` (could be removed in the future). pillow: - ``5.4.1`` (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 + (could be removed in the future). alabaster: ``0.7.x`` (could be removed in the future). From bd5b0416884b45c4ee859b49acc7fa67565354d4 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Mon, 8 Aug 2022 11:50:31 +0200 Subject: [PATCH 6/6] Update readthedocs/doc_builder/python_environments.py Co-authored-by: Santos Gallegos --- readthedocs/doc_builder/python_environments.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readthedocs/doc_builder/python_environments.py b/readthedocs/doc_builder/python_environments.py index cec1c20a648..f3fa0276d0d 100644 --- a/readthedocs/doc_builder/python_environments.py +++ b/readthedocs/doc_builder/python_environments.py @@ -171,7 +171,7 @@ def install_core_requirements(self): requirements = [] - # Avoid re-compiling Pillow on newer Python versions + # Unpin Pillow on newer Python versions to avoid re-compiling # https://pillow.readthedocs.io/en/stable/installation.html#python-support if self.config.python.version in ("2.7", "3.4", "3.5", "3.6", "3.7"): requirements.append("pillow==5.4.1")