Skip to content

Commit

Permalink
Add COCKLE_WASM_EXTRA_CHANNEL env var to get wasm command packages fr…
Browse files Browse the repository at this point in the history
…om local directory (#79)
  • Loading branch information
ianthomas23 authored Dec 2, 2024
1 parent 7ff514e commit 67f0307
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
- Check and recreate cockle_wasm_env if it does not contain all required packages [#72](https://github.com/jupyterlite/cockle/pull/72) ([@ianthomas23](https://github.com/ianthomas23))
- Separate external and internal defs [#70](https://github.com/jupyterlite/cockle/pull/70) ([@ianthomas23](https://github.com/ianthomas23))
- Add tests for cp and mv [#68](https://github.com/jupyterlite/cockle/pull/68) ([@ianthomas23](https://github.com/ianthomas23))
- Support filename expansion of * and ? [#67](https://github.com/jupyterlite/cockle/pull/67) ([@ianthomas23](https://github.com/ianthomas23))
- Support filename expansion of \* and ? [#67](https://github.com/jupyterlite/cockle/pull/67) ([@ianthomas23](https://github.com/ianthomas23))
- Add Shell.dispose and new exit command [#66](https://github.com/jupyterlite/cockle/pull/66) ([@ianthomas23](https://github.com/ianthomas23))

### Bugs fixed
Expand Down
17 changes: 15 additions & 2 deletions src/tools/prepare_wasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const zod = require('zod');

const ENV_NAME = 'cockle_wasm_env';
const PLATFORM = 'emscripten-wasm32';
const REPOS = '-c https://repo.mamba.pm/emscripten-forge -c https://repo.mamba.pm/conda-forge';
const CHANNELS = ['https://repo.mamba.pm/emscripten-forge', 'https://repo.mamba.pm/conda-forge'];

if (process.argv.length !== 4 || (process.argv[2] !== '--list' && process.argv[2] !== '--copy')) {
console.log('Usage: prepare_wasm --list list-filename');
Expand All @@ -31,11 +31,24 @@ function isLocalPackage(packageConfig: object): boolean {
return Object.hasOwn(packageConfig, 'local_directory');
}

function getChannelsString(): string {
console.log('Using channels:');
CHANNELS.map(channel => console.log(` ${channel}`));
return CHANNELS.map(channel => `-c ${channel}`).join(' ');
}

function getWasmPackageInfo(micromambaCmd: string, envPath: string): any {
const cmd = `${micromambaCmd} -p ${envPath} list --json`;
return JSON.parse(execSync(cmd).toString());
}

// Handle environment variables.
const COCKLE_WASM_EXTRA_CHANNEL = process.env.COCKLE_WASM_EXTRA_CHANNEL;
if (COCKLE_WASM_EXTRA_CHANNEL !== undefined) {
// Prepend so used first.
CHANNELS.unshift(COCKLE_WASM_EXTRA_CHANNEL);
}

// Base cockle config file from this repo.
const baseConfigFilename = path.join(__dirname, '..', '..', 'cockle-config-base.json');
console.log('Using base config', baseConfigFilename);
Expand Down Expand Up @@ -114,7 +127,7 @@ if (fs.existsSync(envPath)) {
}

if (wasmPackageInfo === undefined) {
const suffix = `--platform=${PLATFORM} ${REPOS}`;
const suffix = `--platform=${PLATFORM} ${getChannelsString()}`;
console.log(`Creating new environment in ${envPath}`);
const createEnvCmd = `${micromambaCmd} create -p ${envPath} -y ${packageNames.join(' ')} ${suffix}`;
console.log(execSync(createEnvCmd).toString());
Expand Down

0 comments on commit 67f0307

Please sign in to comment.