diff --git a/readthedocs/doc_builder/python_environments.py b/readthedocs/doc_builder/python_environments.py index bfd4916206d..b686fc41766 100644 --- a/readthedocs/doc_builder/python_environments.py +++ b/readthedocs/doc_builder/python_environments.py @@ -152,7 +152,7 @@ def install_core_requirements(self): self.venv_bin(filename='pip'), 'install', '--use-wheel', - '-U', + '--upgrade', '--cache-dir', self.project.pip_cache_path, ] @@ -182,14 +182,21 @@ def install_user_requirements(self): break if requirements_file_path: - self.build_env.run( + args = [ 'python', self.venv_bin(filename='pip'), 'install', + ] + if self.project.has_feature(Feature.PIP_ALWAYS_UPGRADE): + args += ['--upgrade'] + args += [ '--exists-action=w', '--cache-dir', self.project.pip_cache_path, '-r{0}'.format(requirements_file_path), + ] + self.build_env.run( + *args, cwd=self.checkout_path, bin_path=self.venv_bin() ) diff --git a/readthedocs/projects/models.py b/readthedocs/projects/models.py index 068c3622675..cac8e1248a7 100644 --- a/readthedocs/projects/models.py +++ b/readthedocs/projects/models.py @@ -1003,10 +1003,12 @@ def add_features(sender, **kwargs): # may be added by other packages USE_SPHINX_LATEST = 'use_sphinx_latest' USE_SETUPTOOLS_LATEST = 'use_setuptools_latest' + PIP_ALWAYS_UPGRADE = 'pip_always_upgrade' FEATURES = ( (USE_SPHINX_LATEST, _('Use latest version of Sphinx')), (USE_SETUPTOOLS_LATEST, _('Use latest version of setuptools')), + (PIP_ALWAYS_UPGRADE, _('Always run pip install --upgrade')), ) projects = models.ManyToManyField(