From 34f549ecbc5a8a51a3bf6f1d365bebdcb8d509aa Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Thu, 2 May 2019 12:10:01 +0200 Subject: [PATCH 1/3] New Docker Image release: make 4.0 stable and 5.0 latest --- readthedocs/settings/base.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/readthedocs/settings/base.py b/readthedocs/settings/base.py index d8a0f04e7e3..e80c218a6c6 100644 --- a/readthedocs/settings/base.py +++ b/readthedocs/settings/base.py @@ -329,12 +329,15 @@ def USE_PROMOS(self): # noqa 'readthedocs/build:4.0': { 'python': {'supported_versions': [2, 2.7, 3, 3.5, 3.6, 3.7]}, }, + 'readthedocs/build:5.0': { + 'python': {'supported_versions': [2, 2.7, 3, 3.6, 3.7]}, + }, } # Alias tagged via ``docker tag`` on the build servers DOCKER_IMAGE_SETTINGS.update({ - 'readthedocs/build:stable': DOCKER_IMAGE_SETTINGS.get('readthedocs/build:3.0'), - 'readthedocs/build:latest': DOCKER_IMAGE_SETTINGS.get('readthedocs/build:4.0'), + 'readthedocs/build:stable': DOCKER_IMAGE_SETTINGS.get('readthedocs/build:4.0'), + 'readthedocs/build:latest': DOCKER_IMAGE_SETTINGS.get('readthedocs/build:5.0'), }) # All auth From 714cfd985964543e7e5acdacc195b4e92577118c Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Thu, 2 May 2019 12:48:39 +0200 Subject: [PATCH 2/3] Support "pypy3.5" as Python version/interpreter --- readthedocs/config/config.py | 9 +++-- readthedocs/config/tests/test_config.py | 33 ++++++++++++------- .../tests/test_config_integration.py | 2 +- readthedocs/settings/base.py | 2 +- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/readthedocs/config/config.py b/readthedocs/config/config.py index f142b90f997..ad69cc07034 100644 --- a/readthedocs/config/config.py +++ b/readthedocs/config/config.py @@ -245,7 +245,11 @@ def validate(self): @property def python_interpreter(self): ver = self.python_full_version - return 'python{}'.format(ver) + if not ver or isinstance(ver, (int, float)): + return 'python{}'.format(ver) + + # Allow to specify ``pypy3.5`` as Python interpreter + return ver @property def python_full_version(self): @@ -254,7 +258,8 @@ def python_full_version(self): # Get the highest version of the major series version if user only # gave us a version of '2', or '3' ver = max( - v for v in self.get_valid_python_versions() if v < ver + 1 + v for v in self.get_valid_python_versions() + if not isinstance(v, str) and v < ver + 1 ) return ver diff --git a/readthedocs/config/tests/test_config.py b/readthedocs/config/tests/test_config.py index 404cf691211..8782f34ee88 100644 --- a/readthedocs/config/tests/test_config.py +++ b/readthedocs/config/tests/test_config.py @@ -348,12 +348,21 @@ def test_it_defaults_to_a_valid_version(self): def test_it_supports_other_versions(self): build = get_build_config( - {'python': {'version': 3.5}}, + {'python': {'version': 3.7}}, ) build.validate() - assert build.python.version == 3.5 - assert build.python_interpreter == 'python3.5' - assert build.python_full_version == 3.5 + assert build.python.version == 3.7 + assert build.python_interpreter == 'python3.7' + assert build.python_full_version == 3.7 + + def test_it_supports_string_versions(self): + build = get_build_config( + {'python': {'version': 'pypy3.5'}}, + ) + build.validate() + assert build.python.version == 'pypy3.5' + assert build.python_interpreter == 'pypy3.5' + assert build.python_full_version == 'pypy3.5' def test_it_validates_versions_out_of_range(self): build = get_build_config( @@ -375,12 +384,12 @@ def test_it_validates_wrong_type(self): def test_it_validates_wrong_type_right_value(self): build = get_build_config( - {'python': {'version': '3.5'}}, + {'python': {'version': '3.6'}}, ) build.validate() - assert build.python.version == 3.5 - assert build.python_interpreter == 'python3.5' - assert build.python_full_version == 3.5 + assert build.python.version == 3.6 + assert build.python_interpreter == 'python3.6' + assert build.python_full_version == 3.6 build = get_build_config( {'python': {'version': '3'}}, @@ -716,7 +725,7 @@ def test_as_dict(tmpdir): 'version': 1, 'formats': ['pdf'], 'python': { - 'version': 3.5, + 'version': 3.7, }, 'requirements_file': 'requirements.txt', }, @@ -733,7 +742,7 @@ def test_as_dict(tmpdir): 'version': '1', 'formats': ['pdf'], 'python': { - 'version': 3.5, + 'version': 3.7, 'install': [{ 'requirements': str(tmpdir.join('requirements.txt')), }], @@ -944,8 +953,8 @@ def test_python_check_invalid_types(self, value): @pytest.mark.parametrize( 'image,versions', [ - ('latest', [2, 2.7, 3, 3.5, 3.6]), - ('stable', [2, 2.7, 3, 3.5, 3.6]), + ('latest', [2, 2.7, 3, 3.6, 3.7, 'pypy3.5']), + ('stable', [2, 2.7, 3, 3.6, 3.7]), ], ) def test_python_version(self, image, versions): diff --git a/readthedocs/rtd_tests/tests/test_config_integration.py b/readthedocs/rtd_tests/tests/test_config_integration.py index a595b891b89..9a709bdb221 100644 --- a/readthedocs/rtd_tests/tests/test_config_integration.py +++ b/readthedocs/rtd_tests/tests/test_config_integration.py @@ -144,7 +144,7 @@ def test_python_supported_versions_image_latest(self, load_config): config = load_yaml_config(self.version) self.assertEqual( config.get_valid_python_versions(), - [2, 2.7, 3, 3.5, 3.6, 3.7], + [2, 2.7, 3, 3.6, 3.7, 'pypy3.5'], ) @mock.patch('readthedocs.doc_builder.config.load_config') diff --git a/readthedocs/settings/base.py b/readthedocs/settings/base.py index e80c218a6c6..aa5d94ab8c8 100644 --- a/readthedocs/settings/base.py +++ b/readthedocs/settings/base.py @@ -330,7 +330,7 @@ def USE_PROMOS(self): # noqa 'python': {'supported_versions': [2, 2.7, 3, 3.5, 3.6, 3.7]}, }, 'readthedocs/build:5.0': { - 'python': {'supported_versions': [2, 2.7, 3, 3.6, 3.7]}, + 'python': {'supported_versions': [2, 2.7, 3, 3.6, 3.7, 'pypy3.5']}, }, } From 1513a5f0f00c91fc5bd30964d12df468f27bb91a Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Thu, 16 May 2019 17:17:34 +0200 Subject: [PATCH 3/3] Add support for Python 3.5 in Docker 5.0 image --- readthedocs/config/tests/test_config.py | 4 ++-- readthedocs/rtd_tests/tests/test_config_integration.py | 2 +- readthedocs/settings/base.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/readthedocs/config/tests/test_config.py b/readthedocs/config/tests/test_config.py index 8782f34ee88..11a8f7ca1e8 100644 --- a/readthedocs/config/tests/test_config.py +++ b/readthedocs/config/tests/test_config.py @@ -953,8 +953,8 @@ def test_python_check_invalid_types(self, value): @pytest.mark.parametrize( 'image,versions', [ - ('latest', [2, 2.7, 3, 3.6, 3.7, 'pypy3.5']), - ('stable', [2, 2.7, 3, 3.6, 3.7]), + ('latest', [2, 2.7, 3, 3.5, 3.6, 3.7, 'pypy3.5']), + ('stable', [2, 2.7, 3, 3.5, 3.6, 3.7]), ], ) def test_python_version(self, image, versions): diff --git a/readthedocs/rtd_tests/tests/test_config_integration.py b/readthedocs/rtd_tests/tests/test_config_integration.py index 9a709bdb221..78faeb21f91 100644 --- a/readthedocs/rtd_tests/tests/test_config_integration.py +++ b/readthedocs/rtd_tests/tests/test_config_integration.py @@ -144,7 +144,7 @@ def test_python_supported_versions_image_latest(self, load_config): config = load_yaml_config(self.version) self.assertEqual( config.get_valid_python_versions(), - [2, 2.7, 3, 3.6, 3.7, 'pypy3.5'], + [2, 2.7, 3, 3.5, 3.6, 3.7, 'pypy3.5'], ) @mock.patch('readthedocs.doc_builder.config.load_config') diff --git a/readthedocs/settings/base.py b/readthedocs/settings/base.py index aa5d94ab8c8..614b33d5f81 100644 --- a/readthedocs/settings/base.py +++ b/readthedocs/settings/base.py @@ -330,7 +330,7 @@ def USE_PROMOS(self): # noqa 'python': {'supported_versions': [2, 2.7, 3, 3.5, 3.6, 3.7]}, }, 'readthedocs/build:5.0': { - 'python': {'supported_versions': [2, 2.7, 3, 3.6, 3.7, 'pypy3.5']}, + 'python': {'supported_versions': [2, 2.7, 3, 3.5, 3.6, 3.7, 'pypy3.5']}, }, }