def checkTeXPaths():
''' Determine the path-style needed by the TeX engine on Win32 (Cygwin) '''
windows_style_tex_paths = ''
+ if LATEX == '':
+ return windows_style_tex_paths
if os.name == 'nt' or sys.platform == 'cygwin':
from tempfile import mkstemp
fd, tmpfname = mkstemp(suffix='.ltx')
msg = '+checking for "' + ac_word + '"... '
path = os.environ["PATH"].split(os.pathsep) + path
extlist = ['']
- if os.environ.has_key("PATHEXT"):
+ if "PATHEXT" in os.environ:
extlist = extlist + os.environ["PATHEXT"].split(os.pathsep)
for ac_dir in path:
for ext in extlist:
msg = '+checking for "' + ac_word + '"... '
path = os.environ["PATH"].split(os.pathsep) + path
extlist = ['']
- if os.environ.has_key("PATHEXT"):
+ if "PATHEXT" in os.environ:
extlist = extlist + os.environ["PATHEXT"].split(os.pathsep)
found_alt = False
for ac_dir in path:
return ''
+def checkLuatex():
+ ''' Check if luatex is there and usable '''
+ path, LUATEX = checkProg('LuaTeX', ['lualatex $$i'])
+ path, DVILUATEX = checkProg('LuaTeX (DVI)', ['dvilualatex $$i'])
+ if LUATEX != '':
+ # luatex binary is there
+ msg = "checking if LuaTeX is usable ..."
+ # Check if luatex is usable
+ writeToFile('luatest.tex', '''
+\\nonstopmode\\documentclass{minimal}
+\\usepackage{fontspec}
+\\begin{document}
+.
+\\end{document}
+''')
+ # run lualatex on luatest.tex and check result
+ luatest = cmdOutput(LUATEX + ' luatest.tex')
+ if luatest.find('XeTeX is required to compile this document') != -1:
+ # fontspec/luatex too old! We do not support this version.
+ logger.info(msg + ' no (probably not recent enough)')
+ elif luatest.find('! LaTeX Error: File `fontspec.sty\' not found') != -1:
+ # fontspec missing
+ logger.info(msg + ' no (missing fontspec)')
+ else:
+ # working luatex
+ logger.info(msg + ' yes')
+ addToRC(r'\converter luatex pdf5 "%s" "latex=lualatex"' % LUATEX)
+ if DVILUATEX != '':
+ addToRC(r'\converter luatex dvi3 "%s" "latex=lualatex"' % DVILUATEX)
+ # remove temporary files
+ removeFiles(['luatest.tex', 'luatest.log', 'luatest.aux', 'luatest.pdf'])
+
+
def checkModule(module):
''' Check for a Python module, return the status '''
msg = 'checking for "' + module + ' module"... '
\Format literate nw NoWeb N "" "%%" "document,menu=export"
\Format sweave Rnw "Sweave" S "" "%%" "document,menu=export"
\Format lilypond ly "LilyPond music" "" "" "%%" "vector"
-\Format lilypond-book lytex "LilyPond book (LaTeX)" "" "" "%%" "document"
+\Format lilypond-book lytex "LilyPond book (LaTeX)" "" "" "%%" "document,menu=export"
\Format latex tex "LaTeX (plain)" L "" "%%" "document,menu=export"
\Format luatex tex "LaTeX (LuaTeX)" "" "" "%%" "document,menu=export"
\Format pdflatex tex "LaTeX (pdflatex)" "" "" "%%" "document,menu=export"
checkProg('XeTeX', ['xelatex $$i'],
rc_entry = [ r'\converter xetex pdf4 "%%" "latex=xelatex"' ])
- checkProg('LuaTeX', ['lualatex $$i'],
- rc_entry = [ r'\converter luatex pdf5 "%%" "latex=lualatex"' ])
-
- checkProg('LuaTeX (DVI)', ['dvilualatex $$i'],
- rc_entry = [ r'\converter luatex dvi3 "%%" "latex=lualatex"' ])
+ checkLuatex()
''' If we're running LyX in-place then tex2lyx will be found in
../src/tex2lyx. Add this directory to the PATH temporarily and
rc_entry = [r'''\converter literate latex "%%" ""
\converter literate pdflatex "%%" ""'''])
#
- checkProg('a Sweave -> LaTeX converter', ['Rscript --no-save --no-restore $$s/scripts/lyxsweave.R $$p$$i $$e $$r'],
+ checkProg('a Sweave -> LaTeX converter', ['Rscript --verbose --no-save --no-restore $$s/scripts/lyxsweave.R $$p$$i $$p$$o $$e $$r'],
rc_entry = [r'''\converter sweave latex "%%" ""
-\converter sweave pdflatex "%%" ""'''])
+\converter sweave pdflatex "%%" ""
+\converter sweave xetex "%%" ""
+\converter sweave luatex "%%" ""'''])
#
checkProg('an HTML -> LaTeX converter', ['html2latex $$i', 'gnuhtml2latex $$i', \
'htmltolatex -input $$i -output $$o', 'java -jar htmltolatex.jar -input $$i -output $$o'],
# this, use different output folders for eps and pdf outputs.
addToRC(r'\converter lilypond-book latex "lilypond-book --safe --lily-output-dir=ly-eps $$i" ""')
addToRC(r'\converter lilypond-book pdflatex "lilypond-book --safe --pdf --latex-program=pdflatex --lily-output-dir=ly-pdf $$i" ""')
+ addToRC(r'\converter lilypond-book xetex "lilypond-book --safe --pdf --latex-program=xelatex --lily-output-dir=ly-pdf $$i" ""')
+ addToRC(r'\converter lilypond-book luatex "lilypond-book --safe --pdf --latex-program=lualatex --lily-output-dir=ly-pdf $$i" ""')
logger.info('+ found LilyPond-book version %s.' % version_number)
else:
logger.info('+ found LilyPond-book, but version %s is too old.' % version_number)
testclasses = list()
for file in glob.glob( os.path.join('layouts', '*.layout') ) + \
glob.glob( os.path.join(srcdir, 'layouts', '*.layout' ) ) :
+ nodeclaration = False
if not os.path.isfile(file):
continue
classname = file.split(os.sep)[-1].split('.')[0]
for line in open(file).readlines():
if not empty.match(line) and line[0] != '#':
- logger.error("Failed to find \Declare line for layout file `" + file + "'")
- sys.exit(3)
+ logger.warning("Failed to find valid \Declare line for layout file `" + file + "'.\n\t=> Skipping this file!")
+ nodeclaration = True
+ break
if declare.search(line) == None:
continue
testclasses.append("\\TestDocClass{%s}{%s}" % (classname, line[1:].strip()))
break
+ if nodeclaration:
+ continue
testclasses.sort()
cl = open('chklayouts.tex', 'w')
for line in testclasses:
sys.exit(1)
setEnviron()
createDirectories()
- windows_style_tex_paths = checkTeXPaths()
dtl_tools = checkDTLtools()
## Write the first part of outfile
writeToFile(outfile, '''# This file has been automatically generated by LyX' lib/configure.py
checkConverterEntries()
(chk_docbook, bool_docbook, docbook_cmd) = checkDocBook()
checkTeXAllowSpaces()
+ windows_style_tex_paths = checkTeXPaths()
if windows_style_tex_paths != '':
addToRC(r'\tex_expects_windows_paths %s' % windows_style_tex_paths)
checkOtherEntries()