Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 171 additions & 0 deletions graphics/vega-lite/Portfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# -*- 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

PortSystem 1.0
PortGroup github 1.0

github.setup vega vega-lite 6.4.2 v
revision 0

categories graphics devel
license BSD
maintainers nomaintainer
platforms {darwin any}
supported_archs noarch

description Vega-Lite — a high-level grammar of interactive graphics

long_description Vega-Lite is a high-level grammar of interactive graphics. It \
provides a concise, declarative JSON syntax to create an expressive \
range of visualizations for data analysis and presentation. \
Vega-Lite specifications compile to full Vega specifications. \
This port installs the Vega-Lite library and the command-line \
utilities vl2vg, vl2svg, vl2png, and vl2pdf.

homepage https://vega.github.io/vega-lite/

github.tarball_from archive

checksums rmd160 76ee27132f7309886d8b687ec32e39ac501118e9 \
sha256 70ae0bc14e7cdc6a608e2790793f009fd809dbe639b83903ac322d162b1bfcd8 \
size 30967782

depends_build path:bin/npm:npm11 \
port:pkgconfig

depends_lib port:cairo \
port:pango \
port:libjpeg-turbo \
port:giflib \
port:librsvg

depends_run path:bin/node:nodejs22 \
port:vega

# The vega-lite npm package bundles the CLI tools (vl2vg, vl2svg, vl2png,
# vl2pdf) and requires vega as a peer dependency. We install both packages
# globally so that peer-dep resolution succeeds and the CLIs work.
# The GitHub tarball is used for livecheck & port version tracking.

use_configure no

# npm needs a writable HOME for caches
build.env-append HOME=${workpath}/.home

build {
file mkdir ${workpath}/.home
}

destroot {
# Install vega-lite (with vega as peer) globally into the destroot.
# vega is listed as a peer dependency; npm >=7 installs peers
# automatically, but we pin the version explicitly for reproducibility.
system -W ${worksrcpath} \
"HOME=${workpath}/.home \
${prefix}/bin/npm install -g vega-lite@${version} vega canvas \
--prefix=${destroot}${prefix} \
--cache=${workpath}/.npm-cache \
--unsafe-perm \
--no-audit --no-fund --no-update-notifier"

# Fix shebangs on the actual files, NOT the symlinks in bin/
foreach f [glob -nocomplain ${destroot}${prefix}/lib/node_modules/vega-lite/bin/vl2*] {
reinplace "s|#!/usr/bin/env node|#!${prefix}/bin/node|g" ${f}
}

# npm bakes the destroot path into internal metadata files; strip it safely
foreach f {
lib/node_modules/.package-lock.json
lib/node_modules/vega-lite/package.json
} {
if {[file exists ${destroot}${prefix}/${f}]} {
reinplace -q "s|${destroot}||g" ${destroot}${prefix}/${f}
}
}

# If vega was already installed by the vega port, npm may have placed a
# duplicate copy. The vega port owns the vg2* binaries and the
# node_modules/vega-cli tree, so remove any duplicates we created here
# to avoid file conflicts.
foreach f [glob -nocomplain ${destroot}${prefix}/bin/vg2*] {
file delete ${f}
}
}

