Skip to content

New config for new docker build images #8478

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 13 commits into from
Sep 21, 2021
20 changes: 16 additions & 4 deletions readthedocs/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from .find import find_one
from .models import (
Build,
BuildTool,
BuildWithTools,
Conda,
Mkdocs,
Expand Down Expand Up @@ -1252,10 +1253,21 @@ def conda(self):
@property
@lru_cache(maxsize=1)
def build(self):
klass = Build
if 'os' in self._config['build']:
klass = BuildWithTools
return klass(**self._config['build'])
build = self._config['build']
if 'os' in build:
tools = {
tool: BuildTool(
version=version,
full_version=self.settings['tools'][tool][version],
)
for tool, version in build['tools'].items()
}
return BuildWithTools(
os=build['os'],
tools=tools,
apt_packages=build['apt_packages'],
)
return Build(**build)

@property
def python(self):
Expand Down
5 changes: 5 additions & 0 deletions readthedocs/config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ def __init__(self, **kwargs):
super().__init__(**kwargs)


class BuildTool(Base):

__slots__ = ('version', 'full_version')


class Python(Base):

__slots__ = ('version', 'install', 'use_system_site_packages')
Expand Down
7 changes: 4 additions & 3 deletions readthedocs/config/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,8 @@ def test_new_build_config(self):
assert build.using_build_tools
assert isinstance(build.build, BuildWithTools)
assert build.build.os == 'ubuntu-20.04'
assert build.build.tools == {'python': '3.9'}
assert build.build.tools['python'].version == '3.9'
assert build.build.tools['python'].full_version == '3.9.7'

def test_new_build_config_conflict_with_build_image(self):
build = self.get_build_config(
Expand Down Expand Up @@ -2286,8 +2287,8 @@ def test_as_dict_new_build_config(self, tmpdir):
'build': {
'os': 'ubuntu-20.04',
'tools': {
'python': '3.9',
'nodejs': '16',
'python': {'version': '3.9', 'full_version': '3.9.7'},
'nodejs': {'version': '16', 'full_version': '16.9.1'},
},
'apt_packages': [],
},
Expand Down