Skip to content

Cap setuptools even if installed packages are ignored #8777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions readthedocs/doc_builder/python_environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,10 @@ def install_core_requirements(self):
# even if it is already installed system-wide (and
# --system-site-packages is used)
cmd.append('-I')
# If this flag is present,
# we need to cap setuptools again.
# See https://github.com/readthedocs/readthedocs.org/issues/8775
requirements.append('setuptools<58.3.0')
cmd.extend(requirements)
self.build_env.run(
*cmd,
Expand Down
42 changes: 41 additions & 1 deletion readthedocs/rtd_tests/tests/test_doc_building.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* the Command wrappers encapsulate the bytes and expose unicode
"""
import hashlib
from itertools import zip_longest
import json
import os
import tempfile
Expand Down Expand Up @@ -1210,8 +1211,9 @@ def assertArgsStartsWith(self, args, call):
with each element of args.
"""
args_mock, _ = call
for arg, arg_mock in zip(args, args_mock):
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))

@patch('readthedocs.projects.models.Project.checkout_path')
Expand Down Expand Up @@ -1241,6 +1243,44 @@ def test_install_core_requirements_sphinx(self, checkout_path):
args = self.pip_install_args + requirements
self.assertArgsStartsWith(args, calls[1])

@mock.patch('readthedocs.doc_builder.config.load_config')
@patch('readthedocs.projects.models.Project.checkout_path')
def test_install_core_requirements_sphinx_system_packages_caps_setuptools(self, checkout_path, load_config):
config_data = {
'python': {
'use_system_site_packages': True,
},
}
load_config.side_effect = create_load(config_data)
config = load_yaml_config(self.version_sphinx)

tmpdir = tempfile.mkdtemp()
checkout_path.return_value = tmpdir
python_env = Virtualenv(
version=self.version_sphinx,
build_env=self.build_env_mock,
config=config,
)
python_env.install_core_requirements()
requirements_sphinx = [
'commonmark',
'recommonmark',
'sphinx',
'sphinx-rtd-theme',
'readthedocs-sphinx-ext',
'setuptools<58.3.0',
]

self.assertEqual(self.build_env_mock.run.call_count, 2)
calls = self.build_env_mock.run.call_args_list

core_args = self.pip_install_args + ['pip', 'setuptools<58.3.0']
self.assertArgsStartsWith(core_args, calls[0])

requirements = self.base_requirements + requirements_sphinx
args = self.pip_install_args + ['-I'] + requirements
self.assertArgsStartsWith(args, calls[1])

@patch('readthedocs.projects.models.Project.checkout_path')
def test_install_core_requirements_mkdocs(self, checkout_path):
tmpdir = tempfile.mkdtemp()
Expand Down