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')
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:
inpname = cmdOutput('cygpath -m ' + tmpfname)
logname = os.path.basename(inpname.replace('.ltx', '.log'))
os.write(fd, r'\relax')
os.close(fd)
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:
logger.warning("configure: TeX engine needs posix-style paths in latex files")
windows_style_tex_paths = 'false'
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 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)" "" "" "%%" ""
\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"
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', \
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)
## 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:
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:
msg = "Checking whether TeX allows spaces in file names... "
writeToFile('a b.tex', r'\message{working^^J}' )
if LATEX != '':
- if os.name == 'nt':
+ if os.name == 'nt' or sys.platform == 'cygwin':
latex_out = cmdOutput(LATEX + r""" "\nonstopmode\input{\"a b\"}" """)
else:
latex_out = cmdOutput(LATEX + r""" '\nonstopmode\input{"a b"}' """)
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()