From b41e2a62a4ac31e83ca3272a4570c9d8370fa04a Mon Sep 17 00:00:00 2001 From: Arlett Grygar Date: Mon, 30 Dec 2024 23:47:13 +0100 Subject: [PATCH] windows includes angepasst --- all_base_includes.ly | 19 +++++++++++++++---- scm/yaml_parser.scm | 4 +++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/all_base_includes.ly b/all_base_includes.ly index b71665d..7dd398c 100644 --- a/all_base_includes.ly +++ b/all_base_includes.ly @@ -1,10 +1,21 @@ #(define noStandaloneOutput (if (defined? 'noStandaloneOutput) noStandaloneOutput #f)) +#(define windows? (string-prefix-ci? "windows" (utsname:sysname (uname)))) + #(if (defined? 'LAYOUT) #f - (let ((scmdir (string-append (dirname (current-filename)) file-name-separator-string "scm" file-name-separator-string))) - (load (string-append scmdir "json_parser.scm")) - (load (string-append scmdir "resolve_inherits.scm")) - (load (string-append scmdir "yaml_parser.scm")))) + (let ((scm-load (lambda (filename) (load ( + string-append + ; on windows the detection of absolute pathes is broken (cause they start with a drive letter and not with a /) + ; so we have to use relative pathes for load. That works in frescobaldi, but not if you call lilypond from command line, + ; with a relative path to the .ly file, so we use absolute pathes on posix systems, where it works. + (if windows? + "" + (string-append (dirname (current-filename)) file-name-separator-string)) + "scm" file-name-separator-string filename + ))))) + (scm-load "json_parser.scm") + (scm-load "resolve_inherits.scm") + (scm-load "yaml_parser.scm"))) #(define AUTHOR_DATA (if (defined? 'AUTHOR_DATA) AUTHOR_DATA (parse-yml-file "../../lilypond-song-includes/data/authors.yml"))) #(define SONG_DATA (if (defined? 'SONG_DATA) SONG_DATA (parse-yml-file "../../lilypond-song-includes/data/songs.yml"))) diff --git a/scm/yaml_parser.scm b/scm/yaml_parser.scm index 6ecae50..7930a52 100644 --- a/scm/yaml_parser.scm +++ b/scm/yaml_parser.scm @@ -2,7 +2,9 @@ (define (yml-file->scm filename) (let* ((python_cmd (string-append "import sys, yaml, json; print(json.dumps(yaml.safe_load(open('" filename "'))))")) - (pipe (open-pipe* OPEN_READ "python3" "-c" python_cmd)) + ; WTF? On Windows there is "py" and we need to specify the encoding, on linux there is "python3" or "python" + ; but "python3" seems to work better. Be sure you have PyYAML installed. + (pipe (open-pipe* OPEN_READ (if windows? "py" "python3") "-X" "utf8" "-c" python_cmd)) (json (get-string-all pipe))) (close-pipe pipe) (json-string->scm json)))