Skip to content

Commit

Permalink
Add pyodide virtual package
Browse files Browse the repository at this point in the history
In setup, this package selects `perspective-python` and sets some
environment variables to make the build run for Pyodide.

Co-authored-by: Andrew Stein <steinlink@gmail.com>
Signed-off-by: Tom Jakubowski <tom@prospective.dev>
  • Loading branch information
tomjakubowski and texodus committed Sep 10, 2024
1 parent 6078daf commit 72212ce
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tools/perspective-scripts/setup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ const CONFIG = new Proxy(
).replace(/\|/g, ",");
}
}
remove(keyname) {
const idx = this.config.find((x) => s.startsWith(keyname));
if (idx >= 0) {
this.config.splice(idx);
}
}
add(new_config) {
for (const key in new_config) {
const val = new_config[key];
Expand Down Expand Up @@ -120,6 +126,11 @@ async function focus_package() {
name: "perspective-python",
value: "perspective-python",
},
{
key: "q",
name: "perspective-pyodide (Python)",
value: "perspective-pyodide",
},
{
key: "r",
name: "perspective-rs",
Expand Down Expand Up @@ -166,6 +177,17 @@ async function focus_package() {

if (Array.isArray(new_config.PACKAGE)) {
if (new_config.PACKAGE.length > 0) {
let pyodide = new_config.PACKAGE.indexOf("perspective-pyodide");
if (pyodide >= 0) {
new_config.PACKAGE.splice(pyodide, 1);
new_config.PSP_PYODIDE = 1;
new_config.CI = 1;
new_config.PACKAGE.push("perspective-python");
} else {
CONFIG.remove("PSP_PYODIDE");
CONFIG.remove("CI");
}

new_config.PACKAGE = `${new_config.PACKAGE.join(",")}`;
} else {
new_config.PACKAGE = undefined;
Expand Down

0 comments on commit 72212ce

Please sign in to comment.