Skip to content

Commit 8bceffa

Browse files
committed
test
1 parent 9b87bda commit 8bceffa

File tree

5 files changed

+26
-31
lines changed

5 files changed

+26
-31
lines changed

packages/pyodide-kernel-extension/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const kernel: JupyterLiteServerPlugin<void> = {
5959
const disablePyPIFallback = !!config.disablePyPIFallback;
6060
const loadPyodideOptions = config.loadPyodideOptions || {};
6161
const extraPackagesAndIndexes = config.extraPackagesAndIndexes || [];
62+
console.log('extraPackagesAndIndexes', extraPackagesAndIndexes, config);
6263

6364
for (const [key, value] of Object.entries(loadPyodideOptions)) {
6465
if (key.endsWith('URL') && typeof value === 'string') {

packages/pyodide-kernel/src/_pypi.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
export * as allJSONUrl from '../pypi/all.json';
33
export * as ipykernelWheelUrl from '../pypi/ipykernel-6.9.2-py3-none-any.whl';
44
export * as pipliteWheelUrl from '../pypi/piplite-0.5.0-py3-none-any.whl';
5+
export * as pipliteWheelUrl1 from '../pypi/piplite-0.5.0b0-py3-none-any.whl';
56
export * as pyodide_kernelWheelUrl from '../pypi/pyodide_kernel-0.5.0-py3-none-any.whl';
7+
export * as pyodide_kernelWheelUrl1 from '../pypi/pyodide_kernel-0.5.0b0-py3-none-any.whl';
68
export * as widgetsnbextensionWheelUrl from '../pypi/widgetsnbextension-3.6.999-py3-none-any.whl';
79
export * as widgetsnbextensionWheelUrl1 from '../pypi/widgetsnbextension-4.0.999-py3-none-any.whl';

packages/pyodide-kernel/src/kernel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,6 @@ export namespace PyodideKernel {
395395
* The Jupyterlite content manager
396396
*/
397397
contentsManager: Contents.IManager;
398-
extraPackagesAndIndexes: Array<{ package: string; indexes: string[] | null }>;
398+
extraPackagesAndIndexes: Array<{ packages: string[]; indexes: string[] | null }>;
399399
}
400400
}

packages/pyodide-kernel/src/tokens.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export namespace IPyodideWorkerKernel {
9393
/**
9494
* List of extra url/wheel paths to load, and extra associated indexes urls (if not a wheel url)
9595
*/
96-
extraPackagesAndIndexes: Array<{ package: string; indexes: string[] | null }>;
96+
extraPackagesAndIndexes: Array<{ packages: string[]; indexes: string[] | null }>;
9797

9898
/**
9999
* additional options to provide to `loadPyodide`

packages/pyodide-kernel/src/worker.ts

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,8 @@ export class PyodideRemoteKernel {
6565
throw new Error('Uninitialized');
6666
}
6767

68-
const {
69-
pipliteWheelUrl,
70-
disablePyPIFallback,
71-
pipliteUrls,
72-
loadPyodideOptions,
73-
extraPackagesAndIndexes,
74-
} = this._options;
68+
const { pipliteWheelUrl, disablePyPIFallback, pipliteUrls, loadPyodideOptions } =
69+
this._options;
7570

7671
const preloaded = (loadPyodideOptions || {}).packages || [];
7772

@@ -85,28 +80,6 @@ export class PyodideRemoteKernel {
8580
await micropip.install('${pipliteWheelUrl}', keep_going=True)
8681
`);
8782
}
88-
console.debug('extraPackagesAndIndexes', extraPackagesAndIndexes);
89-
90-
if (extraPackagesAndIndexes.length > 0) {
91-
// note that here pkg can be a package name or a wheel url
92-
for (let { package: pkg, indexes } of extraPackagesAndIndexes) {
93-
let installCmd: string;
94-
if (indexes === null) {
95-
installCmd = `import micropip\nawait micropip.install('${pkg}', keep_going=True)`;
96-
} else {
97-
installCmd = `import micropip\nawait micropip.install('${pkg}', index_urls=${JSON.stringify(indexes)}, keep_going=True)`;
98-
}
99-
console.info('installCmd', installCmd);
100-
try {
101-
await this._pyodide.runPythonAsync(installCmd);
102-
console.info(`Package ${pkg} Installed successfully`);
103-
} catch (e) {
104-
console.error('Error installing package', e);
105-
}
106-
}
107-
} else {
108-
console.info('no extra packages and indexes');
109-
}
11083

11184
// get piplite early enough to impact pyodide-kernel dependencies
11285
await this._pyodide.runPythonAsync(`
@@ -129,6 +102,25 @@ export class PyodideRemoteKernel {
129102
scriptLines.push(`await piplite.install('${pkgName}', keep_going=True)`);
130103
}
131104
}
105+
const { extraPackagesAndIndexes } = this._options as IPyodideWorkerKernel.IOptions;
106+
if (extraPackagesAndIndexes.length > 0) {
107+
// note that here pkg can be a package name or a wheel url
108+
for (let { packages: pkgs, indexes } of extraPackagesAndIndexes) {
109+
let installCmd: string;
110+
if (indexes === null) {
111+
installCmd = `import micropip\nawait micropip.install(${JSON.stringify(pkgs)}, keep_going=True)`;
112+
} else {
113+
installCmd = `import micropip\nawait micropip.install(${JSON.stringify(pkgs)}, index_urls=${JSON.stringify(indexes)}, keep_going=True)`;
114+
}
115+
console.info('installCmd', installCmd);
116+
try {
117+
await this._pyodide.runPythonAsync(installCmd);
118+
console.info(`Package ${pkgs} Installed successfully`);
119+
} catch (e) {
120+
console.error('Error installing packages', e);
121+
}
122+
}
123+
}
132124

133125
// import the kernel
134126
scriptLines.push('import pyodide_kernel');

0 commit comments

Comments
 (0)