X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=lib%2Fconfigure.py;h=c6c2ddd6202742b97c5f6af9cac92b6168e719d6;hb=88099cf89aa6db90ed862f43348c9ed8c48b08a4;hp=3caa31d3bcd3036b52e1b67aec2406d4d3101866;hpb=3cc1001bd37e5d407877286d5d261c1c245906ef;p=lyx.git diff --git a/lib/configure.py b/lib/configure.py index 3caa31d3bc..c6c2ddd620 100644 --- a/lib/configure.py +++ b/lib/configure.py @@ -1,4 +1,5 @@ #! /usr/bin/env python +# -*- coding: utf-8 -*- # # file configure.py # This file is part of LyX, the document processor. @@ -7,9 +8,6 @@ # \author Bo Peng # Full author contact details are available in file CREDITS. -# This is an experimental version of the configure script, written -# in Python. - import sys, os, re, shutil, glob @@ -106,6 +104,7 @@ def checkTeXPaths(): inpname = tmpfname.replace('\\', '/') else: inpname = cmdOutput('cygpath -m ' + tmpfname) + logname = os.path.basename(inpname.replace('.ltx', '.log')) inpname = inpname.replace('~', '\\string~') os.write(fd, r'\relax') os.close(fd) @@ -116,7 +115,7 @@ def checkTeXPaths(): else: print "configure: TeX engine needs windows-style paths in latex files" windows_style_tex_paths = 'true' - removeFiles([tmpfname, 'texput.log']) + removeFiles([tmpfname, logname, 'texput.log']) return windows_style_tex_paths @@ -189,15 +188,15 @@ def checkDTLtools(): if ((os.name == 'nt' or sys.platform == 'cygwin') and checkProg('DVI to DTL converter', ['dv2dt']) != ['', ''] and checkProg('DTL to DVI converter', ['dt2dv']) != ['', '']): - dtl_tools = 'true' + dtl_tools = True else: - dtl_tools = 'false' + dtl_tools = False return dtl_tools def checkLatex(dtl_tools): ''' Check latex, return lyx_check_config ''' - if (dtl_tools): + if dtl_tools: # Windows only: DraftDVI converter_entry = r'''\converter latex dvi2 "%%" "latex" \converter dvi2 dvi "python -tt $$s/scripts/clean_dvi.py $$i $$o" ""''' @@ -240,8 +239,8 @@ def checkFormatEntries(dtl_tools): checkViewer('a FEN viewer and editor', ['xboard -lpf $$i -mode EditPosition'], rc_entry = [r'\Format fen fen FEN "" "%%" "%%" ""']) # - path, iv = checkViewer('a raster image viewer', ['xv', 'kview', 'gimp']) - path, ie = checkViewer('a raster image editor', ['gimp']) + path, iv = checkViewer('a raster image viewer', ['xv', 'kview', 'gimp-remote', 'gimp']) + path, ie = checkViewer('a raster image editor', ['gimp-remote', 'gimp']) addToRC(r'''\Format bmp bmp BMP "" "%s" "%s" "" \Format gif gif GIF "" "%s" "%s" "" \Format jpg jpg JPEG "" "%s" "%s" "" @@ -271,43 +270,54 @@ def checkFormatEntries(dtl_tools): \Format text2 txt "Plain text (pstotext)" "" "" "%%" "document" \Format text3 txt "Plain text (ps2ascii)" "" "" "%%" "document" \Format text4 txt "Plain text (catdvi)" "" "" "%%" "document" -\Format textparagraph txt "Plain text (paragraphs)" "" "" "%%" "document"''' ]) +\Format textparagraph txt "Plain Text, Join Lines" "" "" "%%" "document"''' ]) # #checkProg('a Postscript interpreter', ['gs'], # rc_entry = [ r'\ps_command "%%"' ]) - checkViewer('a Postscript previewer', ['gv', 'ghostview -swap', 'kghostview'], + checkViewer('a Postscript previewer', ['kghostview', 'evince', 'gv', 'ghostview -swap'], rc_entry = [r'''\Format eps eps EPS "" "%%" "" "vector" \Format ps ps Postscript t "%%" "" "document,vector"''']) # - checkViewer('a PDF previewer', ['acrobat', 'acroread', 'gv', 'ghostview', \ - 'xpdf', 'kpdf', 'kghostview'], + checkViewer('a PDF previewer', ['kpdf', 'evince', 'kghostview', 'xpdf', 'acrobat', 'acroread', \ + 'gv', 'ghostview'], rc_entry = [r'''\Format pdf pdf "PDF (ps2pdf)" P "%%" "" "document,vector" \Format pdf2 pdf "PDF (pdflatex)" F "%%" "" "document,vector" \Format pdf3 pdf "PDF (dvipdfm)" m "%%" "" "document,vector"''']) # checkViewer('a DVI previewer', ['xdvi', 'kdvi'], rc_entry = [r'\Format dvi dvi DVI D "%%" "" "document,vector"']) - if (dtl_tools): + if dtl_tools: # Windows only: DraftDVI addToRC(r'\Format dvi2 dvi DraftDVI "" "" "document,vector"') # - checkViewer('a HTML previewer', ['mozilla file://$$p$$i', 'netscape'], + checkViewer('an HTML previewer', ['firefox', 'mozilla file://$$p$$i', 'netscape'], rc_entry = [r'\Format html html HTML H "%%" "" "document"']) # + checkViewer('Noteedit', ['noteedit'], + rc_entry = [r'\Format noteedit not Noteedit "" "%%" "%%" "vector"']) + # + checkViewer('an OpenDocument viewer', ['oowriter'], + rc_entry = [r'\Format odt odt OpenDocument "" "%%" "%%" "document,vector"']) + # # entried that do not need checkProg addToRC(r'''\Format date "" "date command" "" "" "" "" \Format fax "" Fax "" "" "" "document" \Format lyx lyx LyX "" "" "" "" \Format lyx13x lyx13 "LyX 1.3.x" "" "" "" "document" +\Format lyx14x lyx14 "LyX 1.4.x" "" "" "" "document" +\Format clyx cjklyx "CJK LyX 1.4.x (big5)" "" "" "" "document" +\Format jlyx cjklyx "CJK LyX 1.4.x (euc-jp)" "" "" "" "document" +\Format klyx cjklyx "CJK LyX 1.4.x (euc-kr)" "" "" "" "document" \Format lyxpreview lyxpreview "LyX Preview" "" "" "" "" \Format pdftex pdftex_t PDFTEX "" "" "" "" \Format program "" Program "" "" "" "" \Format pstex pstex_t PSTEX "" "" "" "" \Format rtf rtf "Rich Text Format" "" "" "" "document,vector" -\Format sxw sxw "OpenOffice.Org Writer" O "" "" "document,vector" -\Format wmf wmf "Windows Meta File" "" "" "" "vector" +\Format sxw sxw "OpenOffice.Org (sxw)" "" "" "" "document,vector" +\Format wmf wmf "Windows Metafile" "" "" "" "vector" +\Format emf emf "Enhanced Metafile" "" "" "" "vector" \Format word doc "MS Word" W "" "" "document,vector" -\Format wordhtml html "MS Word (HTML)" "" "" "" "document" +\Format wordhtml html "HTML (MS Word)" "" "" "" "document" ''') @@ -335,20 +345,40 @@ def checkConverterEntries(): checkProg('a Noweb -> LaTeX converter', ['noweave -delay -index $$i > $$o'], rc_entry = [ r'\converter literate latex "%%" ""' ]) # - checkProg('a HTML -> LaTeX converter', ['html2latex $$i'], + checkProg('an HTML -> LaTeX converter', ['html2latex $$i'], rc_entry = [ r'\converter html latex "%%" ""' ]) # - checkProg('a MSWord -> LaTeX converter', ['wvCleanLatex $$i $$o'], + checkProg('an MS Word -> LaTeX converter', ['wvCleanLatex $$i $$o'], rc_entry = [ r'\converter word latex "%%" ""' ]) - # - checkProg('a LaTeX -> MS Word converter', ["htlatex $$i 'html,word' 'symbol/!' '-cvalidate'"], - rc_entry = [ r'\converter latex wordhtml "%%" ""' ]) + # On SuSE the scripts have a .sh suffix, and on debian they are in /usr/share/tex4ht/ + path, htmlconv = checkProg('a LaTeX -> HTML converter', ['htlatex $$i', 'htlatex.sh $$i', \ + '/usr/share/tex4ht/htlatex $$i', 'tth -t -e2 -L$$b < $$i > $$o', \ + 'latex2html -no_subdir -split 0 -show_section_numbers $$i', 'hevea -s $$i'], + rc_entry = [ r'\converter latex html "%%" "needaux"' ]) + if htmlconv.find('htlatex') >= 0 or htmlconv == 'latex2html': + addToRC(r'''\copier html "python -tt $$s/scripts/ext_copy.py -e html,png,css $$i $$o"''') + else: + addToRC(r'''\copier html "python -tt $$s/scripts/ext_copy.py $$i $$o"''') + + # On SuSE the scripts have a .sh suffix, and on debian they are in /usr/share/tex4ht/ + path, htmlconv = checkProg('a LaTeX -> MS Word converter', ["htlatex $$i 'html,word' 'symbol/!' '-cvalidate'", \ + "htlatex.sh $$i 'html,word' 'symbol/!' '-cvalidate'", \ + "/usr/share/tex4ht/htlatex $$i 'html,word' 'symbol/!' '-cvalidate'"], + rc_entry = [ r'\converter latex wordhtml "%%" "needaux"' ]) + if htmlconv.find('htlatex') >= 0: + addToRC(r'''\copier wordhtml "python -tt $$s/scripts/ext_copy.py -e html,png,css $$i $$o"''') # checkProg('an OpenOffice.org -> LaTeX converter', ['w2l -clean $$i'], rc_entry = [ r'\converter sxw latex "%%" ""' ]) # - checkProg('a LaTeX -> OpenOffice.org converter', ['oolatex $$i', 'oolatex.sh $$i'], - rc_entry = [ r'\converter latex sxw "%%" "latex"' ]) + checkProg('an OpenDocument -> LaTeX converter', ['w2l -clean $$i'], + rc_entry = [ r'\converter odt latex "%%" ""' ]) + # On SuSE the scripts have a .sh suffix, and on debian they are in /usr/share/tex4ht/ + # Both SuSE and debian have oolatex + checkProg('a LaTeX -> Open Document converter', ['oolatex $$i', 'oolatex.sh $$i', \ + '/usr/share/tex4ht/oolatex $$i', \ + 'htlatex $$i \'xhtml,ooffice\' \'ooffice/! -cmozhtf\' \'-coo\' \'-cvalidate\''], + rc_entry = [ r'\converter latex odt "%%" "needaux"' ]) # On windows it is called latex2rt.exe checkProg('a LaTeX -> RTF converter', ['latex2rtf -p -S -o $$o $$i', 'latex2rt -p -S -o $$o $$i'], rc_entry = [ r'\converter latex rtf "%%" "needaux"' ]) @@ -398,12 +428,19 @@ def checkConverterEntries(): \converter tgif pdf "tgif -stdout -print -color -pdf $$i > $$o" ""''', '']) # - checkProg('a WMF -> EPS converter', ['wmf2eps -o $$o $$i'], - rc_entry = [ r'\converter wmf eps "%%" ""', '']) + checkProg('a WMF -> EPS converter', ['metafile2eps $$i $$o', 'wmf2eps -o $$o $$i'], + rc_entry = [ r'\converter wmf eps "%%" ""']) + # + checkProg('an EMF -> EPS converter', ['metafile2eps $$i $$o', 'wmf2eps -o $$o $$i'], + rc_entry = [ r'\converter emf eps "%%" ""']) # - checkProg('a EPS -> PDF converter', ['epstopdf'], + checkProg('an EPS -> PDF converter', ['epstopdf'], rc_entry = [ r'\converter eps pdf "epstopdf --outfile=$$o $$i" ""', '']) # + # no agr -> pdf converter, since the pdf library used by gracebat is not + # free software and therefore not compiled in in many installations. + # Fortunately, this is not a big problem, because we will use epstopdf to + # convert from agr to pdf via eps without loss of quality. checkProg('a Grace -> Image converter', ['gracebat'], rc_entry = [ r'''\converter agr eps "gracebat -hardcopy -printfile $$o -hdevice EPS $$i 2>/dev/null" "" @@ -412,11 +449,8 @@ def checkConverterEntries(): \converter agr ppm "gracebat -hardcopy -printfile $$o -hdevice PNM $$i 2>/dev/null" ""''', '']) # - checkProg('a LaTeX -> HTML converter', ['htlatex $$i', 'tth -t -e2 -L$$b < $$i > $$o', \ - 'latex2html -no_subdir -split 0 -show_section_numbers $$i', 'hevea -s $$i'], - rc_entry = [ r'\converter latex html "%%" "originaldir,needaux"' ]) # - path, lilypond = checkProg('a LilyPond -> ESP/PDF/PNG converter', ['lilypond']) + path, lilypond = checkProg('a LilyPond -> EPS/PDF/PNG converter', ['lilypond']) if (lilypond != ''): version_string = cmdOutput("lilypond --version") match = re.match('GNU LilyPond (\S+)', version_string) @@ -434,17 +468,27 @@ def checkConverterEntries(): else: print '+ found LilyPond, but could not extract version number.' # + checkProg('a Noteedit -> LilyPond converter', ['noteedit --export-lilypond $$i'], + rc_entry = [ r'\converter noteedit lilypond "%%" ""', '']) + # # FIXME: no rc_entry? comment it out # checkProg('Image converter', ['convert $$i $$o']) # - # Entried that do not need checkProg + # Entries that do not need checkProg addToRC(r'''\converter lyxpreview ppm "python -tt $$s/scripts/lyxpreview2bitmap.py" "" -\converter date dateout "date +%d-%m-%Y > $$o" "" +\converter date dateout "python -tt $$s/scripts/date.py %d-%m-%Y > $$o" "" \converter docbook docbook-xml "cp $$i $$o" "xml" \converter fen asciichess "python -tt $$s/scripts/fen2ascii.py $$i $$o" "" \converter fig pdftex "python -tt $$s/scripts/fig2pdftex.py $$i $$o" "" \converter fig pstex "python -tt $$s/scripts/fig2pstex.py $$i $$o" "" \converter lyx lyx13x "python -tt $$s/lyx2lyx/lyx2lyx -t 221 $$i > $$o" "" +\converter lyx lyx14x "python -tt $$s/lyx2lyx/lyx2lyx -t 245 $$i > $$o" "" +\converter lyx clyx "python -tt $$s/lyx2lyx/lyx2lyx -c big5 -t 245 $$i > $$o" "" +\converter lyx jlyx "python -tt $$s/lyx2lyx/lyx2lyx -c euc_jp -t 245 $$i > $$o" "" +\converter lyx klyx "python -tt $$s/lyx2lyx/lyx2lyx -c euc_kr -t 245 $$i > $$o" "" +\converter clyx lyx "python -tt $$s/lyx2lyx/lyx2lyx -c big5 $$i > $$o" "" +\converter jlyx lyx "python -tt $$s/lyx2lyx/lyx2lyx -c euc_jp $$i > $$o" "" +\converter klyx lyx "python -tt $$s/lyx2lyx/lyx2lyx -c euc_kr $$i > $$o" "" ''') @@ -488,9 +532,9 @@ def checkOtherEntries(): ''' entries other than Format and Converter ''' checkProg('a *roff formatter', ['groff', 'nroff'], rc_entry = [ - r'\ascii_roff_command "groff -t -Tlatin1 $$FName"', - r'\ascii_roff_command "tbl $$FName | nroff"', - r'\ascii_roff_command ""' ]) + r'\plaintext_roff_command "groff -t -Tlatin1 $$FName"', + r'\plaintext_roff_command "tbl $$FName | nroff"', + r'\plaintext_roff_command ""' ]) checkProg('ChkTeX', ['chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38'], rc_entry = [ r'\chktex_command "%%"' ]) checkProg('a spellchecker', ['ispell'], @@ -510,13 +554,14 @@ def checkOtherEntries(): addToRC(r'''\copier fig "python -tt $$s/scripts/fig_copy.py $$i $$o" \copier pstex "python -tt $$s/scripts/tex_copy.py $$i $$o $$l" \copier pdftex "python -tt $$s/scripts/tex_copy.py $$i $$o $$l" +\copier program "python -tt $$s/scripts/ext_copy.py $$i $$o" ''') def processLayoutFile(file, bool_docbook, bool_linuxdoc): ''' process layout file and get a line of result - Declear line are like this: (article.layout, scrbook.layout, svjog.layout) + Declare lines look like this: (article.layout, scrbook.layout, svjog.layout) \DeclareLaTeXClass{article} \DeclareLaTeXClass[scrbook]{book (koma-script)} @@ -529,8 +574,8 @@ def processLayoutFile(file, bool_docbook, bool_linuxdoc): "svjog" "svjour" "article (Springer - svjour/jog)" "false" ''' classname = file.split(os.sep)[-1].split('.')[0] - # return ('LaTeX', '[a,b]', 'a', ',b,c', 'article') for \DeclearLaTeXClass[a,b,c]{article} - p = re.compile(r'\Declare(LaTeX|DocBook)Class\s*(\[([^,]*)(,.*)*\])*\s*{(.*)}') + # return ('LaTeX', '[a,b]', 'a', ',b,c', 'article') for \DeclareLaTeXClass[a,b,c]{article} + p = re.compile(r'\Declare(LaTeX|DocBook|LinuxDoc)Class\s*(\[([^,]*)(,.*)*\])*\s*{(.*)}') for line in open(file).readlines(): res = p.search(line) if res != None: @@ -539,7 +584,7 @@ def processLayoutFile(file, bool_docbook, bool_linuxdoc): if opt == None: opt = classname return '"%s" "%s" "%s" "%s"\n' % (classname, opt, desc, avai) - print "Layout file without \DeclearXXClass line. " + print "Layout file without \DeclareXXClass line. " sys.exit(2) @@ -585,7 +630,7 @@ def checkLatexConfig(check_config, bool_docbook, bool_linuxdoc): 'chkconfig.classes', 'chklayouts.tex']) rmcopy = False if not os.path.isfile( 'chkconfig.ltx' ): - shutil.copy( os.path.join(srcdir, 'chkconfig.ltx'), 'chkconfig.ltx' ) + shutil.copyfile( os.path.join(srcdir, 'chkconfig.ltx'), 'chkconfig.ltx' ) rmcopy = True writeToFile('wrap_chkconfig.ltx', '%s\n%s\n\\input{chkconfig.ltx}\n' \ % (linuxdoc_cmd, docbook_cmd) ) @@ -692,6 +737,57 @@ s!@chk_docbook@!%s!g ''.join(lyxin)) +def checkModulesConfig(): + removeFiles(['lyxmodules.lst']) + + print '+checking list of modules... ' + tx = open('lyxmodules.lst', 'w') + tx.write('''## This file declares modules and their associated definition files. +## It has been automatically generated by configure +## Use "Options/Reconfigure" if you need to update it after a +## configuration change. +''') + # build the list of available modules + foundClasses = [] + for file in glob.glob( os.path.join('layouts', '*.module') ) + \ + glob.glob( os.path.join(srcdir, 'layouts', '*.module' ) ) : + # valid file? + print file + if not os.path.isfile(file): + continue + tx.write(processModuleFile(file, bool_docbook, bool_linuxdoc)) + tx.close() + print '\tdone' + +def processModuleFile(file, bool_docbook, bool_linuxdoc): + ''' process module file and get a line of result + + Declare lines look like this: + \DeclareLyXModule[LaTeX Packages]{Description}{ModuleName}... + We expect output: + "ModuleName" "filename" "Description" "Packages" + " + ''' + p = re.compile(r'\DeclareLyXModule\s*(?:\[([^]]*)\])?{(.*)}{(.*)}') + for line in open(file).readlines(): + res = p.search(line) + if res != None: + (packages, desc, modname) = res.groups() + #check availability...need to add that + if packages == None: + packages = "" + else: + pkgs = [s.strip() for s in packages.split(",")] + packages = ",".join(pkgs) + + filename = file.split(os.sep)[-1] + return '"%s" "%s" "%s" "%s"\n' % (modname, filename, desc, packages) + print "Module file without \DeclareLyXModule line. " + sys.exit(2) + + + + def checkTeXAllowSpaces(): ''' Let's check whether spaces are allowed in TeX file names ''' tex_allows_spaces = 'false' @@ -785,4 +881,5 @@ Options: # --without-latex-config can disable lyx_check_config checkLatexConfig( lyx_check_config and LATEX != '', bool_docbook, bool_linuxdoc) createLaTeXConfig() + checkModulesConfig() #lyx_check_config and LATEX != '') removeTempFiles()