Fix #2436: Sphinx does not check version by :confval:needs_sphinx if loading extensions failed

This commit is contained in:
Takeshi KOMIYA 2016-04-16 16:55:59 +09:00
parent f15bdce1db
commit febfd6829c
3 changed files with 12 additions and 7 deletions

View File

@ -12,6 +12,7 @@ Bugs fixed
* #2370: the equations are slightly misaligned in LaTeX writer * #2370: the equations are slightly misaligned in LaTeX writer
* #1817, #2077: suppress pep8 warnings on conf.py generated by sphinx-quickstart * #1817, #2077: suppress pep8 warnings on conf.py generated by sphinx-quickstart
* #2407: building docs crash if document includes large data image URIs * #2407: building docs crash if document includes large data image URIs
* #2436: Sphinx does not check version by :confval:`needs_sphinx` if loading extensions failed
Release 1.4.1 (released Apr 12, 2016) Release 1.4.1 (released Apr 12, 2016)

View File

@ -133,6 +133,13 @@ class Sphinx(object):
self.config.check_unicode(self.warn) self.config.check_unicode(self.warn)
# defer checking types until i18n has been initialized # defer checking types until i18n has been initialized
# check the Sphinx version if requested
needs_sphinx = self.config.get_needs_sphinx()
if needs_sphinx and needs_sphinx > sphinx.__display_version__:
raise VersionRequirementError(
'This project needs at least Sphinx v%s and therefore cannot '
'be built with this version.' % needs_sphinx)
# set confdir to srcdir if -C given (!= no confdir); a few pieces # set confdir to srcdir if -C given (!= no confdir); a few pieces
# of code expect a confdir to be set # of code expect a confdir to be set
if self.confdir is None: if self.confdir is None:
@ -163,13 +170,6 @@ class Sphinx(object):
# now that we know all config values, collect them from conf.py # now that we know all config values, collect them from conf.py
self.config.init_values(self.warn) self.config.init_values(self.warn)
# check the Sphinx version if requested
if self.config.needs_sphinx and \
self.config.needs_sphinx > sphinx.__display_version__:
raise VersionRequirementError(
'This project needs at least Sphinx v%s and therefore cannot '
'be built with this version.' % self.config.needs_sphinx)
# check extension versions if requested # check extension versions if requested
if self.config.needs_extensions: if self.config.needs_extensions:
for extname, needs_ver in self.config.needs_extensions.items(): for extname, needs_ver in self.config.needs_extensions.items():

View File

@ -338,6 +338,10 @@ class Config(object):
'characters; this can lead to Unicode errors occurring. ' 'characters; this can lead to Unicode errors occurring. '
'Please use Unicode strings, e.g. %r.' % (name, u'Content')) 'Please use Unicode strings, e.g. %r.' % (name, u'Content'))
def get_needs_sphinx(self):
"""Obtain the value of ``needs_sphinx``"""
return self.overrides.get('needs_sphinx') or self._raw_config.get('needs_sphinx')
def init_values(self, warn): def init_values(self, warn):
config = self._raw_config config = self._raw_config
for valname, value in iteritems(self.overrides): for valname, value in iteritems(self.overrides):