From 87724860a66608b838201589295096860b0dcb7e Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Wed, 20 Jun 2018 12:54:29 -0700 Subject: [PATCH] Don't load extensions by default tho heh --- releases/util.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/releases/util.py b/releases/util.py index a41f4cc..bbaf59d 100644 --- a/releases/util.py +++ b/releases/util.py @@ -197,7 +197,7 @@ def make_app(**kwargs): in one's own test output and/or debug logs. Finally, it does load the given srcdir's ``conf.py``, but only to read - specific bits like ``extensions``; most of it is ignored. + specific bits like ``extensions`` (if requested); most of it is ignored. All args are stored in a single ``**kwargs``. Aside from the params listed below (all of which are optional), all kwargs given are turned into @@ -216,11 +216,17 @@ def make_app(**kwargs): :param str doctreedir: Sphinx doctree directory path. + :param bool load_extensions: + Whether to load the real ``conf.py`` and setup any extensions it + configures. Default: ``False``. + :returns: A Sphinx ``Application`` instance. """ srcdir = kwargs.pop('srcdir', mkdtemp()) dstdir = kwargs.pop('dstdir', mkdtemp()) doctreedir = kwargs.pop('doctreedir', mkdtemp()) + load_extensions = kwargs.pop('load_extensions', False) + real_conf = None try: # Sphinx <1.6ish Sphinx._log = lambda self, message, wfile, nonl=False: None @@ -236,7 +242,8 @@ def make_app(**kwargs): buildername='html', ) # Might as well load the conf file here too. - real_conf = load_conf(srcdir) + if load_extensions: + real_conf = load_conf(srcdir) finally: for d in (srcdir, dstdir, doctreedir): # Only remove empty dirs; non-empty dirs are implicitly something @@ -273,11 +280,12 @@ def make_app(**kwargs): app.config.init_values(lambda x: x) # Initialize extensions (the internal call to this happens at init time, # which of course had no valid config yet here...) - for extension in real_conf['extensions']: - # But don't set up ourselves again, that's bad... - if extension == 'releases': - continue - app.setup_extension(extension) + if load_extensions: + for extension in real_conf['extensions']: + # But don't set up ourselves again, that causes errors + if extension == 'releases': + continue + app.setup_extension(extension) return app