summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJulien Rioux <jrioux@physics.utoronto.ca>2012-03-20 12:19:56 -0400
committerJulien Rioux <jrioux@physics.utoronto.ca>2012-03-26 06:25:01 -0400
commit03f6b90453f1e4f5d794454c3a3f7f1f63eed0c0 (patch)
tree0ba60c30d5bc7ca3358232baac4c956fb62bfa6c /scripts
parente9f23376b8bac1ae6b776d944469712c983e844c (diff)
lilypond-book: Set include path for --output option (issue 2423).
Add the current working dir to the list of include paths.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lilypond-book.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py
index 395551ca05..a78fdfc02e 100644
--- a/scripts/lilypond-book.py
+++ b/scripts/lilypond-book.py
@@ -608,6 +608,22 @@ def do_file (input_filename, included=False):
progress (_ ("Removing `%s'") % output_filename)
raise BookSnippet.CompileError
+def inverse_relpath (path, relpath):
+ """Given two paths, the second relative to the first,
+ return the first path relative to the second."""
+ if os.path.isabs (relpath):
+ return os.path.abspath (path)
+ relparts = ['']
+ parts = os.path.normpath (path).split (os.path.sep)
+ for part in os.path.normpath (relpath).split (os.path.sep):
+ if part == '..':
+ relparts.append (parts[-1])
+ parts.pop ()
+ else:
+ relparts.append ('..')
+ parts.append (part)
+ return os.path.sep.join (relparts[::-1])
+
def do_options ():
global global_options
@@ -617,6 +633,10 @@ def do_options ():
global_options.information = {'program_version': ly.program_version, 'program_name': ly.program_name }
global_options.original_dir = original_dir
+ if global_options.output_dir:
+ global_options.output_dir = os.path.expanduser (global_options.output_dir)
+ global_options.include_path.insert (0, inverse_relpath (original_dir, global_options.output_dir))
+
# Load the python packages (containing e.g. custom formatter classes)
# passed on the command line
nr = 0