Trying to get my head round where we are with all this...
There are several things going on:
in the webr kernel, packages are installed dynamically from a web path / package repo; this path is configurable via options()
to webr kernel package has settings for core webr files it needs to dynamically load from a web repo; in the jupyterlite kernel, we can configure this path;
To distribute arbitrary packages, we need to:
build/compile them for wasm use;
put them on at a custom known repo location.;
dynamically point to them via options()
To distribute the webr wasm core package, we need to:
get a copy of the current distribution files (or build our own);
put them at a know custom location;
bake the known location into Jupyterlite kernel settings at custom jupyterlite kernel build time;
For a self-contained distribution:
served from a website (eg GIthub pages) we can bundle the package repo and the webr repo into the same pages site at the jupyterlite environment and set paths appropriately (can we set relative paths?)
served from a bundle - all files need to be bundled; ideally, we'd set paths locally? Or we need to determine a port that eg a local server is guaranteed to serve the distribution on (eg http://127..0.0.1:8348)
https://github.com/ouseful-testing/webr-package-repo-demo/ uses actions to custom build R wasm packages: this works and provides packages as required in a repository on a github pages site; the build action produces an artifact zip which contains the packages, if required; this action could be used with other actions in creating a self-contained site; in this repo, i am using packages_wasmbuilt as the built package src dir; the compiled packages then get copied into ./dist/repo in the Pages build; that means we can then do install.packages("M348", repos = "https://ouseful-demos.github.io/jupyterlite-m348-demo/repo/") or more conveniently just set options("webr_pkg_repos"="https://ouseful-demos.github.io/jupyterlite-m348-demo/repo/") and then library(M348)
https://github.com/ouseful-testing/jupyterlite-webr-kernel/ builds a custom jupyterllite kernel that has custom settings for where the webr wasm package lives. To form a distribution, we then need to copy the appropriate files from the original webr wasm directory (current path: https://webr.r-wasm.org/v0.3.0/R.bin.wasmetc ; zipped as https://github.com/r-wasm/webr/releases/download/v0.3.0/webr-0.3.0.zip ; BUT i note not all files on the correct path [share.data,share.js.metadata,DESCRIPTION]; ) [note 1]; currently, in this repo, these duplicated files are in [./webr-dist](https://github.com/ouseful-demos/jupyterlite-m348-demo/tree/main/webr-dist) and get copied to./dist/webr/` in the Github pages site; Note here — https://github.com/r-wasm/jupyterlite-webr-kernel/issues/8 — on jupyterlite zip settings and other config options.
trying to build a cross-platform, standalone distributable with pyinstaller — actions etc here: https://github.com/ouseful-testing/m348-jupyterlite-distro The build process seems to work ok for windows, no idea about linux, macs is crapped on when you try to use it by security settings (is there an easy way for the user to expliclty trust the package?)
For a standalone version, we would need to make sure paths are set appropriately, and everything bundled, or have the package repo and the webr distribution repo on a path on the same domain.
Trying to get my head round where we are with all this...
There are several things going on:
options()
To distribute arbitrary packages, we need to:
options()
To distribute the webr wasm core package, we need to:
For a self-contained distribution:
served from a website (eg GIthub pages) we can bundle the package repo and the webr repo into the same pages site at the jupyterlite environment and set paths appropriately (can we set relative paths?)
served from a bundle - all files need to be bundled; ideally, we'd set paths locally? Or we need to determine a port that eg a local server is guaranteed to serve the distribution on (eg
http://127..0.0.1:8348
)https://github.com/ouseful-testing/webr-package-repo-demo/ uses actions to custom build R wasm packages: this works and provides packages as required in a repository on a github pages site; the build action produces an artifact zip which contains the packages, if required; this action could be used with other actions in creating a self-contained site; in this repo, i am using
packages_wasmbuilt
as the built package src dir; the compiled packages then get copied into./dist/repo
in the Pages build; that means we can then doinstall.packages("M348", repos = "https://ouseful-demos.github.io/jupyterlite-m348-demo/repo/")
or more conveniently just setoptions("webr_pkg_repos"="https://ouseful-demos.github.io/jupyterlite-m348-demo/repo/")
and thenlibrary(M348)
https://github.com/ouseful-testing/jupyterlite-webr-kernel/ builds a custom jupyterllite kernel that has custom settings for where the webr wasm package lives. To form a distribution, we then need to copy the appropriate files from the original webr wasm directory (current path: https://webr.r-wasm.org/v0.3.0/R.bin.wasm
etc ; zipped as https://github.com/r-wasm/webr/releases/download/v0.3.0/webr-0.3.0.zip ; BUT i note not all files on the correct path [
share.data,
share.js.metadata,
DESCRIPTION]; ) [note 1]; currently, in this repo, these duplicated files are in [
./webr-dist](https://github.com/ouseful-demos/jupyterlite-m348-demo/tree/main/webr-dist) and get copied to
./dist/webr/` in the Github pages site; Note here — https://github.com/r-wasm/jupyterlite-webr-kernel/issues/8 — on jupyterlite zip settings and other config options.trying to build a cross-platform, standalone distributable with pyinstaller — actions etc here: https://github.com/ouseful-testing/m348-jupyterlite-distro The build process seems to work ok for windows, no idea about linux, macs is crapped on when you try to use it by security settings (is there an easy way for the user to expliclty trust the package?)
For a standalone version, we would need to make sure paths are set appropriately, and everything bundled, or have the package repo and the webr distribution repo on a path on the same domain.
NOTE 1: if we wanted to build a custom webr distribtion, with custom paths baked in rather than set by parameters, see: https://github.com/r-wasm/webr/compare/main...ouseful-testing:webr:main Note that the build action is broken for legacy r kernel v3 builds but is okay for 4.