Check for Asymptote not writing a PDF file.

If no drawing commands are called in an Asymptote script, no PDF output is created and no error is generated. This confuses the build process, which expect a target to exist after its commands were called.

With this change, the Python wrapper checks whether a PDF was actually written and throws an error otherwise.
This commit is contained in:
Michael Schwarz 2015-09-11 22:03:03 +02:00
parent 0c5b944686
commit 93f9696491
2 changed files with 5 additions and 2 deletions

View file

@ -17,6 +17,9 @@ def main(in_path, out_path):
# Asymptote creates A LOT of temp files (presumably when invoking LaTeX) and leaves some of them behind. Thus we run asymptote in a temporary directory.
_asymptote(absolute_in_path, 'out', os.path.dirname(absolute_in_path), temp_dir)
if not os.path.exists(temp_out_path):
raise util.UserError('Asymptote did not generate a PDF file for input file {}.', in_path)
shutil.copyfile(temp_out_path, out_path)
else:
raise Exception('Unknown file type: {}'.format(out_suffix))

View file

@ -35,7 +35,7 @@ def TemporaryDirectory():
shutil.rmtree(dir)
def command(args, remove_env = [], set_env = { }):
def command(args, remove_env = [], set_env = { }, working_dir = None):
env = dict(os.environ)
for i in remove_env:
@ -45,7 +45,7 @@ def command(args, remove_env = [], set_env = { }):
env[k] = v
try:
process = subprocess.Popen(args, env = env)
process = subprocess.Popen(args, env = env, cwd = working_dir)
process.wait()
except OSError as e:
raise UserError('Error running {}: {}', args[0], e)