From f2ee8247064230b01e3d7222bff440ca56b52b6d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 23 Aug 2020 13:57:30 +0530 Subject: [PATCH] Fix building of POT for user manual --- manual/build.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/manual/build.py b/manual/build.py index 6c1f3cd441..eb64847676 100755 --- a/manual/build.py +++ b/manual/build.py @@ -11,7 +11,8 @@ from functools import partial j, d, a = os.path.join, os.path.dirname, os.path.abspath BASE = d(a(__file__)) -SPHINX_BUILD = 'sphinx-build' +SPHINX_BUILD = ['sphinx-build'] +is_ci = os.environ.get('CI') == 'true' sys.path.insert(0, d(BASE)) from setup import __appname__, __version__ @@ -23,7 +24,7 @@ def sphinx_build(language, base, builder='html', bdir='html', t=None, quiet=True destdir = j(base, bdir) if not os.path.exists(destdir): os.makedirs(destdir) - ans = [SPHINX_BUILD, '-D', ('language=' + language), '-b', builder] + ans = SPHINX_BUILD + ['-D', ('language=' + language), '-b', builder] if quiet: ans.append('-q') if very_quiet: @@ -69,7 +70,11 @@ def build_manual(language, base): def build_pot(base): - cmd = [SPHINX_BUILD, '-b', 'gettext', '-t', 'online', '-t', 'gettext', '.', base] + cmd = SPHINX_BUILD + ['-b', 'gettext', '-t', 'online', '-t', 'gettext', '.', base] + if is_ci: + sp = eval(subprocess.check_output(['python', '-c', 'import sphinx; print(sphinx.__path__)']).decode('utf-8')) + code = f'import sys, os; sys.path += [{os.path.dirname(sp[0])!r}]; from sphinx.cmd.build import main; main({cmd[1:]!r})' + cmd = [sys.executable, '-c', code] print(' '.join(cmd)) subprocess.check_call(cmd) os.remove(j(base, 'generated.pot')) @@ -77,7 +82,7 @@ def build_pot(base): def build_linkcheck(base): - cmd = [SPHINX_BUILD, '-b', 'linkcheck', '-t', 'online', '-t', 'linkcheck', '.', base] + cmd = SPHINX_BUILD + ['-b', 'linkcheck', '-t', 'online', '-t', 'linkcheck', '.', base] print(' '.join(cmd)) subprocess.check_call(cmd) return base