Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add COCKLE_WASM_EXTRA_CHANNEL env var to get wasm command packages from an extra channel #79

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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