mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add support for old versions of latex (with no --output-directory option).
This commit is contained in:
@@ -14,7 +14,7 @@ import shlex
|
||||
import shutil
|
||||
import tempfile
|
||||
import posixpath
|
||||
from os import path
|
||||
from os import path, getcwd, chdir
|
||||
from subprocess import Popen, PIPE
|
||||
try:
|
||||
from hashlib import sha1 as sha
|
||||
@@ -96,9 +96,15 @@ def render_math(self, math):
|
||||
tf.write(latex)
|
||||
tf.close()
|
||||
|
||||
# build latex command. old versions of latex don't have the
|
||||
# --output-directory option, so we have to manually chdir to the
|
||||
# temp dir to run it.
|
||||
ltx_args = shlex.split(self.builder.config.pngmath_latex)
|
||||
ltx_args += ['--interaction=nonstopmode', '--output-directory=' + tempdir,
|
||||
'math.tex']
|
||||
ltx_args += ['--interaction=nonstopmode', 'math.tex']
|
||||
|
||||
curdir = getcwd()
|
||||
chdir(tempdir)
|
||||
|
||||
try:
|
||||
p = Popen(ltx_args, stdout=PIPE, stderr=PIPE)
|
||||
except OSError, err:
|
||||
@@ -110,6 +116,9 @@ def render_math(self, math):
|
||||
self.builder.config.pngmath_latex)
|
||||
self.builder._mathpng_warned_latex = True
|
||||
return relfn, None
|
||||
finally:
|
||||
chdir(curdir)
|
||||
|
||||
stdout, stderr = p.communicate()
|
||||
if p.returncode != 0:
|
||||
raise MathExtError('latex exited with error:\n[stderr]\n%s\n[stdout]\n%s'
|
||||
|
||||
Reference in New Issue
Block a user