--- /dev/null
+This generic code used for all python scripts.
+
+The quotes are to ensure that the source .py file can still be
+run as a python script, but does not include any sys.path handling.
+Otherwise, the lilypond-book calls inside the build
+might modify installed .pyc files.
+
+"""
+
+for d in ['@lilypond_datadir@',
+ '@lilypond_libdir@']:
+ sys.path.insert (0, os.path.join (d, 'python'))
+
+# dynamic relocation, for GUB binaries.
+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)
+"""
LOCALSTEPMAKE_TEMPLATES = lilypond
HELP2MAN_EXECS = $(SEXECUTABLES)
+AT_FILES=relocate-preamble
+at-ext=.py.in
+at-dir=$(depth)/python
+
include $(depth)/make/stepmake.make
include $(stepdir)/executable-targets.make
-
program_name = sys.argv[0]
-for d in ['@lilypond_datadir@',
- '@lilypond_libdir@']:
- sys.path.insert (0, os.path.join (d, 'python'))
-
-# dynamic relocation, for GUB binaries.
-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)
-
+"""
+@relocate-preamble@
+"""
import lilylib as ly
global _;_=ly._
import string
import re
-
-datadir = '@local_lilypond_datadir@'
-if not os.path.isdir (datadir):
- datadir = '@lilypond_datadir@'
-
-sys.path.insert (0, os.path.join (datadir, 'python'))
-
-# dynamic relocation, for GUB binaries.
-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)
+"""
+@relocate-preamble@
+"""
import lilylib as ly
global _;_=ly._
if version == '@' + 'TOPLEVEL_VERSION' + '@':
version = '(unknown version)' # uGUHGUHGHGUGH
-
-################################################################
-# Users of python modules should include this snippet.
-#
-
-
-
-
-for d in ['@lilypond_datadir@',
- '@lilypond_libdir@']:
- sys.path.insert (0, os.path.join (d, 'python'))
-
-
-# dynamic relocation, for GUB binaries.
-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)
-
+"""
+@relocate-preamble@
+"""
################################################################
import re
import md5
-################
-# RELOCATION
-################
-
-
-for d in ['@lilypond_datadir@',
- '@lilypond_libdir@']:
- sys.path.insert (0, os.path.join (d, 'python'))
-
-# dynamic relocation, for GUB binaries.
-bindir = os.path.abspath (os.path.split (sys.argv[0])[0])
-
-os.environ['PATH'] = bindir + os.pathsep + os.environ['PATH']
-for p in ['share', 'lib']:
- datadir = os.path.abspath (bindir + '/../%s/lilypond/current/python/' % p)
- sys.path.insert (0, datadir)
-
+"""
+@relocate-preamble@
+"""
import lilylib as ly
import fontextract
import string
import sys
-################################################################
-# Users of python modules should include this snippet.
-#
-
-for d in ['@lilypond_datadir@',
- '@lilypond_libdir@']:
- sys.path.insert (0, os.path.join (d, 'python'))
-
-# dynamic relocation, for GUB binaries.
-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)
-
+"""
+@relocate-preamble@
+"""
import midi
import lilylib as ly
################################################################
-################ CONSTANTS
+## CONSTANTS
output_name = ''
import string
from gettext import gettext as _
-
-
-for d in ['@lilypond_datadir@',
- '@lilypond_libdir@']:
- sys.path.insert (0, os.path.join (d, 'python'))
-
-# dynamic relocation, for GUB binaries.
-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)
-
-
-
+"""
+@relocate-preamble@
+"""
import lilylib as ly
$(PYTHON) -O -c 'import py_compile; py_compile.compile ("$<")'
$(outdir)/%.py: %.py $(config_make)
- cat $< | sed $(sed-atvariables) > $@
+ cat $< | sed $(sed-atfiles) $(sed-atvariables) > $@
chmod 755 $@
+
$(outdir)/%: %.pl $(config_make) $(depth)/VERSION
- cat $< | sed $(sed-atvariables) > $@
+ cat $< | sed $(sed-atfiles) $(sed-atvariables) > $@
chmod 755 $@
$(outdir)/%: %.bash $(config_make) $(depth)/VERSION
- cat $< | sed $(sed-atvariables) > $@
+ cat $< | sed $(sed-atfiles) $(sed-atvariables) > $@
chmod 755 $@
$(outdir)/%: %.scm $(config_make) $(depth)/VERSION
- cat $< | sed $(sed-atvariables) > $@
+ cat $< | sed $(sed-atfiles) $(sed-atvariables) > $@
chmod 755 $@
$(outdir)/%: %.expect $(config_make) $(depth)/VERSION
- cat $< | sed $(sed-atvariables) > $@
+ cat $< | sed $(sed-atfiles) $(sed-atvariables) > $@
chmod 755 $@
$(outdir)/%: %.sh $(config_make) $(depth)/VERSION
- cat $< | sed $(sed-atvariables) > $@
+ cat $< | sed $(sed-atfiles)$(sed-atvariables) > $@
chmod 755 $@
$(outdir)/%: %.py $(config_make) $(depth)/VERSION
- cat $< | sed $(sed-atvariables) > $@
+ cat $< | sed $(sed-atfiles) $(sed-atvariables) > $@
chmod 755 $@
# for all FILE in AT_FILES:
# substitute occurrences of @FILE@ with contents $(at-dir)BLA$(at-ext)
sed-atfiles = -e '\#' $(foreach i, $(AT_FILES), \
- -e '/@$i@/r $(at-dir)$i$(at-ext)' -e 's%@$i@%%g')
+ -e '/@$i@/r $(at-dir)/$i$(at-ext)' -e 's%@$i@%%g')
# for all VAR in ATVARIABLES
# substitute occurrences of @VAR@ with $(VAR)
sed-atvariables = -e '\#' $(foreach i, $(ATVARIABLES), -e 's!@$i@!$($i)!g')
+