From 198f4d748307a3d6d8be3bb29e4197606f24b6b8 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Mon, 24 Jul 2006 12:28:53 +0000 Subject: [PATCH] (datadir): remove LILYPONDPREFIX support. --- ChangeLog | 16 +- make/lilypond-vars.make | 5 +- scm/output-lib.scm | 4 +- scripts/abc2ly.py | 21 +-- scripts/convert-ly.py | 358 +++++++++++++++++++-------------------- scripts/etf2ly.py | 30 ++-- scripts/lilypond-book.py | 33 +--- scripts/midi2ly.py | 29 +--- scripts/musicxml2ly.py | 27 +-- 9 files changed, 230 insertions(+), 293 deletions(-) diff --git a/ChangeLog b/ChangeLog index f0d2e72c0e..8580df7eab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-07-24 Han-Wen Nienhuys + + * scripts/*.py (program_name): cleanup relocation snippets. + + * scripts/convert-ly.py (datadir): remove LILYPONDPREFIX support. + 2006-07-24 Joe Neeman * scm/define-grobs.scm (all-grob-descriptions): make NonMusicalPaperColumn @@ -28,6 +34,8 @@ 2006-07-23 Han-Wen Nienhuys + * VERSION (PACKAGE_NAME): release 2.9.13 + * scm/define-grobs.scm (all-grob-descriptions): remove stray assignment. @@ -35,13 +43,15 @@ * Documentation/topdocs/NEWS.tely (Top): doc new features. - * scm/output-lib.scm (grace-spacing::calc-shortest-duration): new function. + * scm/output-lib.scm (grace-spacing::calc-shortest-duration): new + function. * scm/define-grob-properties.scm (all-user-grob-properties): remove grace-space-factor. - * scm/define-grob-interfaces.scm (grace-spacing-interface): add grace-spacing-interface - (spacing-options-interface): add. + * scm/define-grob-interfaces.scm (grace-spacing-interface): add + grace-spacing-interface + (spacing-options-interface): add. * ly/engraver-init.ly (AncientRemoveEmptyStaffContext): add Grace_spacing_engraver diff --git a/make/lilypond-vars.make b/make/lilypond-vars.make index 107dd0a506..fe2920ad18 100644 --- a/make/lilypond-vars.make +++ b/make/lilypond-vars.make @@ -1,11 +1,10 @@ ## ## settings to run LilyPond ifeq ($(LILYPOND_EXTERNAL_BINARY),) + # environment settings. export PATH:=$(top-build-dir)/lily/$(outconfbase):$(top-build-dir)/buildscripts/$(outconfbase):$(top-build-dir)/scripts/$(outconfbase):$(PATH): -export LILYPONDPREFIX:=$(build_lilypond_datadir)/current -export DVIPSHEADERS:=$(top-build-dir)/mf/out:: -export LILYPOND_BINARY=$(top-build-dir)/lily/$(outconfbase)/lilypond +export LILYPOND_BINARY=$(top-build-dir)/$(outconfbase)/bin/lilypond else ## better not take the binaries from a precompiled bundle, as they diff --git a/scm/output-lib.scm b/scm/output-lib.scm index dd456be80c..2496763397 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -399,6 +399,6 @@ centered, X==1 is at the right, X == -1 is at the left." (x x) (y y))))) - - (fold moment-min #f (map get-difference (iota (1- (ly:grob-array-length cols))))))) + (fold moment-min #f (map get-difference + (iota (1- (ly:grob-array-length cols))))))) diff --git a/scripts/abc2ly.py b/scripts/abc2ly.py index 6121e51c6a..ba60c1cfee 100644 --- a/scripts/abc2ly.py +++ b/scripts/abc2ly.py @@ -77,25 +77,16 @@ import os program_name = sys.argv[0] -datadir = '@local_lilypond_datadir@' -if not os.path.isdir (datadir): - datadir = '@lilypond_datadir@' - -sys.path.insert (0, os.path.join (datadir, 'python')) - -if os.environ.has_key ('LILYPONDPREFIX'): - datadir = os.environ['LILYPONDPREFIX'] - while datadir[-1] == os.sep: - datadir= datadir[:-1] - - datadir = os.path.join (datadir, "share/lilypond/current/") -sys.path.insert (0, os.path.join (datadir, 'python')) +for d in ['@lilypond_datadir@', + '@lilypond_libdir@']: + sys.path.insert (0, os.path.join (d, 'python')) # dynamic relocation, for GUB binaries. -bindir = os.path.split (sys.argv[0])[0] +bindir = os.path.abspath (os.path.split (sys.argv[0])[0]) for p in ['share', 'lib']: datadir = os.path.abspath (bindir + '/../%s/lilypond/current/python/' % p) - sys.path.insert (0, os.path.join (datadir)) + sys.path.insert (0, datadir) + import lilylib as ly global _;_=ly._ diff --git a/scripts/convert-ly.py b/scripts/convert-ly.py index c4c1e74082..9c3ebeee83 100644 --- a/scripts/convert-ly.py +++ b/scripts/convert-ly.py @@ -18,23 +18,15 @@ import re datadir = '@local_lilypond_datadir@' if not os.path.isdir (datadir): - datadir = '@lilypond_datadir@' + datadir = '@lilypond_datadir@' sys.path.insert (0, os.path.join (datadir, 'python')) -if os.environ.has_key ('LILYPONDPREFIX'): - datadir = os.environ['LILYPONDPREFIX'] - while datadir[-1] == os.sep: - datadir= datadir[:-1] - - datadir = os.path.join (datadir, "share/lilypond/current/") -sys.path.insert (0, os.path.join (datadir, 'python')) - # dynamic relocation, for GUB binaries. -bindir = os.path.split (sys.argv[0])[0] +bindir = os.path.abspath (os.path.split (sys.argv[0])[0]) for p in ['share', 'lib']: - datadir = os.path.abspath (bindir + '/../%s/lilypond/current/python/' % p) - sys.path.insert (0, datadir) + datadir = os.path.abspath (bindir + '/../%s/lilypond/current/python/' % p) + sys.path.insert (0, datadir) import lilylib as ly global _;_=ly._ @@ -56,7 +48,7 @@ Examples: ''') copyright = ('Jan Nieuwenhuizen ', - 'Han-Wen Nienhuys ') + 'Han-Wen Nienhuys ') program_name = os.path.basename (sys.argv[0]) program_version = '@TOPLEVEL_VERSION@' @@ -64,17 +56,17 @@ program_version = '@TOPLEVEL_VERSION@' add_version = 1 def warning (s): - sys.stderr.write (program_name + ": " + _ ("warning: %s") % s + '\n') + sys.stderr.write (program_name + ": " + _ ("warning: %s") % s + '\n') def error (s): - sys.stderr.write (program_name + ": " + _ ("error: %s") % s + '\n') + sys.stderr.write (program_name + ": " + _ ("error: %s") % s + '\n') def identify (port=sys.stderr): - port.write ('%s (GNU LilyPond) %s\n' % (program_name, program_version)) + port.write ('%s (GNU LilyPond) %s\n' % (program_name, program_version)) def warranty (): - identify () - sys.stdout.write (''' + identify () + sys.stdout.write (''' Copyright (c) %s by Han-Wen Nienhuys @@ -89,212 +81,212 @@ Copyright (c) %s by def get_option_parser (): - p = ly.get_option_parser (usage='convert-ly [OPTIONS] FILE', - version="@TOPLEVEL_VERSION@", - description=help_summary) - - p.add_option ('-f', '--from', - action="store", - metavar=_ ("VERSION"), - dest="from_version", - help=_('start from VERSION [default: \\version found in file]'), - default='') - - p.add_option ('-e', '--edit', help=_('edit in place'), - action='store_true') - p.add_option ('-n', '--no-version', - help=_ ('do not add \\version command if missing'), - action='store_true', - dest='skip_version_add', - default=False) - - p.add_option ("-s", '--show-rules', - help=_('print rules [default: --from=0, --to=@TOPLEVEL_VERSION@]'), - dest='show_rules', - action='store_true', default=False) - - p.add_option ('-t', '--to', - help=_('convert to VERSION [default: @TOPLEVEL_VERSION@]'), - metavar=_('VERSION'), - action='store', - dest="to_version", - default='') - - p.add_option_group ('bugs', - description='''Report bugs via http://post.gmane.org/post.php''' - '''?group=gmane.comp.gnu.lilypond.bugs\n''') - - return p + p = ly.get_option_parser (usage='convert-ly [OPTIONS] FILE', + version="@TOPLEVEL_VERSION@", + description=help_summary) + + p.add_option ('-f', '--from', + action="store", + metavar=_ ("VERSION"), + dest="from_version", + help=_('start from VERSION [default: \\version found in file]'), + default='') + + p.add_option ('-e', '--edit', help=_('edit in place'), + action='store_true') + p.add_option ('-n', '--no-version', + help=_ ('do not add \\version command if missing'), + action='store_true', + dest='skip_version_add', + default=False) + + p.add_option ("-s", '--show-rules', + help=_('print rules [default: --from=0, --to=@TOPLEVEL_VERSION@]'), + dest='show_rules', + action='store_true', default=False) + + p.add_option ('-t', '--to', + help=_('convert to VERSION [default: @TOPLEVEL_VERSION@]'), + metavar=_('VERSION'), + action='store', + dest="to_version", + default='') + + p.add_option_group ('bugs', + description='''Report bugs via http://post.gmane.org/post.php''' + '''?group=gmane.comp.gnu.lilypond.bugs\n''') + + return p def str_to_tuple (s): - return tuple (map (int, string.split (s, '.'))) + return tuple (map (int, string.split (s, '.'))) def tup_to_str (t): - return string.join (map (lambda x: '%s' % x, list (t)), '.') + return string.join (map (lambda x: '%s' % x, list (t)), '.') def version_cmp (t1, t2): - for x in [0, 1, 2]: - if t1[x] - t2[x]: - return t1[x] - t2[x] - return 0 + for x in [0, 1, 2]: + if t1[x] - t2[x]: + return t1[x] - t2[x] + return 0 def get_conversions (from_version, to_version): - def is_applicable (v, f = from_version, t = to_version): - return version_cmp (v[0], f) > 0 and version_cmp (v[0], t) <= 0 - return filter (is_applicable, conversions) + def is_applicable (v, f = from_version, t = to_version): + return version_cmp (v[0], f) > 0 and version_cmp (v[0], t) <= 0 + return filter (is_applicable, conversions) def latest_version (): - return conversions[-1][0] + return conversions[-1][0] def show_rules (file, from_version, to_version): - for x in conversions: - if (not from_version or x[0] > from_version) \ - and (not to_version or x[0] <= to_version): - file.write ('%s: %s\n' % (tup_to_str (x[0]), x[2])) + for x in conversions: + if (not from_version or x[0] > from_version) \ + and (not to_version or x[0] <= to_version): + file.write ('%s: %s\n' % (tup_to_str (x[0]), x[2])) def do_conversion (str, from_version, to_version): - """Apply conversions from FROM_VERSION to TO_VERSION. Return + """Apply conversions from FROM_VERSION to TO_VERSION. Return tuple (LAST,STR), with the last succesful conversion and the resulting string.""" - conv_list = get_conversions (from_version, to_version) + conv_list = get_conversions (from_version, to_version) - if error_file: - error_file.write (_ ("Applying conversion: ")) - - last_conversion = () - try: - for x in conv_list: - error_file.write (tup_to_str (x[0])) - if x != conv_list[-1]: - error_file.write (', ') - str = x[1] (str) - last_conversion = x[0] + if error_file: + error_file.write (_ ("Applying conversion: ")) + + last_conversion = () + try: + for x in conv_list: + error_file.write (tup_to_str (x[0])) + if x != conv_list[-1]: + error_file.write (', ') + str = x[1] (str) + last_conversion = x[0] - except FatalConversionError: - error_file.write (_ ("error while converting")) - error_file.write ('\n') - error_file.write (_ ("Aborting")) - error_file.write ('\n') + except FatalConversionError: + error_file.write (_ ("error while converting")) + error_file.write ('\n') + error_file.write (_ ("Aborting")) + error_file.write ('\n') - return (last_conversion, str) + return (last_conversion, str) def guess_lilypond_version (filename): - s = open (filename).read () - m = lilypond_version_re.search (s) - if m: - return m.group (1) - else: - return '' + s = open (filename).read () + m = lilypond_version_re.search (s) + if m: + return m.group (1) + else: + return '' class FatalConversionError: - pass + pass class UnknownVersion: - pass + pass def do_one_file (infile_name): - sys.stderr.write (_ ("Processing `%s\'... ") % infile_name) - sys.stderr.write ('\n') - - from_version = None - to_version = None - if global_options.from_version: - from_version = global_options.from_version - else: - guess = guess_lilypond_version (infile_name) - if not guess: - raise UnknownVersion () - from_version = str_to_tuple (guess) - - if global_options.to_version: - to_version = global_options.to_version - else: - to_version = latest_version () - - - if infile_name: - infile = open (infile_name, 'r') - else: - infile = sys.stdin - - - (last, result) = do_conversion (infile.read (), from_version, to_version) - infile.close () - - if last: - newversion = r'\version "%s"' % tup_to_str (last) - if lilypond_version_re.search (result): - result = re.sub (lilypond_version_re_str, - '\\' + newversion, result) - elif add_version: - result = newversion + '\n' + result - - error_file.write ('\n') - - if global_options.edit: - try: - os.remove(infile_name + '~') - except: - pass - os.rename (infile_name, infile_name + '~') - outfile = open (infile_name, 'w') - else: - outfile = sys.stdout - - - outfile.write (result) - - sys.stderr.flush () + sys.stderr.write (_ ("Processing `%s\'... ") % infile_name) + sys.stderr.write ('\n') + + from_version = None + to_version = None + if global_options.from_version: + from_version = global_options.from_version + else: + guess = guess_lilypond_version (infile_name) + if not guess: + raise UnknownVersion () + from_version = str_to_tuple (guess) + + if global_options.to_version: + to_version = global_options.to_version + else: + to_version = latest_version () + + + if infile_name: + infile = open (infile_name, 'r') + else: + infile = sys.stdin + + + (last, result) = do_conversion (infile.read (), from_version, to_version) + infile.close () + + if last: + newversion = r'\version "%s"' % tup_to_str (last) + if lilypond_version_re.search (result): + result = re.sub (lilypond_version_re_str, + '\\' + newversion, result) + elif add_version: + result = newversion + '\n' + result + + error_file.write ('\n') + + if global_options.edit: + try: + os.remove(infile_name + '~') + except: + pass + os.rename (infile_name, infile_name + '~') + outfile = open (infile_name, 'w') + else: + outfile = sys.stdout + + + outfile.write (result) + + sys.stderr.flush () def do_options (): - opt_parser = get_option_parser() - (options, args) = opt_parser.parse_args () + opt_parser = get_option_parser() + (options, args) = opt_parser.parse_args () - if options.from_version: - options.from_version = str_to_tuple (options.from_version) - if options.to_version: - options.to_version = str_to_tuple (options.to_version) + if options.from_version: + options.from_version = str_to_tuple (options.from_version) + if options.to_version: + options.to_version = str_to_tuple (options.to_version) - options.outfile_name = '' - global global_options - global_options = options + options.outfile_name = '' + global global_options + global_options = options - if not args and not options.show_rules: - opt_parser.print_help () - sys.exit (2) + if not args and not options.show_rules: + opt_parser.print_help () + sys.exit (2) - return args + return args def main (): - files = do_options () - - # should parse files[] to read \version? - if global_options.show_rules: - show_rules (sys.stdout, global_options.from_version, global_options.to_version) - sys.exit (0) - - identify (sys.stderr) - - for f in files: - if f == '-': - f = '' - elif not os.path.isfile (f): - error (_ ("can't open file: `%s'") % f) - if len (files) == 1: - sys.exit (1) - continue - try: - do_one_file (f) - except UnknownVersion: - error (_ ("can't determine version for `%s'. Skipping") % f) - - sys.stderr.write ('\n') + files = do_options () + + # should parse files[] to read \version? + if global_options.show_rules: + show_rules (sys.stdout, global_options.from_version, global_options.to_version) + sys.exit (0) + + identify (sys.stderr) + + for f in files: + if f == '-': + f = '' + elif not os.path.isfile (f): + error (_ ("can't open file: `%s'") % f) + if len (files) == 1: + sys.exit (1) + continue + try: + do_one_file (f) + except UnknownVersion: + error (_ ("can't determine version for `%s'. Skipping") % f) + + sys.stderr.write ('\n') main () diff --git a/scripts/etf2ly.py b/scripts/etf2ly.py index a5291e92ad..0e85317a2e 100644 --- a/scripts/etf2ly.py +++ b/scripts/etf2ly.py @@ -43,32 +43,22 @@ if version == '@' + 'TOPLEVEL_VERSION' + '@': ################################################################ # Users of python modules should include this snippet. # -libdir = '@local_lilypond_libdir@' -if not os.path.isdir (libdir): - libdir = '@lilypond_libdir@' - -# ugh -datadir = '@local_lilypond_datadir@' -if os.environ.has_key ('LILYPONDPREFIX'): - datadir = os.environ['LILYPONDPREFIX'] - while datadir[-1] == os.sep: - datadir= datadir[:-1] - libdir = datadir.replace ('/share/', '/lib/') - -if os.path.exists (os.path.join (datadir, 'lib/lilypond/@TOPLEVEL_VERSION@/')): - libdir = os.path.join (libdir, 'lib/lilypond/@TOPLEVEL_VERSION@/') - -if os.path.exists (os.path.join (datadir, 'lib/lilypond/current/')): - libdir = os.path.join (libdir, 'lib/lilypond/current/') - -sys.path.insert (0, os.path.join (libdir, 'python')) + + + + +for d in ['@lilypond_datadir@', + '@lilypond_libdir@']: + sys.path.insert (0, os.path.join (d, 'python')) + # dynamic relocation, for GUB binaries. -bindir = os.path.split (sys.argv[0])[0] +bindir = os.path.abspath (os.path.split (sys.argv[0])[0]) for p in ['share', 'lib']: datadir = os.path.abspath (bindir + '/../%s/lilypond/current/python/' % p) sys.path.insert (0, datadir) + ################################################################ import lilylib as ly diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index abba494907..7861c524a5 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -36,40 +36,19 @@ import os import sys import re -# Users of python modules should include this snippet -# and customize variables below. - -# We'll suffer this path initialization stuff as long as we don't install -# our python packages in /lib/pythonX.Y - -# If set, LILYPONDPREFIX must take prevalence. -# if datadir is not set, we're doing a build and LILYPONDPREFIX. - ################ # RELOCATION ################ -datadir = '@local_lilypond_datadir@' -if not os.path.isdir (datadir): - datadir = '@lilypond_datadir@' - -sys.path.insert (0, os.path.join (datadir, 'python')) -if os.environ.has_key ('LILYPONDPREFIX'): - datadir = os.environ['LILYPONDPREFIX'] - while datadir[-1] == os.sep: - datadir = datadir[:-1] - - if not os.path.exists (os.path.join (datadir, 'python/lilylib.py')): - datadir = os.path.join (datadir, 'share/lilypond/current/') -sys.path.insert (0, os.path.join (datadir, 'python')) +for d in ['@lilypond_datadir@', + '@lilypond_libdir@']: + sys.path.insert (0, os.path.join (d, 'python')) # dynamic relocation, for GUB binaries. -bindir = os.path.split (sys.argv[0])[0] - - -for prefix_component in ['share', 'lib']: - datadir = os.path.abspath (bindir + '/../%s/lilypond/current/python/' % prefix_component) +bindir = os.path.abspath (os.path.split (sys.argv[0])[0]) +for p in ['share', 'lib']: + datadir = os.path.abspath (bindir + '/../%s/lilypond/current/python/' % p) sys.path.insert (0, datadir) diff --git a/scripts/midi2ly.py b/scripts/midi2ly.py index 256063d679..e35e9d13ea 100644 --- a/scripts/midi2ly.py +++ b/scripts/midi2ly.py @@ -28,33 +28,20 @@ import sys ################################################################ # Users of python modules should include this snippet. # -libdir = '@local_lilypond_libdir@' -if not os.path.isdir (libdir): - libdir = '@lilypond_libdir@' -# ugh -datadir = '@local_lilypond_datadir@' -if os.environ.has_key ('LILYPONDPREFIX'): - datadir = os.environ['LILYPONDPREFIX'] - while datadir[-1] == os.sep: - datadir= datadir[:-1] - libdir = datadir.replace ('/share/', '/lib/') +for d in ['@lilypond_datadir@', + '@lilypond_libdir@']: + sys.path.insert (0, os.path.join (d, 'python')) -if os.path.exists (os.path.join (datadir, 'lib/lilypond/@TOPLEVEL_VERSION@/')): - libdir = os.path.join (libdir, 'lib/lilypond/@TOPLEVEL_VERSION@/') - -if os.path.exists (os.path.join (datadir, 'lib/lilypond/current/')): - libdir = os.path.join (libdir, 'lib/lilypond/current/') - -sys.path.insert (0, os.path.join (libdir, 'python')) +sys.path.insert (0, os.path.join (datadir, 'python')) # dynamic relocation, for GUB binaries. -bindir = os.path.split (sys.argv[0])[0] - -for prefix_component in ['share', 'lib']: - datadir = os.path.abspath (bindir + '/../%s/lilypond/current/python/' % prefix_component) +bindir = os.path.abspath (os.path.split (sys.argv[0])[0]) +for p in ['share', 'lib']: + datadir = os.path.abspath (bindir + '/../%s/lilypond/current/python/' % p) sys.path.insert (0, datadir) + import midi import lilylib as ly diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index 5f25567c59..f3fd9a7a06 100644 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -9,30 +9,19 @@ from gettext import gettext as _ - -datadir = '@local_lilypond_datadir@' -if not os.path.isdir (datadir): - datadir = '@lilypond_datadir@' -if os.environ.has_key ('LILYPONDPREFIX'): - datadir = os.environ['LILYPONDPREFIX'] - while datadir[-1] == os.sep: - datadir = datadir[:-1] - -if os.path.exists (os.path.join (datadir, 'share/lilypond/@TOPLEVEL_VERSION@/')): - datadir = os.path.join (datadir, 'share/lilypond/@TOPLEVEL_VERSION@/') -elif os.path.exists (os.path.join (datadir, 'share/lilypond/current/')): - datadir = os.path.join (datadir, 'share/lilypond/current/') - -sys.path.insert (0, os.path.join (datadir, 'python')) +for d in ['@lilypond_datadir@', + '@lilypond_libdir@']: + sys.path.insert (0, os.path.join (d, 'python')) # dynamic relocation, for GUB binaries. -bindir = os.path.split (sys.argv[0])[0] - -for prefix_component in ['share', 'lib']: - datadir = os.path.abspath (bindir + '/../%s/lilypond/current/python/' % prefix_component) +bindir = os.path.abspath (os.path.split (sys.argv[0])[0]) +for p in ['share', 'lib']: + datadir = os.path.abspath (bindir + '/../%s/lilypond/current/python/' % p) sys.path.insert (0, datadir) + + import lilylib as ly import musicxml -- 2.39.2