X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=lib%2Fconfigure.py;h=b376d5029d47eb9b2c62e8705489e80fa983e495;hb=ecda7b0d557de2075509ebc610c22f009443f952;hp=0961d8b3560e800fd019e2b677be13e7912dccf5;hpb=0489d3c496c0a7d5de3d490e1da7541cd5a9d9c8;p=lyx.git diff --git a/lib/configure.py b/lib/configure.py index 0961d8b356..b376d5029d 100644 --- a/lib/configure.py +++ b/lib/configure.py @@ -96,6 +96,8 @@ def createDirectories(): 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') @@ -158,7 +160,7 @@ def checkProg(description, progs, rc_entry = [], path = [], not_found = ''): 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: @@ -199,7 +201,7 @@ def checkProgAlternatives(description, progs, rc_entry = [], alt_rc_entry = [], 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: @@ -426,6 +428,39 @@ def checkLatex(dtl_tools): 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"... ' @@ -492,7 +527,7 @@ def checkFormatEntries(dtl_tools): \Format xpm xpm XPM "" "%s" "%s" ""''' % \ (iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie, iv, ie) ) # - checkViewerEditor('a text editor', ['sensible-editor', 'xemacs', 'gvim', 'kedit', 'kwrite', 'kate', \ + checkViewerEditor('a text editor', ['xemacs', 'gvim', 'kedit', 'kwrite', 'kate', \ 'nedit', 'gedit', 'notepad'], rc_entry = [r'''\Format asciichess asc "Plain text (chess output)" "" "" "%%" "" \Format asciiimage asc "Plain text (image)" "" "" "%%" "" @@ -505,7 +540,7 @@ def checkFormatEntries(dtl_tools): \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" @@ -526,7 +561,7 @@ def checkFormatEntries(dtl_tools): if xhtmlview == "": addToRC(r'\Format xhtml xhtml "LyXHTML" y "" "" "document,menu=export"') # - checkEditor('a BibTeX editor', ['sensible-editor', 'jabref', 'JabRef', \ + checkEditor('a BibTeX editor', ['jabref', 'JabRef', \ 'pybliographic', 'bibdesk', 'gbib', 'kbib', \ 'kbibtex', 'sixpack', 'bibedit', 'tkbibtex' \ 'xemacs', 'gvim', 'kedit', 'kwrite', 'kate', \ @@ -600,11 +635,7 @@ def checkConverterEntries(): 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 @@ -627,9 +658,11 @@ def checkConverterEntries(): 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'], @@ -859,6 +892,8 @@ def checkConverterEntries(): # 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) @@ -1068,17 +1103,21 @@ def checkLatexConfig(check_config, bool_docbook): 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: @@ -1130,22 +1169,32 @@ def checkModulesConfig(): ## configuration change. ## "ModuleName" "filename" "Description" "Packages" "Requires" "Excludes" "Category" ''') + # build the list of available modules - foundClasses = [] + seen = [] + # note that this searches the local directory first, then the + # system directory. that way, we pick up the user's version first. for file in glob.glob( os.path.join('layouts', '*.module') ) + \ glob.glob( os.path.join(srcdir, 'layouts', '*.module' ) ) : # valid file? logger.info(file) if not os.path.isfile(file): continue - retval = processModuleFile(file, bool_docbook) + + filename = file.split(os.sep)[-1] + filename = filename[:-7] + if seen.count(filename): + continue + + seen.append(filename) + retval = processModuleFile(file, filename, bool_docbook) if retval != "": tx.write(retval) tx.close() logger.info('\tdone') -def processModuleFile(file, bool_docbook): +def processModuleFile(file, filename, bool_docbook): ''' process module file and get a line of result The top of a module file should look like this: @@ -1170,8 +1219,6 @@ def processModuleFile(file, bool_docbook): modname = desc = pkgs = req = excl = catgy = "" readingDescription = False descLines = [] - filename = file.split(os.sep)[-1] - filename = filename[:-7] for line in open(file).readlines(): if readingDescription: @@ -1307,7 +1354,6 @@ Options: 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 @@ -1323,6 +1369,7 @@ Options: 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()