gittup/tup

Unclear tup error: run-script line 2 is not a :-rule - '

Closed this issue · 4 comments

Hello, and thanks!

I'm having trouble in one case using run to generate rules, with tup v0.8-4-g748b7c7d.

This is a working, but repetitive Tupfile:

Tupfile
: foreach vars/*.nt |> ^t^ nt2json %f >%o |> tmp/vars/%B.json

: foreach vars/*.nt | tmp/vars/%B.json |> PYTHONPATH=./templates wheezy.template templates/kde.colors.wz tmp/vars/%B.json >%o |> schemes/kde/%B.colors                            ^__pycache__
: foreach vars/*.nt | tmp/vars/%B.json |> wheezy.template templates/colors.tdesktop-theme.wz tmp/vars/%B.json >%o             |> schemes/telegram/%B.tdesktop-theme               ^__pycache__
: foreach vars/*.nt | tmp/vars/%B.json |> wheezy.template templates/ayu-dark.sublime-theme.wz tmp/vars/%B.json >%o            |> schemes/sublime/ayu-dark-%B.sublime-theme        ^__pycache__
: foreach vars/*.nt | tmp/vars/%B.json |> wheezy.template templates/ayu-dark.sublime-color-scheme.wz tmp/vars/%B.json >%o     |> schemes/sublime/ayu-dark-%B.sublime-color-scheme ^__pycache__

: foreach vars/*.nt | tmp/vars/%B.json |> ^t^ wheezy.template templates/firefox.manifest.json.wz tmp/vars/%B.json >%o |> tmp/firefox/%B/manifest.json ^__pycache__
: foreach vars/*.nt | tmp/firefox/%B/manifest.json |> zip -j %o tmp/firefox/%B/manifest.json |> schemes/firefox/%B.xpi

: foreach vars/*.nt | tmp/vars/%B.json |> ^t^ PYTHONPATH=./templates wheezy.template templates/trit.json.wz tmp/vars/%B.json >%o |> tmp/vars/%BTrit.json ^__pycache__

: foreach vars/*.nt | tmp/vars/%BTrit.json |> PYTHONPATH=./templates wheezy.template templates/kde.colors.wz tmp/vars/%BTrit.json >%o |> schemes/kde/%BTrit.colors                            ^__pycache__
: foreach vars/*.nt | tmp/vars/%BTrit.json |> wheezy.template templates/colors.tdesktop-theme.wz tmp/vars/%BTrit.json >%o             |> schemes/telegram/%BTrit.tdesktop-theme               ^__pycache__
: foreach vars/*.nt | tmp/vars/%BTrit.json |> wheezy.template templates/ayu-dark.sublime-theme.wz tmp/vars/%BTrit.json >%o            |> schemes/sublime/ayu-dark-%BTrit.sublime-theme        ^__pycache__
: foreach vars/*.nt | tmp/vars/%BTrit.json |> wheezy.template templates/ayu-dark.sublime-color-scheme.wz tmp/vars/%BTrit.json >%o     |> schemes/sublime/ayu-dark-%BTrit.sublime-color-scheme ^__pycache__

: foreach vars/*.nt | tmp/vars/%BTrit.json |> ^t^ wheezy.template templates/firefox.manifest.json.wz tmp/vars/%BTrit.json >%o |> tmp/firefox/%BTrit/manifest.json ^__pycache__
: foreach vars/*.nt | tmp/firefox/%BTrit/manifest.json |> zip -j %o tmp/firefox/%BTrit/manifest.json |> schemes/firefox/%BTrit.xpi

: foreach vars/*.nt | tmp/vars/%B.json |> ^t^ PYTHONPATH=./templates wheezy.template templates/prot.json.wz tmp/vars/%B.json >%o |> tmp/vars/%BProt.json ^__pycache__

: foreach vars/*.nt | tmp/vars/%BProt.json |> PYTHONPATH=./templates wheezy.template templates/kde.colors.wz tmp/vars/%BProt.json >%o |> schemes/kde/%BProt.colors                            ^__pycache__
: foreach vars/*.nt | tmp/vars/%BProt.json |> wheezy.template templates/colors.tdesktop-theme.wz tmp/vars/%BProt.json >%o             |> schemes/telegram/%BProt.tdesktop-theme               ^__pycache__
: foreach vars/*.nt | tmp/vars/%BProt.json |> wheezy.template templates/ayu-dark.sublime-theme.wz tmp/vars/%BProt.json >%o            |> schemes/sublime/ayu-dark-%BProt.sublime-theme        ^__pycache__
: foreach vars/*.nt | tmp/vars/%BProt.json |> wheezy.template templates/ayu-dark.sublime-color-scheme.wz tmp/vars/%BProt.json >%o     |> schemes/sublime/ayu-dark-%BProt.sublime-color-scheme ^__pycache__

: foreach vars/*.nt | tmp/vars/%BProt.json |> ^t^ wheezy.template templates/firefox.manifest.json.wz tmp/vars/%BProt.json >%o |> tmp/firefox/%BProt/manifest.json ^__pycache__
: foreach vars/*.nt | tmp/firefox/%BProt/manifest.json |> zip -j %o tmp/firefox/%BProt/manifest.json |> schemes/firefox/%BProt.xpi

: foreach vars/*.nt | tmp/vars/%B.json |> ^t^ PYTHONPATH=./templates wheezy.template templates/deuter.json.wz tmp/vars/%B.json >%o |> tmp/vars/%BDeuter.json ^__pycache__

: foreach vars/*.nt | tmp/vars/%BDeuter.json |> PYTHONPATH=./templates wheezy.template templates/kde.colors.wz tmp/vars/%BDeuter.json >%o |> schemes/kde/%BDeuter.colors                            ^__pycache__
: foreach vars/*.nt | tmp/vars/%BDeuter.json |> wheezy.template templates/colors.tdesktop-theme.wz tmp/vars/%BDeuter.json >%o             |> schemes/telegram/%BDeuter.tdesktop-theme               ^__pycache__
: foreach vars/*.nt | tmp/vars/%BDeuter.json |> wheezy.template templates/ayu-dark.sublime-theme.wz tmp/vars/%BDeuter.json >%o            |> schemes/sublime/ayu-dark-%BDeuter.sublime-theme        ^__pycache__
: foreach vars/*.nt | tmp/vars/%BDeuter.json |> wheezy.template templates/ayu-dark.sublime-color-scheme.wz tmp/vars/%BDeuter.json >%o     |> schemes/sublime/ayu-dark-%BDeuter.sublime-color-scheme ^__pycache__

: foreach vars/*.nt | tmp/vars/%BDeuter.json |> ^t^ wheezy.template templates/firefox.manifest.json.wz tmp/vars/%BDeuter.json >%o |> tmp/firefox/%BDeuter/manifest.json ^__pycache__
: foreach vars/*.nt | tmp/firefox/%BDeuter/manifest.json |> zip -j %o tmp/firefox/%BDeuter/manifest.json |> schemes/firefox/%BDeuter.xpi

I want to use tup's run to generate most of these, using wheezy.template (from PyPI). So I replace the Tupfile content with:

run wheezy.template templates/tup.rules.wz

And create templates/tup.rules.wz:

wheezy template
: foreach vars/*.nt |> ^t^ nt2json %f >%o |> tmp/vars/%B.json

: foreach vars/*.nt | tmp/vars/%B.json |> PYTHONPATH=./templates wheezy.template templates/kde.colors.wz tmp/vars/%B.json >%o |> schemes/kde/%B.colors                            ^__pycache__
: foreach vars/*.nt | tmp/vars/%B.json |> wheezy.template templates/colors.tdesktop-theme.wz tmp/vars/%B.json >%o             |> schemes/telegram/%B.tdesktop-theme               ^__pycache__
: foreach vars/*.nt | tmp/vars/%B.json |> wheezy.template templates/ayu-dark.sublime-theme.wz tmp/vars/%B.json >%o            |> schemes/sublime/ayu-dark-%B.sublime-theme        ^__pycache__
: foreach vars/*.nt | tmp/vars/%B.json |> wheezy.template templates/ayu-dark.sublime-color-scheme.wz tmp/vars/%B.json >%o     |> schemes/sublime/ayu-dark-%B.sublime-color-scheme ^__pycache__

: foreach vars/*.nt | tmp/vars/%B.json |> ^t^ wheezy.template templates/firefox.manifest.json.wz tmp/vars/%B.json >%o |> tmp/firefox/%B/manifest.json ^__pycache__
: foreach vars/*.nt | tmp/firefox/%B/manifest.json |> zip -j %o tmp/firefox/%B/manifest.json |> schemes/firefox/%B.xpi

@for variant, suffix in (('trit', 'Trit'), ('prot', 'Prot'), ('deuter', 'Deuter')):
: foreach vars/*.nt | tmp/vars/%B.json |> ^t^ PYTHONPATH=./templates wheezy.template templates/@{variant}.json.wz tmp/vars/%B.json >%o |> tmp/vars/%B@{suffix}.json ^__pycache__

: foreach vars/*.nt | tmp/vars/%B@{suffix}.json |> PYTHONPATH=./templates wheezy.template templates/kde.colors.wz tmp/vars/%B@{suffix}.json >%o |> schemes/kde/%B@{suffix}.colors                            ^__pycache__
: foreach vars/*.nt | tmp/vars/%B@{suffix}.json |> wheezy.template templates/colors.tdesktop-theme.wz tmp/vars/%B@{suffix}.json >%o             |> schemes/telegram/%B@{suffix}.tdesktop-theme               ^__pycache__
: foreach vars/*.nt | tmp/vars/%B@{suffix}.json |> wheezy.template templates/ayu-dark.sublime-theme.wz tmp/vars/%B@{suffix}.json >%o            |> schemes/sublime/ayu-dark-%B@{suffix}.sublime-theme        ^__pycache__
: foreach vars/*.nt | tmp/vars/%B@{suffix}.json |> wheezy.template templates/ayu-dark.sublime-color-scheme.wz tmp/vars/%B@{suffix}.json >%o     |> schemes/sublime/ayu-dark-%B@{suffix}.sublime-color-scheme ^__pycache__

: foreach vars/*.nt | tmp/vars/%B@{suffix}.json |> ^t^ wheezy.template templates/firefox.manifest.json.wz tmp/vars/%B@{suffix}.json >%o |> tmp/firefox/%B@{suffix}/manifest.json ^__pycache__
: foreach vars/*.nt | tmp/firefox/%B@{suffix}/manifest.json |> zip -j %o tmp/firefox/%B@{suffix}/manifest.json |> schemes/firefox/%B@{suffix}.xpi

@end

If I manually run wheezy.template templates/tup.rules.wz, the stdout is identical to the original Tupfile.

But when I run tup --debug-run, I get:

tup --debug-run output
[ tup ] [0.000s] Scanning filesystem...
[ tup ] [0.002s] Reading in new environment variables...
[ tup ] [0.002s] Parsing Tupfiles...
* 100% 0) [0.031s] .
 --- run script output from 'wheezy.template templates/tup.rules.wz'
: foreach vars/*.nt |> ^t^ nt2json %f >%o |> tmp/vars/%B.json
tup error: run-script line 2 is not a :-rule - '
: foreach vars/*.nt | tmp/vars/%B.json |> PYTHONPATH=./templates wheezy.template templates/kde.colors.wz tmp/vars/%B.json >%o |> schemes/kde/%B.colors                            ^__pycache__
: foreach vars/*.nt | tmp/vars/%B.json |> wheezy.template templates/colors.tdesktop-theme.wz tmp/vars/%B.json >%o             |> schemes/telegram/%B.tdesktop-theme               ^__pycache__
: foreach vars/*.nt | tmp/vars/%B.json |> wheezy.template templates/ayu-dark.sublime-theme.wz tmp/vars/%B.json >%o            |> schemes/sublime/ayu-dark-%B.sublime-theme        ^__pycache__
: foreach vars/*.nt | tmp/vars/%B.json |> wheezy.template templates/ayu-dark.sublime-color-scheme.wz tmp/vars/%B.json >%o     |> schemes/sublime/ayu-dark-%B.sublime-color-scheme ^__pycache__

: foreach vars/*.nt | tmp/vars/%B.json |> ^t^ wheezy.template templates/firefox.manifest.json.wz tmp/vars/%B.json >%o |> tmp/firefox/%B/manifest.json ^__pycache__
: foreach vars/*.nt | tmp/firefox/%B/manifest.json |> zip -j %o tmp/firefox/%B/manifest.json |> schemes/firefox/%B.xpi

: foreach vars/*.nt | tmp/vars/%B.json |> ^t^ PYTHONPATH=./templates wheezy.template templates/trit.json.wz tmp/vars/%B.json >%o |> tmp/vars/%BTrit.json ^__pycache__

: foreach vars/*.nt | tmp/vars/%BTrit.json |> PYTHONPATH=./templates wheezy.template templates/kde.colors.wz tmp/vars/%BTrit.json >%o |> schemes/kde/%BTrit.colors                            ^__pycache__
: foreach vars/*.nt | tmp/vars/%BTrit.json |> wheezy.template templates/colors.tdesktop-theme.wz tmp/vars/%BTrit.json >%o             |> schemes/telegram/%BTrit.tdesktop-theme               ^__pycache__
: foreach vars/*.nt | tmp/vars/%BTrit.json |> wheezy.template templates/ayu-dark.sublime-theme.wz tmp/vars/%BTrit.json >%o            |> schemes/sublime/ayu-dark-%BTrit.sublime-theme        ^__pycache__
: foreach vars/*.nt | tmp/vars/%BTrit.json |> wheezy.template templates/ayu-dark.sublime-color-scheme.wz tmp/vars/%BTrit.json >%o     |> schemes/sublime/ayu-dark-%BTrit.sublime-color-scheme ^__pycache__

: foreach vars/*.nt | tmp/vars/%BTrit.json |> ^t^ wheezy.template templates/firefox.manifest.json.wz tmp/vars/%BTrit.json >%o |> tmp/firefox/%BTrit/manifest.json ^__pycache__
: foreach vars/*.nt | tmp/firefox/%BTrit/manifest.json |> zip -j %o tmp/firefox/%BTrit/manifest.json |> schemes/firefox/%BTrit.xpi

: foreach vars/*.nt | tmp/vars/%B.json |> ^t^ PYTHONPATH=./templates wheezy.template templates/prot.json.wz tmp/vars/%B.json >%o |> tmp/vars/%BProt.json ^__pycache__

: foreach vars/*.nt | tmp/vars/%BProt.json |> PYTHONPATH=./templates wheezy.template templates/kde.colors.wz tmp/vars/%BProt.json >%o |> schemes/kde/%BProt.colors                            ^__pycache__
: foreach vars/*.nt | tmp/vars/%BProt.json |> wheezy.template templates/colors.tdesktop-theme.wz tmp/vars/%BProt.json >%o             |> schemes/telegram/%BProt.tdesktop-theme               ^__pycache__
: foreach vars/*.nt | tmp/vars/%BProt.json |> wheezy.template templates/ayu-dark.sublime-theme.wz tmp/vars/%BProt.json >%o            |> schemes/sublime/ayu-dark-%BProt.sublime-theme        ^__pycache__
: foreach vars/*.nt | tmp/vars/%BProt.json |> wheezy.template templates/ayu-dark.sublime-color-scheme.wz tmp/vars/%BProt.json >%o     |> schemes/sublime/ayu-dark-%BProt.sublime-color-scheme ^__pycache__

: foreach vars/*.nt | tmp/vars/%BProt.json |> ^t^ wheezy.template templates/firefox.manifest.json.wz tmp/vars/%BProt.json >%o |> tmp/firefox/%BProt/manifest.json ^__pycache__
: foreach vars/*.nt | tmp/firefox/%BProt/manifest.json |> zip -j %o tmp/firefox/%BProt/manifest.json |> schemes/firefox/%BProt.xpi

: foreach vars/*.nt | tmp/vars/%B.json |> ^t^ PYTHONPATH=./templates wheezy.template templates/deuter.json.wz tmp/vars/%B.json >%o |> tmp/vars/%BDeuter.json ^__pycache__

: foreach vars/*.nt | tmp/vars/%BDeuter.json |> PYTHONPATH=./templates wheezy.template templates/kde.colors.wz tmp/vars/%BDeuter.json >%o |> schemes/kde/%BDeuter.colors                            ^__pycache__
: foreach vars/*.nt | tmp/vars/%BDeuter.json |> wheezy.template templates/colors.tdesktop-theme.wz tmp/vars/%BDeuter.json >%o             |> schemes/telegram/%BDeuter.tdesktop-theme               ^__pycache__
: foreach vars/*.nt | tmp/vars/%BDeuter.json |> wheezy.template templates/ayu-dark.sublime-theme.wz tmp/vars/%BDeuter.json >%o            |> schemes/sublime/ayu-dark-%BDeuter.sublime-theme        ^__pycache__
: foreach vars/*.nt | tmp/vars/%BDeuter.json |> wheezy.template templates/ayu-dark.sublime-color-scheme.wz tmp/vars/%BDeuter.json >%o     |> schemes/sublime/ayu-dark-%BDeuter.sublime-color-scheme ^__pycache__

: foreach vars/*.nt | tmp/vars/%BDeuter.json |> ^t^ wheezy.template templates/firefox.manifest.json.wz tmp/vars/%BDeuter.json >%o |> tmp/firefox/%BDeuter/manifest.json ^__pycache__
: foreach vars/*.nt | tmp/firefox/%BDeuter/manifest.json |> zip -j %o tmp/firefox/%BDeuter/manifest.json |> schemes/firefox/%BDeuter.xpi

'
tup error: Error parsing Tupfile line 1
  Line was: 'run wheezy.template templates/tup.rules.wz'
 *** tup: 1 job failed.

IIRC run scripts expect every line to be an : rule and does not accept blank lines or comments, unlike the syntax recognized in Tupfiles. I remember having to take measures to get around a similar error, anyway, by skipping blank lines.

@earthlyreason Thanks so much! That's it, all good now.

I would prefer to be able to include blank lines, and to a lesser extent comments, but I can put comments in the template file so that's not too bad.

I pushed 4247a52 to skip blank lines (completely blank, as in just a newline), as well as lines starting with #

Have you tried the built-in lua support for rules at all? I'm curious how that compares to this template style in your experience.

Thanks!

Sorry, I haven't tried using lua for rules, as I don't enjoy writing lua and am quite bad at it. I use wheezy.template a lot for various small projects and am happy with it.