]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/ly2dvi.py
release: 1.5.43
[lilypond.git] / scripts / ly2dvi.py
index 1857dcef5dbf7700bd8d9b19e29a22e8090b1d20..d428202869b5eccf511cac581c4c8c2bba2ef0c9 100644 (file)
@@ -1,4 +1,5 @@
 #!@PYTHON@
+
 # Run lilypond, latex, dvips.
 #
 # This is the third incarnation of ly2dvi.
@@ -14,7 +15,7 @@
 # TODO: should allow to switch off pk cache.
 #
 
-
+#
 # Note: gettext work best if we use ' for docstrings and "
 #       for gettextable strings.
 #       --> DO NOT USE """ for docstrings.
@@ -95,7 +96,7 @@ def identify ():
 def warranty ():
        identify ()
        sys.stdout.write ('\n')
-       sys.stdout.write (_ ('Copyright (c) %s by' % ' 2001'))
+       sys.stdout.write (_ ('Copyright (c) %s by' % ' 2001--2002'))
        sys.stdout.write ('\n')
        sys.stdout.write ('  Han-Wen Nienhuys')
        sys.stdout.write ('  Jan Nieuwenhuizen')
@@ -263,8 +264,6 @@ datadir = '@datadir@'
 
 
 if os.environ.has_key ('LILYPONDPREFIX') :
-# huh ? this always leads to exception.
-# or '@datadir@' == '@' + 'datadir' + '@':   
        datadir = os.environ['LILYPONDPREFIX']
 else:
        datadir = '@datadir@'
@@ -360,21 +359,23 @@ track_dependencies_p = 0
 dependency_files = []
 
 
-#
-# Try to cater for bad installations of LilyPond, that have
-# broken TeX setup.  Just hope this doesn't hurt good TeX
-# setups.  Maybe we should check if kpsewhich can find
-# feta16.{afm,mf,tex,tfm}, and only set env upon failure.
-#
+
+kpse = os.popen ('kpsexpand \$TEXMF').read()
+kpse = re.sub('[ \t\n]+$','', kpse)
+
 environment = {
-       'MFINPUTS' : datadir + '/mf' + ':',
-       'TEXINPUTS': datadir + '/tex:' + datadir + '/ps:' + '.:'
-               + os.getcwd() + ':',
-       'TFMFONTS' : datadir + '/tfm' + ':',
+       ## todo: prevent multiple addition.
+       'TEXMF' : "{%s,%s}" % (datadir, kpse) ,
        'GS_FONTPATH' : datadir + '/afm:' + datadir + '/pfa',
        'GS_LIB' : datadir + '/ps',
 }
 
+# tex needs lots of memory, more than it gets by default on Debian
+non_path_environment = {
+       'extra_mem_top' : '1000000',
+       'extra_mem_bottom' : '1000000',
+       'pool_size' : '250000',
+}
 
 def setup_environment ():
        for key in environment.keys ():
@@ -383,6 +384,10 @@ def setup_environment ():
                        val = os.environ[key] + os.pathsep + val 
                os.environ[key] = val
 
+       for key in non_path_environment.keys ():
+               val = non_path_environment[key]
+               os.environ[key] = val
+
 #what a name.
 def set_setting (dict, key, val):
        try:
@@ -442,7 +447,7 @@ def analyse_lilypond_output (filename, extra):
 
        # search only the first 10k
        s = s[:10240]
-       for x in ('textheight', 'linewidth', 'papersize', 'orientation'):
+       for x in extra_fields:
                m = re.search (r'\\def\\lilypondpaper%s{([^}]*)}'%x, s)
                if m:
                        set_setting (extra, x, m.group (1))