Skip to content

Commit faf4128

Browse files
committed
Support "pypy3.5" as Python version/interpreter
1 parent 34f549e commit faf4128

File tree

4 files changed

+29
-16
lines changed

4 files changed

+29
-16
lines changed

readthedocs/config/config.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,11 @@ def validate(self):
245245
@property
246246
def python_interpreter(self):
247247
ver = self.python_full_version
248-
return 'python{}'.format(ver)
248+
if not ver or isinstance(ver, (int, float)):
249+
return 'python{}'.format(ver)
250+
251+
# Allow to specify ``pypy3.5`` as Python interpreter
252+
return ver
249253

250254
@property
251255
def python_full_version(self):
@@ -254,7 +258,7 @@ def python_full_version(self):
254258
# Get the highest version of the major series version if user only
255259
# gave us a version of '2', or '3'
256260
ver = max(
257-
v for v in self.get_valid_python_versions() if v < ver + 1
261+
v for v in self.get_valid_python_versions() if not isinstance(v, str) and v < ver + 1
258262
)
259263
return ver
260264

readthedocs/config/tests/test_config.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,21 @@ def test_it_defaults_to_a_valid_version(self):
348348

349349
def test_it_supports_other_versions(self):
350350
build = get_build_config(
351-
{'python': {'version': 3.5}},
351+
{'python': {'version': 3.7}},
352352
)
353353
build.validate()
354-
assert build.python.version == 3.5
355-
assert build.python_interpreter == 'python3.5'
356-
assert build.python_full_version == 3.5
354+
assert build.python.version == 3.7
355+
assert build.python_interpreter == 'python3.7'
356+
assert build.python_full_version == 3.7
357+
358+
def test_it_supports_string_versions(self):
359+
build = get_build_config(
360+
{'python': {'version': 'pypy3.5'}},
361+
)
362+
build.validate()
363+
assert build.python.version == 'pypy3.5'
364+
assert build.python_interpreter == 'pypy3.5'
365+
assert build.python_full_version == 'pypy3.5'
357366

358367
def test_it_validates_versions_out_of_range(self):
359368
build = get_build_config(
@@ -375,12 +384,12 @@ def test_it_validates_wrong_type(self):
375384

376385
def test_it_validates_wrong_type_right_value(self):
377386
build = get_build_config(
378-
{'python': {'version': '3.5'}},
387+
{'python': {'version': '3.6'}},
379388
)
380389
build.validate()
381-
assert build.python.version == 3.5
382-
assert build.python_interpreter == 'python3.5'
383-
assert build.python_full_version == 3.5
390+
assert build.python.version == 3.6
391+
assert build.python_interpreter == 'python3.6'
392+
assert build.python_full_version == 3.6
384393

385394
build = get_build_config(
386395
{'python': {'version': '3'}},
@@ -716,7 +725,7 @@ def test_as_dict(tmpdir):
716725
'version': 1,
717726
'formats': ['pdf'],
718727
'python': {
719-
'version': 3.5,
728+
'version': 3.7,
720729
},
721730
'requirements_file': 'requirements.txt',
722731
},
@@ -733,7 +742,7 @@ def test_as_dict(tmpdir):
733742
'version': '1',
734743
'formats': ['pdf'],
735744
'python': {
736-
'version': 3.5,
745+
'version': 3.7,
737746
'install': [{
738747
'requirements': str(tmpdir.join('requirements.txt')),
739748
}],
@@ -944,8 +953,8 @@ def test_python_check_invalid_types(self, value):
944953
@pytest.mark.parametrize(
945954
'image,versions',
946955
[
947-
('latest', [2, 2.7, 3, 3.5, 3.6]),
948-
('stable', [2, 2.7, 3, 3.5, 3.6]),
956+
('latest', [2, 2.7, 3, 3.6, 3.7, 'pypy3.5']),
957+
('stable', [2, 2.7, 3, 3.6, 3.7]),
949958
],
950959
)
951960
def test_python_version(self, image, versions):

readthedocs/rtd_tests/tests/test_config_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def test_python_supported_versions_image_latest(self, load_config):
144144
config = load_yaml_config(self.version)
145145
self.assertEqual(
146146
config.get_valid_python_versions(),
147-
[2, 2.7, 3, 3.5, 3.6, 3.7],
147+
[2, 2.7, 3, 3.6, 3.7, 'pypy3.5'],
148148
)
149149

150150
@mock.patch('readthedocs.doc_builder.config.load_config')

readthedocs/settings/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ def USE_PROMOS(self): # noqa
330330
'python': {'supported_versions': [2, 2.7, 3, 3.5, 3.6, 3.7]},
331331
},
332332
'readthedocs/build:5.0': {
333-
'python': {'supported_versions': [2, 2.7, 3, 3.6, 3.7]},
333+
'python': {'supported_versions': [2, 2.7, 3, 3.6, 3.7, 'pypy3.5']},
334334
},
335335
}
336336

0 commit comments

Comments
 (0)