X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=python%2Fbook_latex.py;h=ec5412b1d8192bee41e292e31bc62a78798cc45d;hb=97a0169312a260933246ab224e4f8b0969871dd5;hp=8d2104b08dd5e5a880a4dc3c9b6dc363e570315c;hpb=e375bc55aea13a75a7ee56248703c30108c25d57;p=lilypond.git diff --git a/python/book_latex.py b/python/book_latex.py index 8d2104b08d..ec5412b1d8 100644 --- a/python/book_latex.py +++ b/python/book_latex.py @@ -189,11 +189,12 @@ def get_latex_textwidth (source, global_options): progress (_ ("Running `%s' on file `%s' to detect default page settings.\n") % (global_options.latex_program, tmpfile)) - cmd = 'TEXINPUTS=%s:$TEXINPUTS %s %s' \ - % (global_options.input_dir, global_options.latex_program, tmpfile) + cmd = '%s %s' % (global_options.latex_program, tmpfile) debug ("Executing: %s\n" % cmd) run_env = os.environ.copy() run_env['LC_ALL'] = 'C' + run_env['TEXINPUTS'] = '%s:%s' % \ + (global_options.input_dir, run_env.get('TEXINPUTS',"")) ### unknown why this is necessary universal_newlines = True @@ -206,7 +207,13 @@ def get_latex_textwidth (source, global_options): output_filename = os.path.join(output_dir, 'output.txt') # call command cmd += " > %s" % output_filename + oldtexinputs = os.environ.get ('TEXINPUTS') + os.environ['TEXINPUTS'] = run_env['TEXINPUTS'] returncode = os.system(cmd) + if oldtexinputs: + os.environ['TEXINPUTS'] = oldtexinputs + else: + del os.environ['TEXINPUTS'] parameter_string = open(output_filename).read() if returncode != 0: warning (_ ("Unable to auto-detect default settings:\n")) @@ -296,9 +303,10 @@ class BookLatexOutputFormat (BookBase.BookOutputFormat): def input_fullname (self, input_filename): # Use kpsewhich if available, otherwise fall back to the default: if ly.search_exe_path ('kpsewhich'): - return os.popen ('kpsewhich ' + input_filename).read()[:-1] - else: - return BookBase.BookOutputFormat.input_fullname (self, input_filename) + trial = os.popen ('kpsewhich ' + input_filename).read()[:-1] + if trial: + return trial + return BookBase.BookOutputFormat.input_fullname (self, input_filename) def process_chunks (self, chunks): for c in chunks: