From 718aa8e48f224307816dc906a90488a0fc3ee12d Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Thu, 29 Nov 2018 13:32:18 -0500 Subject: [PATCH 1/4] Install latest version of pip Closes #4823 --- .../doc_builder/python_environments.py | 31 +++++++++++++------ .../rtd_tests/tests/test_doc_building.py | 4 +-- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/readthedocs/doc_builder/python_environments.py b/readthedocs/doc_builder/python_environments.py index 882a0ebbbc5..590ab64ab2f 100644 --- a/readthedocs/doc_builder/python_environments.py +++ b/readthedocs/doc_builder/python_environments.py @@ -223,6 +223,24 @@ def setup_base(self): def install_core_requirements(self): """Install basic Read the Docs requirements into the virtualenv.""" + pip_install_cmd = [ + 'python', + self.venv_bin(filename='pip'), + 'install', + '--upgrade', + '--cache-dir', + self.project.pip_cache_path, + ] + + # Install latest pip first, + # so it is used when installing the other requirements. + cmd = pip_install_cmd + ['pip==18.1'] + self.build_env.run( + *cmd, + bin_path=self.venv_bin(), + cwd=self.checkout_path + ) + requirements = [ 'Pygments==2.2.0', # Assume semver for setuptools version, support up to next backwards @@ -255,21 +273,14 @@ def install_core_requirements(self): 'readthedocs-sphinx-ext<0.6' ]) - cmd = [ - 'python', - self.venv_bin(filename='pip'), - 'install', - '--upgrade', - '--cache-dir', - self.project.pip_cache_path, - ] + cmd = pip_install_cmd if self.config.python.use_system_site_packages: # Other code expects sphinx-build to be installed inside the # virtualenv. Using the -I option makes sure it gets installed # even if it is already installed system-wide (and # --system-site-packages is used) - cmd.append('-I') - cmd.extend(requirements) + cmd += ['-I'] + cmd += requirements self.build_env.run( *cmd, bin_path=self.venv_bin(), diff --git a/readthedocs/rtd_tests/tests/test_doc_building.py b/readthedocs/rtd_tests/tests/test_doc_building.py index 940815cd90f..014e48cff35 100644 --- a/readthedocs/rtd_tests/tests/test_doc_building.py +++ b/readthedocs/rtd_tests/tests/test_doc_building.py @@ -1193,7 +1193,7 @@ def test_install_core_requirements_sphinx(self, checkout_path): ] requirements = self.base_requirements + requirements_sphinx args = self.pip_install_args + requirements - self.build_env_mock.run.assert_called_once() + self.assertEqual(self.build_env_mock.run.call_count, 2) self.assertArgsStartsWith(args, self.build_env_mock.run) @patch('readthedocs.projects.models.Project.checkout_path') @@ -1212,7 +1212,7 @@ def test_install_core_requirements_mkdocs(self, checkout_path): ] requirements = self.base_requirements + requirements_mkdocs args = self.pip_install_args + requirements - self.build_env_mock.run.assert_called_once() + self.assertEqual(self.build_env_mock.run.call_count, 2) self.assertArgsStartsWith(args, self.build_env_mock.run) @patch('readthedocs.projects.models.Project.checkout_path') From f4815c08028b2b474d7780c272e94a9a8997c4ec Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Mon, 3 Dec 2018 11:00:59 -0500 Subject: [PATCH 2/4] Copy list explicitly --- readthedocs/doc_builder/python_environments.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/readthedocs/doc_builder/python_environments.py b/readthedocs/doc_builder/python_environments.py index 590ab64ab2f..aebde9775cd 100644 --- a/readthedocs/doc_builder/python_environments.py +++ b/readthedocs/doc_builder/python_environments.py @@ -273,14 +273,14 @@ def install_core_requirements(self): 'readthedocs-sphinx-ext<0.6' ]) - cmd = pip_install_cmd + cmd = pip_install_cmd.copy() if self.config.python.use_system_site_packages: # Other code expects sphinx-build to be installed inside the # virtualenv. Using the -I option makes sure it gets installed # even if it is already installed system-wide (and # --system-site-packages is used) - cmd += ['-I'] - cmd += requirements + cmd.append('-I') + cmd.extend(requirements) self.build_env.run( *cmd, bin_path=self.venv_bin(), From e98083a6b422666ec9ec6abb20577b2530249147 Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Mon, 3 Dec 2018 11:06:56 -0500 Subject: [PATCH 3/4] Unpin pip --- 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 aebde9775cd..b09365cbadd 100644 --- a/readthedocs/doc_builder/python_environments.py +++ b/readthedocs/doc_builder/python_environments.py @@ -234,7 +234,7 @@ def install_core_requirements(self): # Install latest pip first, # so it is used when installing the other requirements. - cmd = pip_install_cmd + ['pip==18.1'] + cmd = pip_install_cmd + ['pip'] self.build_env.run( *cmd, bin_path=self.venv_bin(), From 2adec8c0105acd3ef6580f22726c244268b5b9c1 Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Tue, 4 Dec 2018 10:59:22 -0500 Subject: [PATCH 4/4] Python2 again --- readthedocs/doc_builder/python_environments.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/readthedocs/doc_builder/python_environments.py b/readthedocs/doc_builder/python_environments.py index b09365cbadd..fa9bd9f8bf3 100644 --- a/readthedocs/doc_builder/python_environments.py +++ b/readthedocs/doc_builder/python_environments.py @@ -2,16 +2,21 @@ """An abstraction over virtualenv and Conda environments.""" from __future__ import ( - absolute_import, division, print_function, unicode_literals) + absolute_import, + division, + print_function, + unicode_literals, +) +import copy import itertools import json import logging import os import shutil -from builtins import object, open import six +from builtins import object, open from django.conf import settings from readthedocs.doc_builder.config import load_yaml_config @@ -273,7 +278,7 @@ def install_core_requirements(self): 'readthedocs-sphinx-ext<0.6' ]) - cmd = pip_install_cmd.copy() + cmd = copy.copy(pip_install_cmd) if self.config.python.use_system_site_packages: # Other code expects sphinx-build to be installed inside the # virtualenv. Using the -I option makes sure it gets installed