On Windows, improve detection of the TeX engine by avoiding spaces in

filenames passed to latex (through the short form of the path) and also
by taking into account that a short form may not always be available.
Such detection may still fail if the file system does not support short
names and the TeX engine doesn't allow spaces in filenames, but this is
a highly improbable condition, hopefully.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_2_0_X@38921 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2011-06-01 22:22:58 +00:00
parent ac47154162
commit 72230bb98c
2 changed files with 15 additions and 2 deletions

View File

@ -102,7 +102,15 @@ def checkTeXPaths():
from tempfile import mkstemp from tempfile import mkstemp
fd, tmpfname = mkstemp(suffix='.ltx') fd, tmpfname = mkstemp(suffix='.ltx')
if os.name == 'nt': if os.name == 'nt':
inpname = tmpfname.replace('\\', '/') from ctypes import windll, create_unicode_buffer
GetShortPathName = windll.kernel32.GetShortPathNameW
longname = unicode(tmpfname)
shortlen = GetShortPathName(longname, 0, 0)
shortname = create_unicode_buffer(shortlen)
if GetShortPathName(longname, shortname, shortlen):
inpname = shortname.value.replace('\\', '/')
else:
inpname = tmpfname.replace('\\', '/')
else: else:
inpname = cmdOutput('cygpath -m ' + tmpfname) inpname = cmdOutput('cygpath -m ' + tmpfname)
logname = os.path.basename(inpname.replace('.ltx', '.log')) logname = os.path.basename(inpname.replace('.ltx', '.log'))
@ -110,6 +118,8 @@ def checkTeXPaths():
os.write(fd, r'\relax') os.write(fd, r'\relax')
os.close(fd) os.close(fd)
latex_out = cmdOutput(r'latex "\nonstopmode\input{%s}"' % inpname) latex_out = cmdOutput(r'latex "\nonstopmode\input{%s}"' % inpname)
if 'Error' in latex_out:
latex_out = cmdOutput(r'latex "\nonstopmode\input{\"%s\"}"' % inpname)
if 'Error' in latex_out: if 'Error' in latex_out:
logger.warning("configure: TeX engine needs posix-style paths in latex files") logger.warning("configure: TeX engine needs posix-style paths in latex files")
windows_style_tex_paths = 'false' windows_style_tex_paths = 'false'
@ -1293,7 +1303,7 @@ def checkTeXAllowSpaces():
msg = "Checking whether TeX allows spaces in file names... " msg = "Checking whether TeX allows spaces in file names... "
writeToFile('a b.tex', r'\message{working^^J}' ) writeToFile('a b.tex', r'\message{working^^J}' )
if LATEX != '': if LATEX != '':
if os.name == 'nt': if os.name == 'nt' or sys.platform == 'cygwin':
latex_out = cmdOutput(LATEX + r""" "\nonstopmode\input{\"a b\"}" """) latex_out = cmdOutput(LATEX + r""" "\nonstopmode\input{\"a b\"}" """)
else: else:
latex_out = cmdOutput(LATEX + r""" '\nonstopmode\input{"a b"}' """) latex_out = cmdOutput(LATEX + r""" '\nonstopmode\input{"a b"}' """)

View File

@ -91,6 +91,9 @@ What's new
- Calculate relative pathnames to master documents when master is in a - Calculate relative pathnames to master documents when master is in a
directory above the child (bug #7540). directory above the child (bug #7540).
- On Windows, improve detection of the TeX engine when the file system does
not support short names and the temp directory contains spaces.
* USER INTERFACE * USER INTERFACE