#!@PYTHON@
+
# Run lilypond, latex, dvips.
#
# This is the third incarnation of ly2dvi.
# 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.
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')
if os.environ.has_key ('LILYPONDPREFIX') :
-# huh ? this always leads to exception.
-# or '@datadir@' == '@' + 'datadir' + '@':
datadir = os.environ['LILYPONDPREFIX']
else:
datadir = '@datadir@'
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 ():
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:
# 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))