lyp 0.1.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +41 -16
- data/bin/install_release.sh +1 -1
- data/lib/lyp/package.rb +1 -1
- data/lib/lyp/templates/deps_wrapper.rb +38 -25
- data/lib/lyp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95a3a0c7bde875ba4dc99f647f476f3c38c38edc
|
4
|
+
data.tar.gz: a2b2624b43aa5ce75c697c5f3fb29dd3b8141ca9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 787384a486ddbb0f561404513cbda77fc783d5430428669d31021bf3c84878692fb4d13a2ee4bb0fe3a900ba46aa6711cf1815232b573272ca7b067d36cb12d9
|
7
|
+
data.tar.gz: 0dd250c4b5ce752610d59a17f14de1da74d7d91268cea0fb37cb90767a4395b74cefe88ce4d8a8865651d29c3fe2a45cb0d848d0668858567adad06be5b5872b
|
data/README.md
CHANGED
@@ -13,14 +13,18 @@ __No hassle Lilypond installation__: With lyp you can also install any version o
|
|
13
13
|
- [Installation](#installation)
|
14
14
|
- [How lyp works](#how-lyp-works)
|
15
15
|
- [Uninstalling](#uninstalling)
|
16
|
-
- [
|
16
|
+
- [Working with packages](#working-with-packages)
|
17
17
|
- [What constitutes a package?](#what-constitutes-a-package)
|
18
18
|
- [Installing packages](#installing-packages)
|
19
19
|
- [Package references](#package-references)
|
20
20
|
- [Version specifiers](#version-specifiers)
|
21
21
|
- [Using packages](#using-packages)
|
22
|
-
|
23
|
-
- [
|
22
|
+
- [Developing packages](#developing-packages)
|
23
|
+
- [The package interface](#the-package-interface)
|
24
|
+
- [Including files](#including-files)
|
25
|
+
- [Including fonts](#including-fonts)
|
26
|
+
- [Testing packages](#testing-packages)
|
27
|
+
- [Publishing packages](#publishing-packages)
|
24
28
|
- [Installing and switching Lilypond versions](#installing-and-switching-lilypond-versions)
|
25
29
|
- [Contributing](#contributing)
|
26
30
|
|
@@ -81,7 +85,7 @@ In order to completely remove all files in `~/.lyp` you can simply delete the di
|
|
81
85
|
rm -rf ~/.lyp
|
82
86
|
```
|
83
87
|
|
84
|
-
##
|
88
|
+
## Working with Packages
|
85
89
|
|
86
90
|
A package is a library of lilypond code, containing one or more lilypond files, that provide commonly-used functionality for users. A package can be a library of scheme code to extend lilypond, as in openlilylib; or a stylesheet which contains music fonts and additional lilypond code to change the look of the music: font, spacing, line widths, sizes, etc.
|
87
91
|
|
@@ -181,7 +185,7 @@ To include a package in your lilypond code, use ther `\require` command:
|
|
181
185
|
|
182
186
|
It is important to note that once you use `\require` in your code, you will have to compile it using the lilypond wrapper provided by lyp. It will not pass compilation using plain lilypond.
|
183
187
|
|
184
|
-
|
188
|
+
## Developing packages
|
185
189
|
|
186
190
|
To create a lilypond package:
|
187
191
|
|
@@ -191,7 +195,7 @@ To create a lilypond package:
|
|
191
195
|
- Test & debug your code (see below).
|
192
196
|
- Publish your package (see below).
|
193
197
|
|
194
|
-
To test your package
|
198
|
+
To test your package with an actual input file, you can install it from a local path (for more on testing [see below](#testing)). Suppose your package is at ~/repo/mypack:
|
195
199
|
|
196
200
|
```bash
|
197
201
|
lyp install mypack@dev:~/repo/mypack
|
@@ -203,29 +207,50 @@ This will create a `mypack@dev` package referencing your local files, which you
|
|
203
207
|
\require "mypack@dev"
|
204
208
|
```
|
205
209
|
|
206
|
-
###
|
210
|
+
### The package interface
|
207
211
|
|
208
|
-
In order to facilitate writing complex packages, lyp defines a few
|
212
|
+
In order to facilitate writing complex packages, lyp defines a few variables and functions:
|
209
213
|
|
210
|
-
|
214
|
+
- `lyp:current-package-dir` - the absolute directory path for the current package (at the time the package is loaded)
|
215
|
+
- `lyp:input-filename` - the absolute path for the user's file being compiled
|
216
|
+
- `lyp:input-dirname` - the absolute directory path for the user's file being compiled
|
211
217
|
|
212
|
-
|
213
|
-
- `lyp-input-filename` - the absolute path for the user's file being compiled
|
214
|
-
- `lyp-input-dirname` - the absolute directory path for the user's file being compiled
|
215
|
-
- `lyp-cwd` - the current working directory
|
218
|
+
### Including files
|
216
219
|
|
217
|
-
|
220
|
+
Lyp provides the `\pinclude` and `\pincludeOnce` commands for including files residing in the current package using relative paths. The `\pincludeOnce` commands loads a given file only once:
|
218
221
|
|
219
222
|
```lilypond
|
220
|
-
\
|
223
|
+
\pincludeOnce "inc/init.ily"
|
224
|
+
\pinclude "inc/template.ily"
|
221
225
|
```
|
222
226
|
|
223
|
-
|
227
|
+
Lyp also defines a `pload` scheme function for loading scheme files using relative paths without adding directories to the `%load-path`:
|
224
228
|
|
225
229
|
```lilypond
|
226
230
|
#(if (not (defined? 'mypack:init))(pload "scm/init.scm"))
|
227
231
|
```
|
228
232
|
|
233
|
+
Loading scheme files that way is better, because this way one avoids possible name clashes, which may lead to unexpected behavior.
|
234
|
+
|
235
|
+
### Including fonts
|
236
|
+
|
237
|
+
Lyp also supports automatic installation of fonts, based on work by [Abraham Leigh](https://github.com/tisimst). When a package is installed, lyp will copy any font files residing in the `fonts` directory into the corresponding `otf` and `svg` directories of all installed versions of lilypond.
|
238
|
+
|
239
|
+
**Note**: fonts will be only installed in versions of lilypond starting from than 2.18.2. Lyp automatically patches any version ower than 2.19.12 in order to support custom fonts.
|
240
|
+
|
241
|
+
### Testing Packages
|
242
|
+
|
243
|
+
Packages can be tested by using the `lyp test` command, which will compile any file found inside the package directory ending in `_test.ly`:
|
244
|
+
|
245
|
+
```bash
|
246
|
+
cd mypack
|
247
|
+
lyp test .
|
248
|
+
```
|
249
|
+
|
250
|
+
A test file can either be a simple lilypond file which includes the package files and results in a lilypond score, or a lilypond file that performs unit tests on scheme code.
|
251
|
+
|
252
|
+
For more information on testing, see the [lyp-assert](https://github.com/noteflakes/lyp-assert) package, which is meant to be used for unit testing lilypond code, and serves as an example of how to test a package.
|
253
|
+
|
229
254
|
### Publishing packages
|
230
255
|
|
231
256
|
In order for your package to be available to all users, you'll need to first push your code to a publically accessible git repository (for example on github). Users will then be able to install your package by using the git URL of the public repository.
|
data/bin/install_release.sh
CHANGED
data/lib/lyp/package.rb
CHANGED
@@ -85,7 +85,7 @@ module Lyp::Package
|
|
85
85
|
end
|
86
86
|
|
87
87
|
LOCAL_PACKAGE_WRAPPER =
|
88
|
-
"#(set! lyp
|
88
|
+
"#(set! lyp:current-package-dir \"%s\")\n\\include \"%s\"\n"
|
89
89
|
|
90
90
|
def install_from_local_files(package, version, opts)
|
91
91
|
version =~ /^([^\:]+)\:(.+)$/
|
@@ -16,26 +16,24 @@ current_package_dir = _[:current_package_dir] || FileUtils.pwd
|
|
16
16
|
|
17
17
|
# The wrapper defines a few global variables:
|
18
18
|
#
|
19
|
-
# lyp
|
20
|
-
# lyp
|
21
|
-
# lyp-
|
22
|
-
# lyp
|
23
|
-
# lyp-package-refs - a hash table mapping package refs to package entry
|
19
|
+
# lyp:input-filename - the absolute path to the input file name
|
20
|
+
# lyp:input-dirname - the absolute path to the input file directory name
|
21
|
+
# lyp:current-package-dir - the directory for the package currently being loaded
|
22
|
+
# lyp:package-refs - a hash table mapping package refs to package entry
|
24
23
|
# point absolute paths
|
25
|
-
# lyp
|
26
|
-
# lyp
|
24
|
+
# lyp:package-loaded - a hash table for keeping track of loaded packages
|
25
|
+
# lyp:file-included - a hash table for keeping track of include files
|
27
26
|
|
28
27
|
`
|
29
28
|
#(begin
|
30
|
-
(define lyp
|
31
|
-
(define lyp
|
32
|
-
(define lyp-
|
33
|
-
(define lyp-
|
34
|
-
(define lyp-package-refs (make-hash-table))`
|
29
|
+
(define lyp:input-filename "{{user_filename}}")
|
30
|
+
(define lyp:input-dirname "{{user_dirname}}")
|
31
|
+
(define lyp:current-package-dir "{{current_package_dir}}")
|
32
|
+
(define lyp:package-refs (make-hash-table))`
|
35
33
|
|
36
34
|
_[:package_paths].each do |spec, path|
|
37
35
|
`
|
38
|
-
(hash-set! lyp
|
36
|
+
(hash-set! lyp:package-refs "{{spec}}" "{{path}}")`
|
39
37
|
end
|
40
38
|
|
41
39
|
# package-loaded is hash table used for tracking loaded packages, so each
|
@@ -45,8 +43,8 @@ end
|
|
45
43
|
# package is loaded only once.
|
46
44
|
|
47
45
|
`
|
48
|
-
(define lyp
|
49
|
-
(define lyp
|
46
|
+
(define lyp:package-loaded (make-hash-table))
|
47
|
+
(define lyp:file-included (make-hash-table))
|
50
48
|
)
|
51
49
|
`
|
52
50
|
|
@@ -55,20 +53,20 @@ end
|
|
55
53
|
require = #(define-void-function (parser location package)(string?)
|
56
54
|
(let*
|
57
55
|
(
|
58
|
-
(path (hash-ref lyp
|
59
|
-
(loaded? (hash-ref lyp
|
56
|
+
(path (hash-ref lyp:package-refs package))
|
57
|
+
(loaded? (hash-ref lyp:package-loaded path))
|
60
58
|
(package-dir (dirname path))
|
61
|
-
(prev-package-dir lyp
|
59
|
+
(prev-package-dir lyp:current-package-dir)
|
62
60
|
)
|
63
61
|
(if (and path (not loaded?)) (begin
|
64
62
|
(if (not (file-exists? path)) (
|
65
63
|
(ly:error "Failed to load package ~a (file not found ~a)" package path)
|
66
64
|
))
|
67
65
|
(ly:debug "Loading package ~a at ~a" package package-dir)
|
68
|
-
(set! lyp
|
69
|
-
(hash-set! lyp
|
66
|
+
(set! lyp:current-package-dir package-dir)
|
67
|
+
(hash-set! lyp:package-loaded path #t)
|
70
68
|
#{ \include #path #}
|
71
|
-
(set! lyp
|
69
|
+
(set! lyp:current-package-dir prev-package-dir)
|
72
70
|
))
|
73
71
|
)
|
74
72
|
)
|
@@ -80,14 +78,29 @@ require = #(define-void-function (parser location package)(string?)
|
|
80
78
|
pinclude = #(define-void-function (parser location path)(string?)
|
81
79
|
(let*
|
82
80
|
(
|
83
|
-
(full-path (format "~a/~a" lyp
|
84
|
-
|
81
|
+
(full-path (format "~a/~a" lyp:current-package-dir path))
|
82
|
+
)
|
83
|
+
(begin
|
84
|
+
(if (not (file-exists? full-path)) (
|
85
|
+
(ly:error "File not found ~a" full-path)
|
86
|
+
))
|
87
|
+
(hash-set! lyp:file-included full-path #t)
|
88
|
+
#{ \include #full-path #}
|
89
|
+
)
|
90
|
+
)
|
91
|
+
)
|
92
|
+
|
93
|
+
pincludeOnce = #(define-void-function (parser location path)(string?)
|
94
|
+
(let*
|
95
|
+
(
|
96
|
+
(full-path (format "~a/~a" lyp:current-package-dir path))
|
97
|
+
(loaded? (hash-ref lyp:file-included full-path))
|
85
98
|
)
|
86
99
|
(if (and full-path (not loaded?)) (begin
|
87
100
|
(if (not (file-exists? full-path)) (
|
88
101
|
(ly:error "File not found ~a" full-path)
|
89
102
|
))
|
90
|
-
(hash-set! lyp
|
103
|
+
(hash-set! lyp:file-included full-path #t)
|
91
104
|
#{ \include #full-path #}
|
92
105
|
))
|
93
106
|
)
|
@@ -100,7 +113,7 @@ pinclude = #(define-void-function (parser location path)(string?)
|
|
100
113
|
#(define (pload path)
|
101
114
|
(let*
|
102
115
|
(
|
103
|
-
(full-path (format "~a/~a" lyp
|
116
|
+
(full-path (format "~a/~a" lyp:current-package-dir path))
|
104
117
|
)
|
105
118
|
(load full-path)
|
106
119
|
)
|
data/lib/lyp/version.rb
CHANGED