gristlabs_grist-core/sandbox/pyodide/build_packages.sh
Paul Fitzpatrick 66643a5e6b
add a pyodide-based "sandbox" flavor (#437)
This adds a new `GRIST_SANDBOX_FLAVOR=pyodide` option where the
version of Python used for the data engine is wasm, and so can
be run by node like the rest of the back end. It still runs as
a separate process.

There are a few small version changes made to packages to avoid
various awkwardnesses present in the current versions. All existing
tests pass.

This is very experimental. To use, you'll need something with
a bash shell and make. First do:
```
cd sandbox/pyodide
make setup           # README.md and Makefile have details
cd ..
```

Then running Grist as:
```
GRIST_SANDBOX_FLAVOR=pyodide yarn start
```
should work. Adding a formula with content:
```
import sys; return sys.version
```
should return a different Python version than other sandboxes.

The motivation for this work is to have a form of sandboxing
that will work on Windows for Grist Electron (for Linux we have
gvisor/runsc, for Mac we have sandbox-exec, but I haven't found
anything comparable for Windows).

It also brings a back-end-free version of Grist a bit closer, for
use-cases where that would make sense - such as serving a report
(in the form of a Grist document) on a static site.
2023-03-06 16:56:25 -05:00

31 lines
729 B
Bash

#!/bin/bash
set -e
echo ""
echo "###############################################################"
echo "## Get pyodide repository, for transpiling python packages"
if [[ ! -e _build/pyodide ]]; then
cd _build
git clone https://github.com/pyodide/pyodide
cd ..
fi
echo ""
echo "###############################################################"
echo "## Prepare python packages"
cd _build/pyodide
./run_docker make
cp ../../../requirements3.txt .
./run_docker pyodide build -r requirements3.txt --output-lockfile result.txt
cat result.txt
cd ../..
echo ""
echo "###############################################################"
echo "## Copy out python packages"
node ./packages.js _build/pyodide/dist/ _build/packages/