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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for okab-22.1a2-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b644286e4cb5fad44a9934a5d2d69ffc65ed200999b686f8a52f5eba2081c358 |
|
MD5 | 8c31076b605700c6226e0c4f9fe20672 |
|
BLAKE2b-256 | 84e4c070a55a92924ce9d35fb9872aa02f6b19500f239bb06826a655f5718c4d |
Hashes for okab-22.1a2-py3-none-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b1611ac9439c3e6caff60a120031e4710baeee4d1c65753a337af5596ee6b99 |
|
MD5 | 5cc8bc7776be9dbf2bbe423124b80817 |
|
BLAKE2b-256 | b0e4d953ce245eed1573219824a262e93f2ff5f8bc9fb9da424353f77ef23e61 |
Hashes for okab-22.1a2-py3-none-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6185fac9a6e66e4adc759c1dd6c5a8db03de90e66daa53e544440f4b0754e7ca |
|
MD5 | 75fadaa4d2b00058803831b92ba115b9 |
|
BLAKE2b-256 | 8455cab7dfa6e802fe33fce40e99c2ee35288d0fc0305282da197461d6813fc1 |