]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix a few lilypond-book bugs on windows (issue 1815).
authorJulien Rioux <jrioux@physics.utoronto.ca>
Tue, 4 Oct 2011 18:37:34 +0000 (20:37 +0200)
committerGraham Percival <graham@percival-music.ca>
Fri, 14 Oct 2011 18:54:26 +0000 (19:54 +0100)
  - book_snippets.py: Replace os.link (purely unix) when it is
                      unavailable by shutil.copyfile.

  - lilylib.py: Windows command-line arguments don't need escaping.

  - lilypond-book.py: Use forward slashes within lilypond files.

python/book_snippets.py
python/lilylib.py
scripts/lilypond-book.py

index ab7c66e47a60d1a98866e6626aa9564000264458..e3fc2eff950ff6034ca41296ea7488ca192f0942 100644 (file)
@@ -6,6 +6,7 @@ global _;_=ly._
 import re
 import os
 import copy
+import shutil
 # TODO: We are using os.popen3, which has been deprecated since python 2.6. The
 # suggested replacement is the Popen function of the subprocess module.
 # Unfortunately, on windows this needs the msvcrt module, which doesn't seem
@@ -639,7 +640,13 @@ printing diff against existing file." % filename)
             dst_path = os.path.split(dst)[0]
             if not os.path.isdir (dst_path):
                 os.makedirs (dst_path)
-            os.link (src, dst)
+            try:
+                os.link (src, dst)
+            except AttributeError:
+                shutil.copyfile (src, dst)
+            except OSError:
+                print '\nCould not overwrite file', dst
+                raise CompileError(self.basename())
 
     def additional_files_to_consider (self, base, full):
         return []
index e893aaa3a54482599374629d71ee514bd4eddfd5..7a36a8aaace6ab8cce1b09d8044dc61ced22b38a 100644 (file)
@@ -150,6 +150,8 @@ please read 'Setup for MacOS X' in Application Usage.")
 # Modified version of the commands.mkarg(x), which always uses
 # double quotes (since Windows can't handle the single quotes:
 def mkarg(x):
+    if os.name == 'nt':
+        return x
     s = ' "'
     for c in x:
         if c in '\\$"`':
index 4d2b000fbd80252d9a3776244f6ad7a26aebdf5f..69156d715e7f4c100f64dd628354a2bbb19adb49 100644 (file)
@@ -422,7 +422,7 @@ def write_file_map (lys, name):
 #(define output-empty-score-list #f)
 #(ly:add-file-name-alist '(%s
     ))\n
-""" % '\n'.join(['("%s.ly" . "%s")\n' % (ly.basename (), name)
+""" % '\n'.join(['("%s.ly" . "%s")\n' % (ly.basename ().replace('\\','/'), name)
                  for ly in lys]))
 
 def split_output_files(directory):