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
157 changes: 157 additions & 0 deletions graphics/vega/Portfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# -*- 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 6.2.0 v
revision 0

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

description Vega visualization grammar — declarative interactive visualizations

long_description Vega is a visualization grammar, a declarative language for \
creating, saving, and sharing interactive visualization designs. \
With Vega, you can describe the visual appearance and interactive \
behavior of a visualization in a JSON format, and generate \
web-based views using Canvas or SVG. This port installs the Vega \
command-line utilities (vg2png, vg2svg, vg2pdf) and the Vega \
JavaScript library.

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

github.tarball_from archive

checksums rmd160 b878b819fa6fdde984ecf7b0904cec638f87b8f8 \
sha256 4e5497039d7b6630d2efaea0a992946f18333965c59fbc5a3b0f9e7a2578ec6a \
size 15835280

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

# Vega is a monorepo; we install vega-cli (which depends on vega) globally
# from the npm registry so that all transitive dependencies are resolved.
# 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-cli (which pulls in vega) globally into the destroot
system -W ${worksrcpath} \
"HOME=${workpath}/.home \
${prefix}/bin/npm install -g vega-cli@${version} \
--prefix=${destroot}${prefix} \
--cache=${workpath}/.npm-cache \
--unsafe-perm \
--no-audit --no-fund --no-update-notifier"

# Fix shebangs: npm writes #!/usr/bin/env node — replace with
# the MacPorts-provided node binary
# Fix shebangs on the actual files, NOT the symlinks in bin/
foreach f [glob -nocomplain ${destroot}${prefix}/lib/node_modules/vega-cli/bin/vg2*] {
reinplace "s|#!/usr/bin/env node|#!${prefix}/bin/node|g" ${f}
}

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

# Rudimentary post-destroot test: ensure the staged CLI tools run and produce output
post-destroot {
ui_msg "Running functional smoke tests on staged binaries..."

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

# 2. Version check — the installed version must match the port
set vg2svg_out [exec ${prefix}/bin/node \
${destroot}${prefix}/lib/node_modules/vega-cli/bin/vg2svg --version]
if {![string match "*${version}*" $vg2svg_out]} {
return -code error "version mismatch: expected ${version}, got ${vg2svg_out}"
}

# 3. Functional test — render a minimal Vega spec to SVG
set spec_file [file join ${workpath} test-spec.vg.json]
set svg_file [file join ${workpath} test-output.svg]
set fd [open ${spec_file} w]
puts $fd {
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"width": 200,
"height": 200,
"marks": [
{
"type": "rect",
"encode": {
"enter": {
"x": {"value": 0},
"y": {"value": 0},
"width": {"value": 100},
"height": {"value": 100},
"fill": {"value": "steelblue"}
}
}
}
]
}
}
close $fd

# Explicitly invoke with node to guarantee execution in the sandbox
system "${prefix}/bin/node ${destroot}${prefix}/bin/vg2svg ${spec_file} ${svg_file}"

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

# Sanity-check that the output looks like SVG
set svg_content [exec cat ${svg_file}]
if {![string match "*<svg*" $svg_content]} {
return -code error "vg2svg output does not appear to be valid SVG"
}

ui_msg "All vega smoke tests passed successfully!"
}

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

vg2svg — render a Vega spec to SVG
vg2png — render a Vega spec to PNG
vg2pdf — render a Vega spec to PDF

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

livecheck.type regex
livecheck.url https://registry.npmjs.org/vega-cli
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',