# ---------------------------------------------------------------------------
# Post-Destroot Validation Tests
# ---------------------------------------------------------------------------
post-destroot {
ui_msg "Running functional smoke tests on staged vega-lite binaries..."

# 1. Smoke test — vl2vg --help should exit cleanly
system "${prefix}/bin/node ${destroot}${prefix}/bin/vl2vg --help"

# 2. Functional test — compile a minimal Vega-Lite spec to Vega JSON
set spec_file [file join ${workpath} test-spec.vl.json]
set vg_file [file join ${workpath} test-output.vg.json]
set fd [open ${spec_file} w]
puts $fd {
{
"$schema": "https://vega.github.io/schema/vega-lite/v6.json",
"description": "A simple bar chart with embedded data.",
"data": {
"values": [
{"a": "A", "b": 28},
{"a": "B", "b": 55},
{"a": "C", "b": 43}
]
},
"mark": "bar",
"encoding": {
"x": {"field": "a", "type": "nominal"},
"y": {"field": "b", "type": "quantitative"}
}
}
}
close $fd

system "${prefix}/bin/node ${destroot}${prefix}/bin/vl2vg ${spec_file} ${vg_file}"

if {![file exists ${vg_file}]} {
return -code error "vl2vg failed to produce output file"
}

# The compiled Vega spec must reference the Vega schema
set vg_content [exec cat ${vg_file}]
if {![string match "*vega*" $vg_content]} {
return -code error "vl2vg output does not look like a Vega spec"
}

# 3. Render the same spec to SVG via vl2svg
set svg_file [file join ${workpath} test-output.svg]
system "${prefix}/bin/node ${destroot}${prefix}/bin/vl2svg ${spec_file} ${svg_file}"

if {![file exists ${svg_file}]} {
return -code error "vl2svg failed to produce output SVG"
}

set svg_content [exec cat ${svg_file}]
if {![string match "*<svg*" $svg_content]} {
return -code error "vl2svg output does not appear to be valid SVG"
}

ui_msg "All vega-lite smoke tests passed successfully!"
}

# ---------------------------------------------------------------------------
# Post-install notes
# ---------------------------------------------------------------------------
notes "
The following Vega-Lite command-line utilities have been installed:

vl2vg — compile a Vega-Lite spec to a full Vega spec
vl2svg — compile and render a Vega-Lite spec to SVG
vl2png — compile and render to PNG
vl2pdf — compile and render to PDF

For documentation and examples, visit https://vega.github.io/vega-lite/
"

livecheck.type regex
livecheck.url https://registry.npmjs.org/vega-lite
livecheck.regex {"latest":"(\[^"]+)"}
8 changes: 5 additions & 3 deletions python/dot2tex/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PortGroup github 1.0
github.setup kjellmf dot2tex 2.11.3
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision 5
revision 6

categories graphics print python
supported_archs noarch
Expand All @@ -23,12 +23,14 @@ checksums rmd160 a7d4388511cd487e3aed41698d28211dacf3f2d2 \
sha256 299a2af05aee5bbe0257a562a506a93e279293d5c38f28d08ab8acb3233fe7ce \
size 660914

patchfiles patch-remove-scripts-entry.diff

# The python portgroup must be included into this port after the
# github.setup line so that the python portgroup's master_sites take effect.
PortGroup python 1.0

python.default_version 311
python.pep517 no
python.default_version 314
python.pep517 yes

depends_lib-append port:py${python.version}-parsing

Expand Down
28 changes: 28 additions & 0 deletions python/dot2tex/files/patch-remove-scripts-entry.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# setup.py installs the dot2tex binary via two mechanisms:
#
# 1. scripts=['dot2tex/dot2tex'] — copies the raw script file directly to
# bin/. That file uses a relative import (from .dot2tex import main)
# which fails with "attempted relative import with no known parent
# package" when the script is executed outside of its package context.
#
# 2. entry_points console_scripts — pip generates a proper wrapper that
# uses an absolute import (from dot2tex.dot2tex import main), which
# works correctly.
#
# With both present, pip (pep517) installs both to the same path, causing a
# duplicate-file error in MacPorts destroot (trac#65871). The previous
# workaround was python.pep517 no, but that lets the broken raw script win.
#
# The correct fix is to remove the redundant scripts entry and keep pep517
# enabled so that only the proper entry_points wrapper is installed.

--- setup.py
+++ setup.py
@@ -25,7 +25,6 @@
author_email='kjellmf@gmail.com',
url="https://github.com/kjellmf/dot2tex",
py_modules=['dot2tex.dot2tex', 'dot2tex.dotparsing'],
- scripts=['dot2tex/dot2tex'],
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Console',