Skip to content

Commit b958bb8

Browse files
authored
Merge pull request #8777 from readthedocs/always-cap-setuptools
Cap setuptools even if installed packages are ignored
2 parents 794746a + 3c83edf commit b958bb8

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

readthedocs/doc_builder/python_environments.py

+4
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,10 @@ def install_core_requirements(self):
526526
# even if it is already installed system-wide (and
527527
# --system-site-packages is used)
528528
cmd.append('-I')
529+
# If this flag is present,
530+
# we need to cap setuptools again.
531+
# See https://github.com/readthedocs/readthedocs.org/issues/8775
532+
requirements.append('setuptools<58.3.0')
529533
cmd.extend(requirements)
530534
self.build_env.run(
531535
*cmd,

readthedocs/rtd_tests/tests/test_doc_building.py

+41-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* the Command wrappers encapsulate the bytes and expose unicode
66
"""
77
import hashlib
8+
from itertools import zip_longest
89
import json
910
import os
1011
import tempfile
@@ -1210,8 +1211,9 @@ def assertArgsStartsWith(self, args, call):
12101211
with each element of args.
12111212
"""
12121213
args_mock, _ = call
1213-
for arg, arg_mock in zip(args, args_mock):
1214+
for arg, arg_mock in zip_longest(args, args_mock):
12141215
if arg is not mock.ANY:
1216+
self.assertIsNotNone(arg_mock)
12151217
self.assertTrue(arg_mock.startswith(arg))
12161218

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

1246+
@mock.patch('readthedocs.doc_builder.config.load_config')
1247+
@patch('readthedocs.projects.models.Project.checkout_path')
1248+
def test_install_core_requirements_sphinx_system_packages_caps_setuptools(self, checkout_path, load_config):
1249+
config_data = {
1250+
'python': {
1251+
'use_system_site_packages': True,
1252+
},
1253+
}
1254+
load_config.side_effect = create_load(config_data)
1255+
config = load_yaml_config(self.version_sphinx)
1256+
1257+
tmpdir = tempfile.mkdtemp()
1258+
checkout_path.return_value = tmpdir
1259+
python_env = Virtualenv(
1260+
version=self.version_sphinx,
1261+
build_env=self.build_env_mock,
1262+
config=config,
1263+
)
1264+
python_env.install_core_requirements()
1265+
requirements_sphinx = [
1266+
'commonmark',
1267+
'recommonmark',
1268+
'sphinx',
1269+
'sphinx-rtd-theme',
1270+
'readthedocs-sphinx-ext',
1271+
'setuptools<58.3.0',
1272+
]
1273+
1274+
self.assertEqual(self.build_env_mock.run.call_count, 2)
1275+
calls = self.build_env_mock.run.call_args_list
1276+
1277+
core_args = self.pip_install_args + ['pip', 'setuptools<58.3.0']
1278+
self.assertArgsStartsWith(core_args, calls[0])
1279+
1280+
requirements = self.base_requirements + requirements_sphinx
1281+
args = self.pip_install_args + ['-I'] + requirements
1282+
self.assertArgsStartsWith(args, calls[1])
1283+
12441284
@patch('readthedocs.projects.models.Project.checkout_path')
12451285
def test_install_core_requirements_mkdocs(self, checkout_path):
12461286
tmpdir = tempfile.mkdtemp()

0 commit comments

Comments
 (0)