Dear list, Attached is a Python version of the configure script. I currently do not have access to a windows machine with lyx on so I can not test it on windows. On my linux machine, it produces identical lyxrc.default and doc/LaTeXConfig.lyx but no further testing/proof-read of the code has been done.
This script is about 1/3 of the original file in size and is much more cleaner and readable. It somehow runs slower than the bsh version (I will check for reasons later). Please test it on your machine and tell me if it generates the right files. On top of that, I will be happy to improve this script. For example, use windows registry, use default windows application path, use full path, etc. Thanks. Bo
#!/usr/bin/env python # # The original script is a hand-made configure script written in bsh. # It contains a lot of code stolen from GNU autoconf. The author removed # all the code that was not useful for configuring a LyX installation. # # This is a python translation of the original bsh configure script # It is supposed to be cleaner, quicker and can avoid the use of # mingw on windows system. This will make the installation # process less painful under windows. # # Bo Peng ([EMAIL PROTECTED]) # Last Modified: Sep, 2005 # # Implementation: # -- almost line to line translation, almost all variables # have the same name and meaning as before. # -- Use functions to clean up the (original ugly) code # -- use python::re module to replace sed # -- use os.system for system call. # # Known Bugs: # -- none # import sys, os, re, shutil outfile = 'lyxrc.defaults' rc_entries = '' lyx_check_config = True lyx_keep_temps = False srcdir = '' version_suffix = '' # utility function. # save a few lines. def writeToFile(filename, lines, append = False): if append: file = open(filename, 'a') else: file = open(filename, 'w') file.write(lines) file.close() # utility function, 'rm -f' def removeFiles(filenames): for file in filenames: try: os.remove(file) except: pass #### Parse the command line for op in sys.argv[1:]: # default shell/for list is $*, the options if op in [ '-help', '--help', '-h' ]: print '''Usage: configure [options] Options: --help show this help lines --keep-temps keep temporary files (for debug. purposes) --without-latex-config do not run LaTeX to determine configuration --with-version-suffix=suffix suffix of binary installed files ''' sys.exit(0) elif op == '--without-latex-config': lyx_check_config = False elif op == '--keep-temps': lyx_keep_temps = True elif op[0:22] == '--with-version-suffix=': # never mind if op is not long enough version_suffix = op[23:] else: print "Unknown option", op sys.exit(1) #### Checking for some echo oddities (ignored) ## The original script defines ac_n, ac_t and ac_c for ## tab, newline etc, I just use python's print output. #### I do not really know why this is useful, but we might as well keep it. ### NLS nuisances. ### Only set these to C if already set. These must not be set unconditionally ### because not all systems understand e.g. LANG=C (notably SCO). ### Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! ### Non-C LC_CTYPE values break the ctype check. ## os.environ['LANG'] = os.getenv('LANG', 'C') os.environ['LC'] = os.getenv('LC_ALL', 'C') os.environ['LC_MESSAGE'] = os.getenv('LC_MESSAGE', 'C') os.environ['LC_CTYPE'] = os.getenv('LC_CTYPE', 'C') #### Guess the directory in which configure is located. ac_prog = sys.argv[0] srcdir = os.path.dirname(ac_prog) if srcdir == '': srcdir = '.' if not os.path.isfile( os.path.join(srcdir, 'chkconfig.ltx') ): print "configure: error: cannot find chkconfig.ltx script" sys.exit(1) #### Adjust PATH for Win32 (Cygwin) # i.e., change /cygdrive/c to c: # # FIXME: necessary? I assume that lyx/win does not like cygwin. ###### Create the build directories if necessary for dir in ['bind', 'clipart', 'doc', 'examples', 'help', \ 'images', 'kbd', 'layouts', 'reLyX' , 'scripts', 'templates', \ 'ui', 'xfonts']: if not os.path.isdir( dir ): try: os.mkdir( dir) except: print "Failed to create directory ", dir sys.exit(1) #### Searching some useful programs ## This function will search a program in $PATH plus given path ## If found, return directory and program name. ## ## description: description of the program ## progs: check programs ## path: additional path ## ## FIXME: under windows, we should check registry ## instead of $PATH def checkProg(description, progs, path = []): print '\nchecking for', description, '...', print '(' + ','.join(progs) + ')', for ac_prog in progs: # ac_prog may have options, ac_word is the command name ac_word = ac_prog.split(' ')[0] print '\n+checking for "' + ac_word + '"... ', for ac_dir in os.environ['PATH'].split(':') + path: if os.path.isfile( os.path.join(ac_dir, ac_word) ): print ' yes', return [ac_dir, ac_prog] # if not successful print ' no', return ['', 'none'] # Find programs! Returned path is not used now path, LATEX = checkProg( 'a latex2e program', ['latex', 'latex2e']) # no latex lyx_check_config = False if LATEX != 'none': # Check if latex is usable writeToFile('chklatex.ltx', ''' \\nonstopmode\\makeatletter \\ifx\\undefined\\documentclass\\else \\message{ThisIsLaTeX2e} \\fi \\@@end ''') # run latex on chklatex.ltx and check result isLatex2e = False fout = os.popen(LATEX + ' chklatex.ltx') for line in fout.readlines(): if re.search('ThisIsLaTeX2e', line) != None: isLatex2e = True fout.close() if not isLatex2e: print "Latex not usable (not LaTex2e) " else: lyx_check_config = True # remove file removeFiles(['chkltex.ltx', 'chklatex.log']) latex_to_dvi = LATEX if latex_to_dvi != 'none': latex_to_dvi += ' $$i' path, latex_to_pdf = checkProg('a pdflatex program', ['pdflatex']) if latex_to_pdf != 'none': latex_to_pdf += ' $$i' path, tex_to_lyx_command = checkProg('a LaTeX -> LyX converter', ['reLyX'], ['./reLyX']) if tex_to_lyx_command == 'reLyX': tex_to_lyx_command += version_suffix + ' -f $$i' path, literate_to_lyx_command = checkProg('a Noweb -> LyX converter', ['noweb2lyx'], ['./reLyX']) if literate_to_lyx_command == 'noweb2lyx': literate_to_lyx_command += version_suffix + ' $$i $$o' path, literate_to_tex_command = checkProg('a Noweb -> LaTex converter', ['noweave'], ['./reLyX']) if literate_to_tex_command == 'noweave': literate_to_tex_command = literate_to_tex_command + version_suffix + ' -delay -index $$i > $$o' path, html_to_latex_command = checkProg('a HTML -> LaTex converter', ['html2latex']) if html_to_latex_command == 'html2latex': html_to_latex_command += ' $$i' path, word_to_latex_command = checkProg('a MSWord -> LaTex converter', ['wvCleanLatex', 'word2x']) if word_to_latex_command == 'wvCleanLatex': word_to_latex_command += ' $$i $$o' elif word_to_latex_command == 'word2x': word_to_latex_command += ' -f latex $$i' path, image_command = checkProg('Image converter', ['convert']) if image_command == 'convert': image_command += ' $$i $$o' path, prog = checkProg('a Postscript interpreter', ['gs']) # add rc file entry rc_entries += '\n\\ps_command "' + prog + '"' path, GHOSTVIEW = checkProg('a Postscript previewer', ['gsview32', 'gv', 'ghostview']) if GHOSTVIEW in [ 'gv', 'ghostview']: PS_VIEWER = GHOSTVIEW + ' -swap' else: PS_VIEWER = GHISTVIEW EPS_VIEWER = GHOSTVIEW path, PDF_VIEWER = checkProg('a PDF previewer', ['acrobat', 'acrord32', 'gsview32', \ 'acroread', 'gv', 'ghostview', 'xpdf']) path, DVI_VIEWER = checkProg('a DVI previewer', ['xdvi', 'windvi', 'yap']) path, HTML_VIEWER = checkProg('a HTML previewer', ['mozilla file://$$p$$i', 'netscape']) path, ps_to_pdf_command = checkProg('a PS to PDF converter', ['ps2pdf']) if ps_to_pdf_command == 'ps2pdf': ps_to_pdf_command += ' -dCompatibilityLevel=1.3 $$i' path, dvi_to_ps_command = checkProg('a DVI to PS converter', ['dvips']) if dvi_to_ps_command == 'dvips': dvi_to_ps_command += ' -o $$o $$i' path, dvi_to_pdf_command = checkProg('a DVI to PDF converter', ['dvipdfm']) if dvi_to_pdf_command == 'dvipdfm': dvi_to_pdf_command += ' $$i' ### We have a script to convert previewlyx to ppm lyxpreview_to_bitmap_command = "lyxpreview2ppm.py" path, prog = checkProg('a *roff formatter', ['groff -t -Tlatin1 $$FName', 'nroff']) if prog == 'nroff': prog = 'tbl $$FName | nroff' rc_entries += '\n\\ascii_roff_command "' + prog + '"' path, prog = checkProg('ChkTeX', ['chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38']) rc_entries += '\n\\chktex_command "' + prog + '"' path, prog = checkProg('a spell-checker', ['ispell']) rc_entries += '\n\\spell_command "' + prog + '"' path, OCTAVE = checkProg('Octave', ['octave']) path, MAPLE = checkProg('Maple', ['maple']) path, fax_command = checkProg('a fax program', ['kdeprintfax', 'ksendfax']) if fax_command != 'none': fax_command += ' $$i' path, LINUXDOC = checkProg('SGML-tools 1.x (LinuxDoc)', ['sgml2lyx']) if LINUXDOC != 'none': chk_linuxdoc = 'yes' bool_linuxdoc = 'true' linuxdoc_cmd = '\\def\\haslinuxdoc{yes}' linuxdoc_to_latex_command = 'sgml2latex $$i' linuxdoc_to_dvi_command = 'sgml2latex -o dvi $$i' linuxdoc_to_html_command = 'sgml2html $$i' linuxdoc_to_lyx_command = 'sgml2lyx $$i' else: chk_linuxdoc = 'no' bool_linuxdoc = 'false' linuxdoc_to_latex_command = 'none' linuxdoc_to_dvi_command = 'none' linuxdoc_to_html_command = 'none' linuxdoc_to_lyx_command = 'none' path, DOCBOOK = checkProg('SGML-tools 2.x (DocBook) or db2x scripts', ['sgmltools', 'db2dvi']) if DOCBOOK != 'none': chk_docbook = 'yes' bool_docbook = 'true' docbook_cmd = '\\def\\hasdocbook{yes}' else: chk_docbook = 'no' bool_docbook = 'false' if DOCBOOK == 'sgmltools': docbook_to_dvi_command = 'sgmltools -b dvi $$i' docbook_to_html_command = 'sgmltools -b html $$i' elif DOCBOOK == 'db2dvi': docbook_to_dvi_command = 'db2dvi $$i' docbook_to_html_command = 'db2html $$i' else: # none docbook_to_dvi_command = 'none' docbook_to_html_command = 'none' path, prog = checkProg('a spool command', ['lp', 'lpr']) rc_entries += '\n\\print_spool_command "' + prog + '"' if prog == 'lp': print_spool_printerprefix = '-d ' elif prog == 'lpr': print_spool_printerprefix = '-P' rc_entries += '\n\\print_spool_printerprefix "' + print_spool_printerprefix + '"' path, TOHTML = checkProg('a LaTeX -> HTML converter', ['tth', 'latex2html', 'hevea']) if TOHTML == 'tth': latex_to_html_command = 'tth -t -e2 -L$$b < $$i > $$o' elif TOHTML == 'latex2html': latex_to_html_command = 'latex2html -no_subdir -split 0 -show_section_numbers $$i' elif TOHTML == 'hevea': latex_to_html_command = 'hevea -s $$i' #### Explore the LaTeX configuration print '\nchecking LaTeX configuration... ', # ### First, remove the files that we want to re-create removeFiles(['textclass.lst', 'packages.lst', 'chkconfig.sed']) if not lyx_check_config: print ' default values', print '\n+checking list of textclasses... ' tx = open('textclass.lst', 'w') tx.write(''' # This file declares layouts and their associated definition files # (include dir. relative to the place where this file is). # It contains only default values, since chkconfig.ltx could not be run # for some reason. Run ./configure if you need to update it after a # configuration change. ''') # build the list of available layout files and convert it to commands # for chkconfig.ltx foundClasses = [] # sed filters p1 = re.compile(r'\Declare(LaTeX|DocBook|LinuxDoc)Class') p2 = re.compile(r'^.*\DeclareLaTeXClass *(.*)') p3 = re.compile(r'^.*\DeclareDocBookClass *(.*)') p4 = re.compile(r'^.*\DeclareLinuxDocClass *(.*)') p5 = re.compile(r'\[([^,]*),[^]]*\]') p6 = re.compile('^{') p7 = re.compile(r'\[([^]]*)\] *{([^}]*)}') for file in os.listdir('layouts') + os.listdir( os.path.join(srcdir, 'layouts') ): # remove none-layout file if file[-7:] != '.layout': continue # diretory info is lost if os.path.isfile(os.path.join('layouts', file)): file = os.path.join('layouts', file) elif os.path.isfile(os.path.join(srcdir, file)): file = os.path.join(srcdir, file) else: continue # get stuff between /xxxx.layout . classname = file.split(os.sep)[-1].split('.')[0] # tr ' -' '__'` cleanclass = classname.replace(' ', '_') cleanclass = cleanclass.replace('-', '_') # make sure the same class is not considered twice if foundClasses.count(cleanclass) == 0: # not found before foundClasses.append(cleanclass) # The sed commands below are a bit scary. Here is what they do: # 1-3: remove the \DeclareFOO macro and add the correct boolean # at the end of the line telling whether the class is # available # 4: if the macro had an optional argument with several # parameters, only keep the first one # 5: if the macro did not have an optional argument, provide one # (equal to the class name) # 6: remove brackets and replace with correctly quoted entries # grep '\\Declare\(LaTeX\|DocBook\|LinuxDoc\)Class' "$file" \ # | sed -e 's/^.*\DeclareLaTeXClass *\(.*\)/\1 "false"/' \ # -e 's/^.*\DeclareDocBookClass *\(.*\)/\1 "'$bool_docbook'"/' \ # -e 's/^.*\DeclareLinuxDocClass *\(.*\)/\1 "'$bool_linuxdoc'"/' \ # -e 's/\[\([^,]*\),[^]]*\]/[\1]/' \ # -e 's/^{/['$class']{/' \ # -e 's/\[\([^]]*\)\] *{\([^}]*\)}/"'$class'" "\1" "\2"/' \ # >>textclass.lst # for line in open(file).readlines(): try: # Declear ...? if p1.search(line) == None: continue line = p2.sub(r'\1 "false"', line) line = p3.sub(r'\1 "' + bool_docbook + '"', line) line = p4.sub(r'\1 "' + bool_linuxdoc + '"', line) line = p5.sub(r'[\1]', line) line = p6.sub("[" + classname + "]{", line) line = p7.sub( "'" + classname + "'" + r'"\1" "\2"', line) tx.write(line) except: raise continue tx.close() print '\tdone' else: print '\tauto' removeFiles(['wrap_chkconfig.ltx', 'chkconfig.vars', \ 'chkconfig.classes', 'chklayouts.tex']) writeToFile('wrap_chkconfig.ltx', '''\\newcommand\\srcdir{%s} %s %s \\input{%s/chkconfig.ltx} ''' % (srcdir, linuxdoc_cmd, docbook_cmd, srcdir) ) cl = open('chklayouts.tex', 'w') ## Construct the list of classes to test for. # build the list of available layout files and convert it to commands # for chkconfig.ltx for file in os.listdir('layouts') + os.listdir( os.path.join(srcdir, 'layouts') ): # remove none-layout file if file[-7:] != '.layout': continue # directory info is lost if os.path.isfile(os.path.join('layouts', file)) or \ os.path.isfile(os.path.join(srcdir, 'layouts', file)): # \TestDocClass{\1} line = re.sub(r'^(.*)\.layout$', r'\TestDocClass{\1}', file) cl.write(line) cl.close() # # we have chklayouts.tex, then process it fout = os.popen(LATEX + ' wrap_chkconfig.ltx') for line in fout.readlines(): if re.match('^\+', line): print line, fout.close() # # evalulate lines in chkconfig.vars? # is it really necessary? for line in open('chkconfig.vars').readlines(): exec( re.sub('-', '_', line) ) ### Do we have all the files we need? Useful if latex did not run ### if chkconfig.sed does not exist (because LaTeX did not run), ### then provide a standard version. if not os.path.isfile('chkconfig.sed'): writeToFile('chkconfig.sed', ''' ##s/@.*@/???/g ''') print "creating packages.lst" ### if packages.lst does not exist (because LaTeX did not run), ### then provide a standard version. if not os.path.isfile('packages.lst'): writeToFile('packages.lst', ''' ### This file should contain the list of LaTeX packages that have been ### recognized by LyX. Unfortunately, since configure could not find ### your LaTeX2e program, the tests have not been run. Run ./configure ### if you need to update it after a configuration change. ''') print 'creating doc/LaTeXConfig.lyx' # # This is originally done by sed, using a # tex-generated file chkconfig.sed # Now, we have to do it by hand. # # add to chekconfig.sed writeToFile('chkconfig.sed', '''[EMAIL PROTECTED]@!%s!g [EMAIL PROTECTED]@!%s!g ''' % (chk_linuxdoc, chk_docbook) , append=True) # # process this sed file!!!! ##sed -f chkconfig.sed ${srcdir}/doc/LaTeXConfig.lyx.in ## >doc/LaTeXConfig.lyx lyxin = open( os.path.join(srcdir, 'doc', 'LaTeXConfig.lyx.in')).readlines() lyxinnew = [] # get the rules p = re.compile(r's!(.*)!(.*)!g') for sed in open('chkconfig.sed').readlines(): try: fr, to = p.match(sed).groups() # print fr, to lyxinnew = [] for line in lyxin: lyxinnew.append( re.sub(fr, to, line) ) lyxin = lyxinnew except: pass writeToFile( os.path.join('doc', 'LaTeXConfig.lyx'), ''.join(lyxinnew)) print "creating ", outfile, writeToFile(outfile, ''' # This file has been automatically generated by LyX' lib/configure # script. It contains default settings that have been determined by # examining your system. PLEASE DO NOT MODIFY ANYTHING HERE! If you # want to customize LyX, make a copy of the file LYXDIR/lyxrc as # ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will # override the values given here. \\Format text txt ASCII A \\Format textparagraph txt ASCII(paragraphs) "" \\Format docbook sgml DocBook B \\Format bmp bmp BMP "" \\Format dvi dvi DVI D \\Format eps eps EPS "" \\Format fax "" Fax "" \\Format fig fig XFig "" \\Format agr agr GRACE "" \\Format html html HTML H \\Format gif gif GIF "" \\Format jpg jpg JPG "" \\Format latex tex LaTeX L \\Format linuxdoc sgml LinuxDoc x \\Format lyx lyx LyX "" \\Format literate nw NoWeb N \\Format pdf pdf PDF P \\Format pdf2 pdf "PDF (pdflatex)" F \\Format pdf3 pdf "PDF (dvipdfm)" m \\Format png png PNG "" \\Format ppm ppm PPM "" \\Format pgm pgm PGM "" \\Format pbm pbm PBM "" \\Format ps ps Postscript t \\Format program "" Program "" \\Format tgif obj TGIF "" \\Format tiff tif TIFF "" \\Format word doc Word W \\Format xbm xbm XBM "" \\Format xpm xpm XPM "" \\Format lyxpreview lyxpreview "LyX Preview" "" \\converter latex dvi "%s" "latex" \\converter latex pdf2 "%s" "latex" \\converter latex html "%s" "originaldir,needaux" \\converter literate latex "%s" "" \\converter dvi pdf3 "%s" "" \\converter dvi ps "%s" "" \\converter ps pdf "%s" "" \\converter ps fax "%s" "" \\converter linuxdoc lyx "%s" "" \\converter linuxdoc latex "%s" "" \\converter linuxdoc dvi "%s" "" \\converter linuxdoc html "%s" "" \\converter docbook dvi "%s" "" \\converter docbook html "%s" "" \\converter lyxpreview ppm "%s" "" \\converter latex lyx "%s" "" \\converter literate lyx "%s" "" \\converter html latex "%s" "" \\converter word latex "%s" "" \\viewer dvi "%s" \\viewer html "%s" \\viewer pdf "%s" \\viewer ps "%s" \\viewer eps "%s" %s \\font_encoding "%s" ''' % (latex_to_dvi, latex_to_pdf, latex_to_html_command, literate_to_tex_command,\ dvi_to_pdf_command, dvi_to_ps_command, ps_to_pdf_command, fax_command, \ linuxdoc_to_lyx_command, linuxdoc_to_latex_command, linuxdoc_to_dvi_command, \ linuxdoc_to_html_command, docbook_to_dvi_command, docbook_to_html_command, \ lyxpreview_to_bitmap_command, tex_to_lyx_command, literate_to_lyx_command, \ html_to_latex_command, word_to_latex_command, DVI_VIEWER, \ HTML_VIEWER, PDF_VIEWER, PS_VIEWER, EPS_VIEWER, rc_entries, chk_fontenc ) ) path, FIG2DEV = checkProg('an FIG -> EPS/PPM converter', ['fig2dev']) if FIG2DEV == 'fig2dev': writeToFile(outfile, ''' \\converter fig eps "fig2dev -L eps $$i $$o" "" \\converter fig ppm "fig2dev -L ppm $$i $$o" "" ''', append=True) path, TIFF2PS = checkProg('a TIFF -> PS converter', ['tiff2ps']) if TIFF2PS == 'tiff2ps': writeToFile(outfile, ''' \\converter tiff eps "tiff2ps $$i > $$o" "" ''', append=True) path, TGIF = checkProg('a TGIF -> EPS/PPM converter', ['tgif']) if TGIF == 'tgif': writeToFile(outfile, ''' \\converter tgif eps "tgif -stdout -print -color -eps $$i > $$o" "" \\converter tgif png "tgif -stdout -print -color -xpm $$i | xpmtoppm | pnmtopng > $$o" "" ''', append=True) path, EPSTOPDF = checkProg('a EPS -> PDF converter', ['epstopdf']) if EPSTOPDF == 'epstopdf': writeToFile(outfile, ''' \\converter eps pdf "epstopdf --outfile=$$o $$i" "" ''', append=True) path, GRACE = checkProg('a Grace -> Image converter', ['gracebat']) if GRACE == 'gracebat': writeToFile(outfile, ''' \\converter agr eps "gracebat -hardcopy -printfile $$o -hdevice EPS $$i 2>/dev/null" "" \\converter agr png "gracebat -hardcopy -printfile $$o -hdevice PNG $$i 2>/dev/null" "" \\converter agr jpg "gracebat -hardcopy -printfile $$o -hdevice JPEG $$i 2>/dev/null" "" \\converter agr ppm "gracebat -hardcopy -printfile $$o -hdevice PNM $$i 2>/dev/null" "" ''', append=True) ######## X FONTS # create a fonts.dir file to make X fonts available to LyX print "\nchecking for TeX fonts", fontlist = ['cmex10', 'cmmi10', 'cmr10', 'cmsy10', 'eufm10', \ 'msam10', 'msbm10', 'wasy10'] removeFiles([ "xfonts/fonts.dir", "xfonts/fonts.scale", \ "xfonts/tmpfonts"]) # kpsewhich is a texmf command! # how do I know is it available? # path, kpsewhich = checkProg('kpsewhich (under texmf)', ['kpsewhich']) if kpsewhich != 'kpsewhich': print "Tex is not installed properly. (Can not find kpsewhich" else: num = 0 for font in fontlist: print '\n+checking for ', font, '... ', result = False for ext in ['.pfb', '.pfa', '.ttf']: filepath = os.popen(kpsewhich + ' ' + font + ext).readline() if filepath.strip() != '': result = "yes (" + ext + ")" removeFiles( [os.path.join('xfonts', font+ext)] ) # hey, ln -s under windows? try: if sys.platform == 'win32': shutil(filepath, 'xfonts') else: # mac or linux? os.symlink(filepath, 'xfonts') except: # pass if file exists pass writeToFile( os.path.join('xfonts', 'tmpfonts'), "%s%s -unknown-%s-medium-r-normal--0-0-0-0-p-0-adobe-fontspecific\n" % (font, ext, font), append = True) num += 1 break print ' ', result, if num > 0: # found fonts writeToFile( os.path.join('xfonts', 'fonts.scale'), '%d\n' % num) writeToFile( os.path.join('xfonts', 'fonts.scale'), open( os.path.join('xfonts', 'tmpfonts')).read(), append = True) shutil.copy( os.path.join('xfonts', 'fonts.scale'), os.path.join('xfonts', 'fonts.dir') ) # create a resource list file for Display Postscript removeFiles( [os.path.join('xfonts', 'PSres.upr'), os.path.join('xfonts', 'tmpfonts')] ) os.popen('makepsres xfonts' ) # message is not displayed shutil.move('PSres.upr', os.path.join('xfonts', 'PSres.upr')) # Remove superfluous files if we are not writing in the main lib # directory for file in [outfile, 'textclass.lst', 'packages.lst', \ 'doc/LaTeXConfig.lyx', 'xfonts/fonts.dir']: try: # we rename the file first, so that we avoid comparing a file with itself os.rename(file, file + '.new') mycfg = open( os.path.join(srcdir, file) ).read() syscfg = open( file + '.new').read() if mycfg == syscfg: print "removing $file, which is identical to the system global version" removeFiles( [file + '.new'] ) else: os.rename( file + '.new', file ) except: # ignore if file not found os.rename( file + '.new', file ) pass if not os.path.isfile( os.path.join('xfonts', 'fonts.dir')): print "removing font links" removeFiles( os.path.join('xfonts', 'fonts.scale')) for file in os.listdir('xfonts'): if file[-4:] == '.pfb': removeFiles([os.path.join('xfonts', file)]) # Final clean-up if not lyx_keep_temps: removeFiles(['chkconfig.sed', 'chkconfig.vars', \ 'wrap_chkconfig.ltx', 'wrap_chkconfig.log', \ 'chklayouts.tex', 'missfont.log'])