@@ -65,13 +65,8 @@ export class PyodideRemoteKernel {
65
65
throw new Error ( 'Uninitialized' ) ;
66
66
}
67
67
68
- const {
69
- pipliteWheelUrl,
70
- disablePyPIFallback,
71
- pipliteUrls,
72
- loadPyodideOptions,
73
- extraPackagesAndIndexes,
74
- } = this . _options ;
68
+ const { pipliteWheelUrl, disablePyPIFallback, pipliteUrls, loadPyodideOptions } =
69
+ this . _options ;
75
70
76
71
const preloaded = ( loadPyodideOptions || { } ) . packages || [ ] ;
77
72
@@ -85,28 +80,6 @@ export class PyodideRemoteKernel {
85
80
await micropip.install('${ pipliteWheelUrl } ', keep_going=True)
86
81
` ) ;
87
82
}
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
- }
110
83
111
84
// get piplite early enough to impact pyodide-kernel dependencies
112
85
await this . _pyodide . runPythonAsync ( `
@@ -129,6 +102,25 @@ export class PyodideRemoteKernel {
129
102
scriptLines . push ( `await piplite.install('${ pkgName } ', keep_going=True)` ) ;
130
103
}
131
104
}
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
+ }
132
124
133
125
// import the kernel
134
126
scriptLines . push ( 'import pyodide_kernel' ) ;
0 commit comments