Skip to main content

altair + okab = static beauty

Project description

Okab

altair + okab = static beauty

How does it work?

We leverage vercel/pkg and distribute self-contained platform-specific executables within the python wheels. This takes the problems of installing and setting up the needed backends from the user and leaves it to a well crafted CI.

First we need access to the libraries that render our visualizations vega & vega-lite. We can use the vega API to generate a view and easily convert this to svg.

Generating appropriate png is a different problem. The vega view API can return an svg or canvas object. In the browser this uses HTML canvas, server-side they rely on node-canvas. This works fine in a properly configured node environment, but canvas has a number of system dependencies and caveats that make packaging it with vercel/pkg a problem.

Instead, we can take advantage of a different svg rendering library RazrFalcon/resvg and yisibl/resvg-js.

Building from Source

For now the wheels will need to be built manually and the executable copied into the appropriate package directory. This would ultimately be handled at build time by setuptools.

Building vega-resvg

To get started you'll need npm and python.

cd js
npm install
npm i -g vercel/pkg

In order to cross-compile the executable's you'll need to have available the necessary resvg-js node add-ons, you can use ./js/get-binaries.sh to fetch them all. The necessary binary for your own architecture should be pickup by the initial npm install.

To build the executable run the following specifying your target, see vercel/pkg for info about supported targets. Then copy this binary to okab/vega/vega-resvg.

pkg index.js --no-bytecode --public-packages "*" --public -C GZip --target linux -o vega-resvg
cp vega-resvg ../okab/vega/vega-resvg

Finally, build the wheel:

python setup.py bdist_wheel

You can then install this wheel and test it using the included examples:

pip install dist/*.whl
cd examples
python make-examples.py

To cross-compile wheels for windows, mac(x64) and linux:

cd js
./get-binaries.sh
cd ..
make wheels

Results

svg png png (scale factor 2)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

okab-22.1a1-py3-none-win_amd64.whl (30.2 MB view hashes)

Uploaded Python 3 Windows x86-64

okab-22.1a1-py3-none-manylinux_2_17_x86_64.whl (33.6 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ x86-64

okab-22.1a1-py3-none-macosx_10_14_x86_64.whl (33.7 MB view hashes)

Uploaded Python 3 macOS 10.14+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page