|
| 1 | +# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 |
| 2 | + |
| 3 | +PortSystem 1.0 |
| 4 | +PortGroup npm 1.0 |
| 5 | + |
| 6 | +name vega-lite |
| 7 | +version 6.4.2 |
| 8 | +revision 0 |
| 9 | + |
| 10 | +categories graphics devel |
| 11 | +license BSD |
| 12 | +maintainers nomaintainer |
| 13 | + |
| 14 | +description Vega-Lite — a high-level grammar of interactive graphics |
| 15 | + |
| 16 | +long_description Vega-Lite is a high-level grammar of interactive graphics. It \ |
| 17 | + provides a concise, declarative JSON syntax to create an expressive \ |
| 18 | + range of visualizations for data analysis and presentation. \ |
| 19 | + Vega-Lite specifications compile to full Vega specifications. \ |
| 20 | + This port installs the Vega-Lite library and the command-line \ |
| 21 | + utilities vl2vg, vl2svg, vl2png, and vl2pdf. |
| 22 | + |
| 23 | +homepage https://vega.github.io/vega-lite/ |
| 24 | + |
| 25 | +checksums rmd160 5f646631c7b2c108e7034a832383556d84983beb \ |
| 26 | + sha256 158643e963d9a4b81cb971846056fcd629798fae8bc27012b13cddb1f5c03c0f \ |
| 27 | + size 1077598 |
| 28 | + |
| 29 | +depends_build-append \ |
| 30 | + path:bin/pkg-config:pkgconfig |
| 31 | + |
| 32 | +depends_lib-append path:lib/pkgconfig/cairo.pc:cairo \ |
| 33 | + path:lib/pkgconfig/pango.pc:pango \ |
| 34 | + path:include/turbojpeg.h:libjpeg-turbo \ |
| 35 | + port:giflib \ |
| 36 | + path:lib/pkgconfig/librsvg-2.0.pc:librsvg \ |
| 37 | + port:vega |
| 38 | + |
| 39 | +platform darwin { |
| 40 | + if {${os.major} >= 22} { |
| 41 | + npm.nodejs_version 24 |
| 42 | + npm.version 11 |
| 43 | + } |
| 44 | +} |
| 45 | + |
| 46 | +destroot { |
| 47 | + file mkdir ${workpath}/.home |
| 48 | + # Install vega-lite from the distfile tarball, with vega and canvas |
| 49 | + # fetched from the npm registry to satisfy peer dependencies. |
| 50 | + system -W ${workpath} \ |
| 51 | + "HOME=${workpath}/.home \ |
| 52 | + ${prefix}/bin/npm install -ddd --global \ |
| 53 | + --prefix=${destroot}${prefix} \ |
| 54 | + --cache=${workpath}/.npm-cache \ |
| 55 | + ${distpath}/${distfiles} vega canvas" |
| 56 | + |
| 57 | + # Fix shebangs: npm writes #!/usr/bin/env node — replace with |
| 58 | + # the MacPorts-provided node binary |
| 59 | + foreach f [glob -nocomplain ${destroot}${prefix}/lib/node_modules/vega-lite/bin/vl2*] { |
| 60 | + reinplace "s|#!/usr/bin/env node|#!${prefix}/bin/node|g" ${f} |
| 61 | + } |
| 62 | + |
| 63 | + # npm bakes the destroot path into internal metadata files; strip it |
| 64 | + foreach f { |
| 65 | + lib/node_modules/.package-lock.json |
| 66 | + lib/node_modules/vega-lite/package.json |
| 67 | + } { |
| 68 | + if {[file exists ${destroot}${prefix}/${f}]} { |
| 69 | + reinplace -q "s|${destroot}||g" ${destroot}${prefix}/${f} |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + # The vega port owns the vg2* binaries; remove any duplicates to |
| 74 | + # avoid file conflicts at activation time |
| 75 | + foreach f [glob -nocomplain ${destroot}${prefix}/bin/vg2*] { |
| 76 | + file delete ${f} |
| 77 | + } |
| 78 | +} |
| 79 | + |
| 80 | +test.run yes |
| 81 | +test { |
| 82 | + # 1. Smoke test — vl2vg --help should exit cleanly |
| 83 | + system "${prefix}/bin/vl2vg --help" |
| 84 | + |
| 85 | + # 2. Functional test — compile a minimal Vega-Lite spec to Vega JSON |
| 86 | + set spec_file [file join ${workpath} test-spec.vl.json] |
| 87 | + set vg_file [file join ${workpath} test-output.vg.json] |
| 88 | + set fd [open ${spec_file} w] |
| 89 | + puts $fd { |
| 90 | + { |
| 91 | + "$schema": "https://vega.github.io/schema/vega-lite/v6.json", |
| 92 | + "description": "A simple bar chart with embedded data.", |
| 93 | + "data": { |
| 94 | + "values": [ |
| 95 | + {"a": "A", "b": 28}, |
| 96 | + {"a": "B", "b": 55}, |
| 97 | + {"a": "C", "b": 43} |
| 98 | + ] |
| 99 | + }, |
| 100 | + "mark": "bar", |
| 101 | + "encoding": { |
| 102 | + "x": {"field": "a", "type": "nominal"}, |
| 103 | + "y": {"field": "b", "type": "quantitative"} |
| 104 | + } |
| 105 | + } |
| 106 | + } |
| 107 | + close $fd |
| 108 | + |
| 109 | + system "${prefix}/bin/vl2vg ${spec_file} ${vg_file}" |
| 110 | + |
| 111 | + if {![file exists ${vg_file}]} { |
| 112 | + return -code error "vl2vg failed to produce output file" |
| 113 | + } |
| 114 | + |
| 115 | + set vg_content [exec cat ${vg_file}] |
| 116 | + if {![string match "*vega*" $vg_content]} { |
| 117 | + return -code error "vl2vg output does not look like a Vega spec" |
| 118 | + } |
| 119 | + |
| 120 | + # 3. Render the same spec to SVG via vl2svg |
| 121 | + set svg_file [file join ${workpath} test-output.svg] |
| 122 | + system "${prefix}/bin/vl2svg ${spec_file} ${svg_file}" |
| 123 | + |
| 124 | + if {![file exists ${svg_file}]} { |
| 125 | + return -code error "vl2svg failed to produce output SVG" |
| 126 | + } |
| 127 | + |
| 128 | + set svg_content [exec cat ${svg_file}] |
| 129 | + if {![string match "*<svg*" $svg_content]} { |
| 130 | + return -code error "vl2svg output does not appear to be valid SVG" |
| 131 | + } |
| 132 | +} |
| 133 | + |
| 134 | +notes " |
| 135 | +The following Vega-Lite command-line utilities have been installed: |
| 136 | +
|
| 137 | + vl2vg — compile a Vega-Lite spec to a full Vega spec |
| 138 | + vl2svg — compile and render a Vega-Lite spec to SVG |
| 139 | + vl2png — compile and render to PNG |
| 140 | + vl2pdf — compile and render to PDF |
| 141 | +
|
| 142 | +For documentation and examples, visit https://vega.github.io/vega-lite/ |
| 143 | +" |
0 commit comments