diff --git a/.flake8 b/.flake8 index d514d9f38fb..a229cfef0ad 100644 --- a/.flake8 +++ b/.flake8 @@ -1,3 +1,3 @@ [flake8] -ignore = E125,D100,D101,D102,D105,D200,D211,P101,FI15,FI16,FI12,FI11,FI17,FI50,FI53,FI54 +ignore = E125,D100,D101,D102,D105,D107,D200,D211,P101,FI15,FI16,FI12,FI11,FI17,FI50,FI53,FI54 max-line-length = 80 diff --git a/.isort.cfg b/.isort.cfg index 773d50df372..fc9d00977de 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -3,8 +3,7 @@ line_length=80 indent=' ' multi_line_output=4 default_section=FIRSTPARTY -known_readthedocs=readthedocs -known_readthedocsinc=readthedocsinc -known_third_party=celery,stripe,requests,pytz,builtins,django,annoying +known_firstparty=readthedocs,readthedocsinc +known_third_party=celery,stripe,requests,pytz,builtins,django,annoying,readthedocs_build sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER add_imports=from __future__ import division, from __future__ import print_function, from __future__ import unicode_literals diff --git a/readthedocs/doc_builder/config.py b/readthedocs/doc_builder/config.py index d6bf0fa516e..2ce1db0ad9c 100644 --- a/readthedocs/doc_builder/config.py +++ b/readthedocs/doc_builder/config.py @@ -1,11 +1,14 @@ +# -*- coding: utf-8 -*- """An API to load config from a readthedocs.yml file.""" -from __future__ import absolute_import -from builtins import (filter, object) +from __future__ import ( + absolute_import, division, print_function, unicode_literals) -from readthedocs_build.config import (ConfigError, BuildConfig, InvalidConfig, - load as load_config) -from .constants import BUILD_IMAGES, DOCKER_IMAGE +from builtins import filter, object +from readthedocs_build.config import load as load_config +from readthedocs_build.config import BuildConfig, ConfigError, InvalidConfig + +from .constants import DOCKER_BUILD_IMAGES, DOCKER_IMAGE class ConfigWrapper(object): @@ -18,7 +21,6 @@ class ConfigWrapper(object): We only currently implement a subset of the existing YAML config. This should be the canonical source for our usage of the YAML files, never accessing the config object directly. - """ def __init__(self, version, yaml_config): @@ -53,10 +55,12 @@ def python_interpreter(self): if ver in [2, 3]: # Get the highest version of the major series version if user only # gave us a version of '2', or '3' - ver = max(list(filter( - lambda x: x < ver + 1, - self._yaml_config.get_valid_python_versions(), - ))) + ver = max( + list( + filter( + lambda x: x < ver + 1, + self._yaml_config.get_valid_python_versions(), + ))) return 'python{0}'.format(ver) @property @@ -118,8 +122,8 @@ def load_yaml_config(version): """ Load a configuration from `readthedocs.yml` file. - This uses the configuration logic from `readthedocs-build`, - which will keep parsing consistent between projects. + This uses the configuration logic from `readthedocs-build`, which will keep + parsing consistent between projects. """ checkout_path = version.project.checkout_path(version.slug) env_config = {} @@ -127,9 +131,9 @@ def load_yaml_config(version): # Get build image to set up the python version validation. Pass in the # build image python limitations to the loaded config so that the versions # can be rejected at validation - build_image = BUILD_IMAGES.get( + build_image = DOCKER_BUILD_IMAGES.get( version.project.container_image, - BUILD_IMAGES.get(DOCKER_IMAGE, None), + DOCKER_BUILD_IMAGES.get(DOCKER_IMAGE, None), ) if build_image: env_config = { @@ -147,7 +151,8 @@ def load_yaml_config(version): path=checkout_path, env_config=sphinx_env_config, )[0] - except InvalidConfig: # This is a subclass of ConfigError, so has to come first + except InvalidConfig: + # This is a subclass of ConfigError, so has to come first raise except ConfigError: config = BuildConfig( diff --git a/readthedocs/doc_builder/constants.py b/readthedocs/doc_builder/constants.py index 4e96b7ddc6d..18caa705028 100644 --- a/readthedocs/doc_builder/constants.py +++ b/readthedocs/doc_builder/constants.py @@ -1,22 +1,36 @@ -"""Doc build constants""" +# -*- coding: utf-8 -*- +"""Doc build constants.""" + +from __future__ import ( + absolute_import, division, print_function, unicode_literals) -from __future__ import absolute_import import os import re from django.conf import settings - -SPHINX_TEMPLATE_DIR = os.path.join(settings.SITE_ROOT, 'readthedocs', - 'templates', 'sphinx') -MKDOCS_TEMPLATE_DIR = os.path.join(settings.SITE_ROOT, 'readthedocs', - 'templates', 'mkdocs') +SPHINX_TEMPLATE_DIR = os.path.join( + settings.SITE_ROOT, + 'readthedocs', + 'templates', + 'sphinx', +) +MKDOCS_TEMPLATE_DIR = os.path.join( + settings.SITE_ROOT, + 'readthedocs', + 'templates', + 'mkdocs', +) SPHINX_STATIC_DIR = os.path.join(SPHINX_TEMPLATE_DIR, '_static') PDF_RE = re.compile('Output written on (.*?)') # Docker -DOCKER_SOCKET = getattr(settings, 'DOCKER_SOCKET', 'unix:///var/run/docker.sock') +DOCKER_SOCKET = getattr( + settings, + 'DOCKER_SOCKET', + 'unix:///var/run/docker.sock', +) DOCKER_VERSION = getattr(settings, 'DOCKER_VERSION', 'auto') DOCKER_IMAGE = getattr(settings, 'DOCKER_IMAGE', 'readthedocs/build:2.0') DOCKER_LIMITS = {'memory': '200m', 'time': 600} @@ -28,7 +42,7 @@ DOCKER_HOSTNAME_MAX_LEN = 64 # Build images -BUILD_IMAGES = { +DOCKER_BUILD_IMAGES = { 'readthedocs/build:1.0': { 'python': {'supported_versions': [2, 2.7, 3, 3.4]}, }, @@ -39,3 +53,4 @@ 'python': {'supported_versions': [2, 2.7, 3, 3.3, 3.4, 3.5, 3.6]}, }, } +DOCKER_BUILD_IMAGES.update(getattr(settings, 'DOCKER_BUILD_IMAGES', {}))