pyodide 0.20.0 → 0.21.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/console.html +232 -0
- package/distutils.tar +0 -0
- package/package.json +82 -10
- package/packages.json +1 -0
- package/pyodide.asm.data +0 -0
- package/pyodide.asm.js +17 -0
- package/pyodide.asm.wasm +0 -0
- package/pyodide.d.ts +564 -0
- package/pyodide.js +2 -0
- package/pyodide.js.map +1 -0
- package/pyodide.mjs +2 -0
- package/pyodide.mjs.map +1 -0
- package/pyodide_py.tar +0 -0
- package/README.md +0 -40
- package/api.ts +0 -495
- package/compat.ts +0 -146
- package/error_handling.gen.ts +0 -335
- package/index.d.ts +0 -1
- package/index.test-d.ts +0 -167
- package/load-package.ts +0 -414
- package/module.ts +0 -117
- package/pyodide.ts +0 -309
- package/pyodide.umd.ts +0 -3
- package/pyproxy.gen.ts +0 -1507
- package/rollup.config.js +0 -43
- package/test/conftest.js +0 -7
- package/test/filesystem.test.js +0 -12
- package/test/module.test.js +0 -10
- package/test/pyodide.test.mjs +0 -26
- package/tsconfig.json +0 -15
package/pyodide.asm.wasm
ADDED
|
Binary file
|
package/pyodide.d.ts
ADDED
|
@@ -0,0 +1,564 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v6.7.0
|
|
2
|
+
|
|
3
|
+
declare function isPyProxy(jsobj: any): jsobj is PyProxy;
|
|
4
|
+
declare type PyProxyCache = {
|
|
5
|
+
cacheId: number;
|
|
6
|
+
refcnt: number;
|
|
7
|
+
leaked?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare type PyProxy = PyProxyClass & {
|
|
10
|
+
[x: string]: any;
|
|
11
|
+
};
|
|
12
|
+
declare class PyProxyClass {
|
|
13
|
+
$$: {
|
|
14
|
+
ptr: number;
|
|
15
|
+
cache: PyProxyCache;
|
|
16
|
+
destroyed_msg?: string;
|
|
17
|
+
};
|
|
18
|
+
$$flags: number;
|
|
19
|
+
/** @private */
|
|
20
|
+
constructor();
|
|
21
|
+
get [Symbol.toStringTag](): string;
|
|
22
|
+
/**
|
|
23
|
+
* The name of the type of the object.
|
|
24
|
+
*
|
|
25
|
+
* Usually the value is ``"module.name"`` but for builtins or
|
|
26
|
+
* interpreter-defined types it is just ``"name"``. As pseudocode this is:
|
|
27
|
+
*
|
|
28
|
+
* .. code-block:: python
|
|
29
|
+
*
|
|
30
|
+
* ty = type(x)
|
|
31
|
+
* if ty.__module__ == 'builtins' or ty.__module__ == "__main__":
|
|
32
|
+
* return ty.__name__
|
|
33
|
+
* else:
|
|
34
|
+
* ty.__module__ + "." + ty.__name__
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
get type(): string;
|
|
38
|
+
toString(): string;
|
|
39
|
+
/**
|
|
40
|
+
* Destroy the ``PyProxy``. This will release the memory. Any further attempt
|
|
41
|
+
* to use the object will raise an error.
|
|
42
|
+
*
|
|
43
|
+
* In a browser supporting `FinalizationRegistry
|
|
44
|
+
* <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry>`_
|
|
45
|
+
* Pyodide will automatically destroy the ``PyProxy`` when it is garbage
|
|
46
|
+
* collected, however there is no guarantee that the finalizer will be run in
|
|
47
|
+
* a timely manner so it is better to ``destroy`` the proxy explicitly.
|
|
48
|
+
*
|
|
49
|
+
* @param destroyed_msg The error message to print if use is attempted after
|
|
50
|
+
* destroying. Defaults to "Object has already been destroyed".
|
|
51
|
+
*/
|
|
52
|
+
destroy(destroyed_msg?: string): void;
|
|
53
|
+
/**
|
|
54
|
+
* Make a new PyProxy pointing to the same Python object.
|
|
55
|
+
* Useful if the PyProxy is destroyed somewhere else.
|
|
56
|
+
*/
|
|
57
|
+
copy(): PyProxy;
|
|
58
|
+
/**
|
|
59
|
+
* Converts the ``PyProxy`` into a JavaScript object as best as possible. By
|
|
60
|
+
* default does a deep conversion, if a shallow conversion is desired, you can
|
|
61
|
+
* use ``proxy.toJs({depth : 1})``. See :ref:`Explicit Conversion of PyProxy
|
|
62
|
+
* <type-translations-pyproxy-to-js>` for more info.
|
|
63
|
+
* @param options
|
|
64
|
+
* @return The JavaScript object resulting from the conversion.
|
|
65
|
+
*/
|
|
66
|
+
toJs({ depth, pyproxies, create_pyproxies, dict_converter, default_converter, }?: {
|
|
67
|
+
/** How many layers deep to perform the conversion. Defaults to infinite */
|
|
68
|
+
depth?: number;
|
|
69
|
+
/**
|
|
70
|
+
* If provided, ``toJs`` will store all PyProxies created in this list. This
|
|
71
|
+
* allows you to easily destroy all the PyProxies by iterating the list
|
|
72
|
+
* without having to recurse over the generated structure. The most common
|
|
73
|
+
* use case is to create a new empty list, pass the list as `pyproxies`, and
|
|
74
|
+
* then later iterate over `pyproxies` to destroy all of created proxies.
|
|
75
|
+
*/
|
|
76
|
+
pyproxies?: PyProxy[];
|
|
77
|
+
/**
|
|
78
|
+
* If false, ``toJs`` will throw a ``ConversionError`` rather than
|
|
79
|
+
* producing a ``PyProxy``.
|
|
80
|
+
*/
|
|
81
|
+
create_pyproxies?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* A function to be called on an iterable of pairs ``[key, value]``. Convert
|
|
84
|
+
* this iterable of pairs to the desired output. For instance,
|
|
85
|
+
* ``Object.fromEntries`` would convert the dict to an object, ``Array.from``
|
|
86
|
+
* converts it to an array of entries, and ``(it) => new Map(it)`` converts
|
|
87
|
+
* it to a ``Map`` (which is the default behavior).
|
|
88
|
+
*/
|
|
89
|
+
dict_converter?: (array: Iterable<[
|
|
90
|
+
key: string,
|
|
91
|
+
value: any
|
|
92
|
+
]>) => any;
|
|
93
|
+
/**
|
|
94
|
+
* Optional argument to convert objects with no default conversion. See the
|
|
95
|
+
* documentation of :any:`pyodide.to_js`.
|
|
96
|
+
*/
|
|
97
|
+
default_converter?: (obj: PyProxy, convert: (obj: PyProxy) => any, cacheConversion: (obj: PyProxy, result: any) => void) => any;
|
|
98
|
+
}): any;
|
|
99
|
+
/**
|
|
100
|
+
* Check whether the :any:`PyProxy.length` getter is available on this PyProxy. A
|
|
101
|
+
* Typescript type guard.
|
|
102
|
+
*/
|
|
103
|
+
supportsLength(): this is PyProxyWithLength;
|
|
104
|
+
/**
|
|
105
|
+
* Check whether the :any:`PyProxy.get` method is available on this PyProxy. A
|
|
106
|
+
* Typescript type guard.
|
|
107
|
+
*/
|
|
108
|
+
supportsGet(): this is PyProxyWithGet;
|
|
109
|
+
/**
|
|
110
|
+
* Check whether the :any:`PyProxy.set` method is available on this PyProxy. A
|
|
111
|
+
* Typescript type guard.
|
|
112
|
+
*/
|
|
113
|
+
supportsSet(): this is PyProxyWithSet;
|
|
114
|
+
/**
|
|
115
|
+
* Check whether the :any:`PyProxy.has` method is available on this PyProxy. A
|
|
116
|
+
* Typescript type guard.
|
|
117
|
+
*/
|
|
118
|
+
supportsHas(): this is PyProxyWithHas;
|
|
119
|
+
/**
|
|
120
|
+
* Check whether the PyProxy is iterable. A Typescript type guard for
|
|
121
|
+
* :any:`PyProxy.[iterator]`.
|
|
122
|
+
*/
|
|
123
|
+
isIterable(): this is PyProxyIterable;
|
|
124
|
+
/**
|
|
125
|
+
* Check whether the PyProxy is iterable. A Typescript type guard for
|
|
126
|
+
* :any:`PyProxy.next`.
|
|
127
|
+
*/
|
|
128
|
+
isIterator(): this is PyProxyIterator;
|
|
129
|
+
/**
|
|
130
|
+
* Check whether the PyProxy is awaitable. A Typescript type guard, if this
|
|
131
|
+
* function returns true Typescript considers the PyProxy to be a ``Promise``.
|
|
132
|
+
*/
|
|
133
|
+
isAwaitable(): this is PyProxyAwaitable;
|
|
134
|
+
/**
|
|
135
|
+
* Check whether the PyProxy is a buffer. A Typescript type guard for
|
|
136
|
+
* :any:`PyProxy.getBuffer`.
|
|
137
|
+
*/
|
|
138
|
+
isBuffer(): this is PyProxyBuffer;
|
|
139
|
+
/**
|
|
140
|
+
* Check whether the PyProxy is a Callable. A Typescript type guard, if this
|
|
141
|
+
* returns true then Typescript considers the Proxy to be callable of
|
|
142
|
+
* signature ``(args... : any[]) => PyProxy | number | bigint | string |
|
|
143
|
+
* boolean | undefined``.
|
|
144
|
+
*/
|
|
145
|
+
isCallable(): this is PyProxyCallable;
|
|
146
|
+
}
|
|
147
|
+
export declare type PyProxyWithLength = PyProxy & PyProxyLengthMethods;
|
|
148
|
+
declare class PyProxyLengthMethods {
|
|
149
|
+
/**
|
|
150
|
+
* The length of the object.
|
|
151
|
+
*
|
|
152
|
+
* Present only if the proxied Python object has a ``__len__`` method.
|
|
153
|
+
*/
|
|
154
|
+
get length(): number;
|
|
155
|
+
}
|
|
156
|
+
export declare type PyProxyWithGet = PyProxy & PyProxyGetItemMethods;
|
|
157
|
+
declare class PyProxyGetItemMethods {
|
|
158
|
+
/**
|
|
159
|
+
* This translates to the Python code ``obj[key]``.
|
|
160
|
+
*
|
|
161
|
+
* Present only if the proxied Python object has a ``__getitem__`` method.
|
|
162
|
+
*
|
|
163
|
+
* @param key The key to look up.
|
|
164
|
+
* @returns The corresponding value.
|
|
165
|
+
*/
|
|
166
|
+
get(key: any): any;
|
|
167
|
+
}
|
|
168
|
+
export declare type PyProxyWithSet = PyProxy & PyProxySetItemMethods;
|
|
169
|
+
declare class PyProxySetItemMethods {
|
|
170
|
+
/**
|
|
171
|
+
* This translates to the Python code ``obj[key] = value``.
|
|
172
|
+
*
|
|
173
|
+
* Present only if the proxied Python object has a ``__setitem__`` method.
|
|
174
|
+
*
|
|
175
|
+
* @param key The key to set.
|
|
176
|
+
* @param value The value to set it to.
|
|
177
|
+
*/
|
|
178
|
+
set(key: any, value: any): void;
|
|
179
|
+
/**
|
|
180
|
+
* This translates to the Python code ``del obj[key]``.
|
|
181
|
+
*
|
|
182
|
+
* Present only if the proxied Python object has a ``__delitem__`` method.
|
|
183
|
+
*
|
|
184
|
+
* @param key The key to delete.
|
|
185
|
+
*/
|
|
186
|
+
delete(key: any): void;
|
|
187
|
+
}
|
|
188
|
+
export declare type PyProxyWithHas = PyProxy & PyProxyContainsMethods;
|
|
189
|
+
declare class PyProxyContainsMethods {
|
|
190
|
+
/**
|
|
191
|
+
* This translates to the Python code ``key in obj``.
|
|
192
|
+
*
|
|
193
|
+
* Present only if the proxied Python object has a ``__contains__`` method.
|
|
194
|
+
*
|
|
195
|
+
* @param key The key to check for.
|
|
196
|
+
* @returns Is ``key`` present?
|
|
197
|
+
*/
|
|
198
|
+
has(key: any): boolean;
|
|
199
|
+
}
|
|
200
|
+
export declare type PyProxyIterable = PyProxy & PyProxyIterableMethods;
|
|
201
|
+
declare class PyProxyIterableMethods {
|
|
202
|
+
/**
|
|
203
|
+
* This translates to the Python code ``iter(obj)``. Return an iterator
|
|
204
|
+
* associated to the proxy. See the documentation for `Symbol.iterator
|
|
205
|
+
* <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator>`_.
|
|
206
|
+
*
|
|
207
|
+
* Present only if the proxied Python object is iterable (i.e., has an
|
|
208
|
+
* ``__iter__`` method).
|
|
209
|
+
*
|
|
210
|
+
* This will be used implicitly by ``for(let x of proxy){}``.
|
|
211
|
+
*/
|
|
212
|
+
[Symbol.iterator](): Iterator<any, any, any>;
|
|
213
|
+
}
|
|
214
|
+
export declare type PyProxyIterator = PyProxy & PyProxyIteratorMethods;
|
|
215
|
+
declare class PyProxyIteratorMethods {
|
|
216
|
+
/** @private */
|
|
217
|
+
[Symbol.iterator](): this;
|
|
218
|
+
/**
|
|
219
|
+
* This translates to the Python code ``next(obj)``. Returns the next value of
|
|
220
|
+
* the generator. See the documentation for `Generator.prototype.next
|
|
221
|
+
* <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next>`_.
|
|
222
|
+
* The argument will be sent to the Python generator.
|
|
223
|
+
*
|
|
224
|
+
* This will be used implicitly by ``for(let x of proxy){}``.
|
|
225
|
+
*
|
|
226
|
+
* Present only if the proxied Python object is a generator or iterator (i.e.,
|
|
227
|
+
* has a ``send`` or ``__next__`` method).
|
|
228
|
+
*
|
|
229
|
+
* @param any The value to send to the generator. The value will be assigned
|
|
230
|
+
* as a result of a yield expression.
|
|
231
|
+
* @returns An Object with two properties: ``done`` and ``value``. When the
|
|
232
|
+
* generator yields ``some_value``, ``next`` returns ``{done : false, value :
|
|
233
|
+
* some_value}``. When the generator raises a ``StopIteration(result_value)``
|
|
234
|
+
* exception, ``next`` returns ``{done : true, value : result_value}``.
|
|
235
|
+
*/
|
|
236
|
+
next(arg?: any): IteratorResult<any, any>;
|
|
237
|
+
}
|
|
238
|
+
export declare type PyProxyAwaitable = PyProxy & Promise<any>;
|
|
239
|
+
export declare type PyProxyCallable = PyProxy & PyProxyCallableMethods & ((...args: any[]) => any);
|
|
240
|
+
declare class PyProxyCallableMethods {
|
|
241
|
+
apply(jsthis: PyProxyClass, jsargs: any): any;
|
|
242
|
+
call(jsthis: PyProxyClass, ...jsargs: any): any;
|
|
243
|
+
/**
|
|
244
|
+
* Call the function with key word arguments.
|
|
245
|
+
* The last argument must be an object with the keyword arguments.
|
|
246
|
+
*/
|
|
247
|
+
callKwargs(...jsargs: any): any;
|
|
248
|
+
}
|
|
249
|
+
export declare type PyProxyBuffer = PyProxy & PyProxyBufferMethods;
|
|
250
|
+
declare class PyProxyBufferMethods {
|
|
251
|
+
/**
|
|
252
|
+
* Get a view of the buffer data which is usable from JavaScript. No copy is
|
|
253
|
+
* ever performed.
|
|
254
|
+
*
|
|
255
|
+
* Present only if the proxied Python object supports the `Python Buffer
|
|
256
|
+
* Protocol <https://docs.python.org/3/c-api/buffer.html>`_.
|
|
257
|
+
*
|
|
258
|
+
* We do not support suboffsets, if the buffer requires suboffsets we will
|
|
259
|
+
* throw an error. JavaScript nd array libraries can't handle suboffsets
|
|
260
|
+
* anyways. In this case, you should use the :any:`toJs` api or copy the
|
|
261
|
+
* buffer to one that doesn't use suboffets (using e.g.,
|
|
262
|
+
* `numpy.ascontiguousarray
|
|
263
|
+
* <https://numpy.org/doc/stable/reference/generated/numpy.ascontiguousarray.html>`_).
|
|
264
|
+
*
|
|
265
|
+
* If the buffer stores big endian data or half floats, this function will
|
|
266
|
+
* fail without an explicit type argument. For big endian data you can use
|
|
267
|
+
* ``toJs``. `DataViews
|
|
268
|
+
* <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView>`_
|
|
269
|
+
* have support for big endian data, so you might want to pass
|
|
270
|
+
* ``'dataview'`` as the type argument in that case.
|
|
271
|
+
*
|
|
272
|
+
* @param type The type of the :any:`PyBuffer.data <pyodide.PyBuffer.data>` field in the
|
|
273
|
+
* output. Should be one of: ``"i8"``, ``"u8"``, ``"u8clamped"``, ``"i16"``,
|
|
274
|
+
* ``"u16"``, ``"i32"``, ``"u32"``, ``"i32"``, ``"u32"``, ``"i64"``,
|
|
275
|
+
* ``"u64"``, ``"f32"``, ``"f64``, or ``"dataview"``. This argument is
|
|
276
|
+
* optional, if absent ``getBuffer`` will try to determine the appropriate
|
|
277
|
+
* output type based on the buffer `format string
|
|
278
|
+
* <https://docs.python.org/3/library/struct.html#format-strings>`_.
|
|
279
|
+
* @returns :any:`PyBuffer <pyodide.PyBuffer>`
|
|
280
|
+
*/
|
|
281
|
+
getBuffer(type?: string): PyBuffer;
|
|
282
|
+
}
|
|
283
|
+
export declare type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
|
|
284
|
+
export declare type PyProxyDict = PyProxyWithGet & PyProxyWithSet & PyProxyWithHas;
|
|
285
|
+
/**
|
|
286
|
+
* A class to allow access to a Python data buffers from JavaScript. These are
|
|
287
|
+
* produced by :any:`PyProxy.getBuffer` and cannot be constructed directly.
|
|
288
|
+
* When you are done, release it with the :any:`release <PyBuffer.release>`
|
|
289
|
+
* method. See
|
|
290
|
+
* `Python buffer protocol documentation
|
|
291
|
+
* <https://docs.python.org/3/c-api/buffer.html>`_ for more information.
|
|
292
|
+
*
|
|
293
|
+
* To find the element ``x[a_1, ..., a_n]``, you could use the following code:
|
|
294
|
+
*
|
|
295
|
+
* .. code-block:: js
|
|
296
|
+
*
|
|
297
|
+
* function multiIndexToIndex(pybuff, multiIndex){
|
|
298
|
+
* if(multindex.length !==pybuff.ndim){
|
|
299
|
+
* throw new Error("Wrong length index");
|
|
300
|
+
* }
|
|
301
|
+
* let idx = pybuff.offset;
|
|
302
|
+
* for(let i = 0; i < pybuff.ndim; i++){
|
|
303
|
+
* if(multiIndex[i] < 0){
|
|
304
|
+
* multiIndex[i] = pybuff.shape[i] - multiIndex[i];
|
|
305
|
+
* }
|
|
306
|
+
* if(multiIndex[i] < 0 || multiIndex[i] >= pybuff.shape[i]){
|
|
307
|
+
* throw new Error("Index out of range");
|
|
308
|
+
* }
|
|
309
|
+
* idx += multiIndex[i] * pybuff.stride[i];
|
|
310
|
+
* }
|
|
311
|
+
* return idx;
|
|
312
|
+
* }
|
|
313
|
+
* console.log("entry is", pybuff.data[multiIndexToIndex(pybuff, [2, 0, -1])]);
|
|
314
|
+
*
|
|
315
|
+
* .. admonition:: Contiguity
|
|
316
|
+
* :class: warning
|
|
317
|
+
*
|
|
318
|
+
* If the buffer is not contiguous, the ``data`` TypedArray will contain
|
|
319
|
+
* data that is not part of the buffer. Modifying this data may lead to
|
|
320
|
+
* undefined behavior.
|
|
321
|
+
*
|
|
322
|
+
* .. admonition:: Readonly buffers
|
|
323
|
+
* :class: warning
|
|
324
|
+
*
|
|
325
|
+
* If ``buffer.readonly`` is ``true``, you should not modify the buffer.
|
|
326
|
+
* Modifying a readonly buffer may lead to undefined behavior.
|
|
327
|
+
*
|
|
328
|
+
* .. admonition:: Converting between TypedArray types
|
|
329
|
+
* :class: warning
|
|
330
|
+
*
|
|
331
|
+
* The following naive code to change the type of a typed array does not
|
|
332
|
+
* work:
|
|
333
|
+
*
|
|
334
|
+
* .. code-block:: js
|
|
335
|
+
*
|
|
336
|
+
* // Incorrectly convert a TypedArray.
|
|
337
|
+
* // Produces a Uint16Array that points to the entire WASM memory!
|
|
338
|
+
* let myarray = new Uint16Array(buffer.data.buffer);
|
|
339
|
+
*
|
|
340
|
+
* Instead, if you want to convert the output TypedArray, you need to say:
|
|
341
|
+
*
|
|
342
|
+
* .. code-block:: js
|
|
343
|
+
*
|
|
344
|
+
* // Correctly convert a TypedArray.
|
|
345
|
+
* let myarray = new Uint16Array(
|
|
346
|
+
* buffer.data.buffer,
|
|
347
|
+
* buffer.data.byteOffset,
|
|
348
|
+
* buffer.data.byteLength
|
|
349
|
+
* );
|
|
350
|
+
*/
|
|
351
|
+
export declare class PyBuffer {
|
|
352
|
+
/**
|
|
353
|
+
* The offset of the first entry of the array. For instance if our array
|
|
354
|
+
* is 3d, then you will find ``array[0,0,0]`` at
|
|
355
|
+
* ``pybuf.data[pybuf.offset]``
|
|
356
|
+
*/
|
|
357
|
+
offset: number;
|
|
358
|
+
/**
|
|
359
|
+
* If the data is readonly, you should not modify it. There is no way
|
|
360
|
+
* for us to enforce this, but it may cause very weird behavior.
|
|
361
|
+
*/
|
|
362
|
+
readonly: boolean;
|
|
363
|
+
/**
|
|
364
|
+
* The format string for the buffer. See `the Python documentation on
|
|
365
|
+
* format strings
|
|
366
|
+
* <https://docs.python.org/3/library/struct.html#format-strings>`_.
|
|
367
|
+
*/
|
|
368
|
+
format: string;
|
|
369
|
+
/**
|
|
370
|
+
* How large is each entry (in bytes)?
|
|
371
|
+
*/
|
|
372
|
+
itemsize: number;
|
|
373
|
+
/**
|
|
374
|
+
* The number of dimensions of the buffer. If ``ndim`` is 0, the buffer
|
|
375
|
+
* represents a single scalar or struct. Otherwise, it represents an
|
|
376
|
+
* array.
|
|
377
|
+
*/
|
|
378
|
+
ndim: number;
|
|
379
|
+
/**
|
|
380
|
+
* The total number of bytes the buffer takes up. This is equal to
|
|
381
|
+
* ``buff.data.byteLength``.
|
|
382
|
+
*/
|
|
383
|
+
nbytes: number;
|
|
384
|
+
/**
|
|
385
|
+
* The shape of the buffer, that is how long it is in each dimension.
|
|
386
|
+
* The length will be equal to ``ndim``. For instance, a 2x3x4 array
|
|
387
|
+
* would have shape ``[2, 3, 4]``.
|
|
388
|
+
*/
|
|
389
|
+
shape: number[];
|
|
390
|
+
/**
|
|
391
|
+
* An array of of length ``ndim`` giving the number of elements to skip
|
|
392
|
+
* to get to a new element in each dimension. See the example definition
|
|
393
|
+
* of a ``multiIndexToIndex`` function above.
|
|
394
|
+
*/
|
|
395
|
+
strides: number[];
|
|
396
|
+
/**
|
|
397
|
+
* The actual data. A typed array of an appropriate size backed by a
|
|
398
|
+
* segment of the WASM memory.
|
|
399
|
+
*
|
|
400
|
+
* The ``type`` argument of :any:`PyProxy.getBuffer`
|
|
401
|
+
* determines which sort of ``TypedArray`` this is. By default
|
|
402
|
+
* :any:`PyProxy.getBuffer` will look at the format string to determine the most
|
|
403
|
+
* appropriate option.
|
|
404
|
+
*/
|
|
405
|
+
data: TypedArray;
|
|
406
|
+
/**
|
|
407
|
+
* Is it C contiguous?
|
|
408
|
+
*/
|
|
409
|
+
c_contiguous: boolean;
|
|
410
|
+
/**
|
|
411
|
+
* Is it Fortran contiguous?
|
|
412
|
+
*/
|
|
413
|
+
f_contiguous: boolean;
|
|
414
|
+
/**
|
|
415
|
+
* @private
|
|
416
|
+
*/
|
|
417
|
+
_released: boolean;
|
|
418
|
+
/**
|
|
419
|
+
* @private
|
|
420
|
+
*/
|
|
421
|
+
_view_ptr: number;
|
|
422
|
+
/**
|
|
423
|
+
* @private
|
|
424
|
+
*/
|
|
425
|
+
constructor();
|
|
426
|
+
/**
|
|
427
|
+
* Release the buffer. This allows the memory to be reclaimed.
|
|
428
|
+
*/
|
|
429
|
+
release(): void;
|
|
430
|
+
}
|
|
431
|
+
declare function loadPackage(names: string | PyProxy | Array<string>, messageCallback?: (msg: string) => void, errorCallback?: (msg: string) => void): Promise<void>;
|
|
432
|
+
declare let loadedPackages: {
|
|
433
|
+
[key: string]: string;
|
|
434
|
+
};
|
|
435
|
+
declare class PythonError extends Error {
|
|
436
|
+
/** The address of the error we are wrapping. We may later compare this
|
|
437
|
+
* against sys.last_value.
|
|
438
|
+
* WARNING: we don't own a reference to this pointer, dereferencing it
|
|
439
|
+
* may be a use-after-free error!
|
|
440
|
+
* @private
|
|
441
|
+
*/
|
|
442
|
+
__error_address: number;
|
|
443
|
+
constructor(message: string, error_address: number);
|
|
444
|
+
}
|
|
445
|
+
declare let pyodide_py: PyProxy;
|
|
446
|
+
declare let globals: PyProxy;
|
|
447
|
+
declare let version: string;
|
|
448
|
+
declare function runPython(code: string, options?: {
|
|
449
|
+
globals?: PyProxy;
|
|
450
|
+
}): any;
|
|
451
|
+
declare function loadPackagesFromImports(code: string, messageCallback?: (msg: string) => void, errorCallback?: (err: string) => void): Promise<void>;
|
|
452
|
+
declare function runPythonAsync(code: string, options?: {
|
|
453
|
+
globals?: PyProxy;
|
|
454
|
+
}): Promise<any>;
|
|
455
|
+
declare function registerJsModule(name: string, module: object): void;
|
|
456
|
+
declare function registerComlink(Comlink: any): void;
|
|
457
|
+
declare function unregisterJsModule(name: string): void;
|
|
458
|
+
declare function toPy(obj: any, { depth, defaultConverter, }?: {
|
|
459
|
+
/**
|
|
460
|
+
* Optional argument to limit the depth of the conversion.
|
|
461
|
+
*/
|
|
462
|
+
depth: number;
|
|
463
|
+
/**
|
|
464
|
+
* Optional argument to convert objects with no default conversion. See the
|
|
465
|
+
* documentation of :any:`JsProxy.to_py`.
|
|
466
|
+
*/
|
|
467
|
+
defaultConverter?: (value: any, converter: (value: any) => any, cacheConversion: (input: any, output: any) => any) => any;
|
|
468
|
+
}): any;
|
|
469
|
+
declare function pyimport(mod_name: string): PyProxy;
|
|
470
|
+
declare function unpackArchive(buffer: TypedArray | ArrayBuffer, format: string, options?: {
|
|
471
|
+
extractDir?: string;
|
|
472
|
+
}): void;
|
|
473
|
+
declare function setInterruptBuffer(interrupt_buffer: TypedArray): void;
|
|
474
|
+
declare function checkInterrupt(): void;
|
|
475
|
+
export declare type PyodideInterface = {
|
|
476
|
+
globals: typeof globals;
|
|
477
|
+
FS: typeof FS;
|
|
478
|
+
PATH: typeof PATH;
|
|
479
|
+
ERRNO_CODES: typeof ERRNO_CODES;
|
|
480
|
+
pyodide_py: typeof pyodide_py;
|
|
481
|
+
version: typeof version;
|
|
482
|
+
loadPackage: typeof loadPackage;
|
|
483
|
+
loadPackagesFromImports: typeof loadPackagesFromImports;
|
|
484
|
+
loadedPackages: typeof loadedPackages;
|
|
485
|
+
isPyProxy: typeof isPyProxy;
|
|
486
|
+
runPython: typeof runPython;
|
|
487
|
+
runPythonAsync: typeof runPythonAsync;
|
|
488
|
+
registerJsModule: typeof registerJsModule;
|
|
489
|
+
unregisterJsModule: typeof unregisterJsModule;
|
|
490
|
+
setInterruptBuffer: typeof setInterruptBuffer;
|
|
491
|
+
checkInterrupt: typeof checkInterrupt;
|
|
492
|
+
toPy: typeof toPy;
|
|
493
|
+
pyimport: typeof pyimport;
|
|
494
|
+
unpackArchive: typeof unpackArchive;
|
|
495
|
+
registerComlink: typeof registerComlink;
|
|
496
|
+
PythonError: typeof PythonError;
|
|
497
|
+
PyBuffer: typeof PyBuffer;
|
|
498
|
+
};
|
|
499
|
+
declare let FS: any;
|
|
500
|
+
declare let PATH: any;
|
|
501
|
+
declare let ERRNO_CODES: any;
|
|
502
|
+
export declare type Py2JsResult = any;
|
|
503
|
+
/**
|
|
504
|
+
* See documentation for loadPyodide.
|
|
505
|
+
* @private
|
|
506
|
+
*/
|
|
507
|
+
export declare type ConfigType = {
|
|
508
|
+
indexURL: string;
|
|
509
|
+
homedir: string;
|
|
510
|
+
fullStdLib?: boolean;
|
|
511
|
+
stdin?: () => string;
|
|
512
|
+
stdout?: (msg: string) => void;
|
|
513
|
+
stderr?: (msg: string) => void;
|
|
514
|
+
jsglobals?: object;
|
|
515
|
+
};
|
|
516
|
+
/**
|
|
517
|
+
* Load the main Pyodide wasm module and initialize it.
|
|
518
|
+
*
|
|
519
|
+
* Only one copy of Pyodide can be loaded in a given JavaScript global scope
|
|
520
|
+
* because Pyodide uses global variables to load packages. If an attempt is made
|
|
521
|
+
* to load a second copy of Pyodide, :any:`loadPyodide` will throw an error.
|
|
522
|
+
* (This can be fixed once `Firefox adopts support for ES6 modules in webworkers
|
|
523
|
+
* <https://bugzilla.mozilla.org/show_bug.cgi?id=1247687>`_.)
|
|
524
|
+
*
|
|
525
|
+
* @returns The :ref:`js-api-pyodide` module.
|
|
526
|
+
* @memberof globalThis
|
|
527
|
+
* @async
|
|
528
|
+
*/
|
|
529
|
+
export declare function loadPyodide(options?: {
|
|
530
|
+
/**
|
|
531
|
+
* The URL from which Pyodide will load the main Pyodide runtime and
|
|
532
|
+
* packages. Defaults to the url that pyodide is loaded from with the file
|
|
533
|
+
* name (pyodide.js or pyodide.mjs) removed. It is recommended that you
|
|
534
|
+
* leave this undefined, providing an incorrect value can cause broken
|
|
535
|
+
* behavior.
|
|
536
|
+
*/
|
|
537
|
+
indexURL?: string;
|
|
538
|
+
/**
|
|
539
|
+
* The home directory which Pyodide will use inside virtual file system. Default: "/home/pyodide"
|
|
540
|
+
*/
|
|
541
|
+
homedir?: string;
|
|
542
|
+
/** Load the full Python standard library.
|
|
543
|
+
* Setting this to false excludes following modules: distutils.
|
|
544
|
+
* Default: true
|
|
545
|
+
*/
|
|
546
|
+
fullStdLib?: boolean;
|
|
547
|
+
/**
|
|
548
|
+
* Override the standard input callback. Should ask the user for one line of input.
|
|
549
|
+
*/
|
|
550
|
+
stdin?: () => string;
|
|
551
|
+
/**
|
|
552
|
+
* Override the standard output callback.
|
|
553
|
+
* Default: undefined
|
|
554
|
+
*/
|
|
555
|
+
stdout?: (msg: string) => void;
|
|
556
|
+
/**
|
|
557
|
+
* Override the standard error output callback.
|
|
558
|
+
* Default: undefined
|
|
559
|
+
*/
|
|
560
|
+
stderr?: (msg: string) => void;
|
|
561
|
+
jsglobals?: object;
|
|
562
|
+
}): Promise<PyodideInterface>;
|
|
563
|
+
|
|
564
|
+
export {};
|
package/pyodide.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports):"function"==typeof define&&define.amd?define(["exports"],factory):factory((global="undefined"!=typeof globalThis?globalThis:global||self).loadPyodide={})}(this,(function(exports){"use strict";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var errorStackParser={exports:{}},stackframe={exports:{}};!function(module,exports){module.exports=function(){function _isNumber(n){return!isNaN(parseFloat(n))&&isFinite(n)}function _capitalize(str){return str.charAt(0).toUpperCase()+str.substring(1)}function _getter(p){return function(){return this[p]}}var booleanProps=["isConstructor","isEval","isNative","isToplevel"],numericProps=["columnNumber","lineNumber"],stringProps=["fileName","functionName","source"],arrayProps=["args"],objectProps=["evalOrigin"],props=booleanProps.concat(numericProps,stringProps,arrayProps,objectProps);function StackFrame(obj){if(obj)for(var i=0;i<props.length;i++)void 0!==obj[props[i]]&&this["set"+_capitalize(props[i])](obj[props[i]])}StackFrame.prototype={getArgs:function(){return this.args},setArgs:function(v){if("[object Array]"!==Object.prototype.toString.call(v))throw new TypeError("Args must be an Array");this.args=v},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(v){if(v instanceof StackFrame)this.evalOrigin=v;else{if(!(v instanceof Object))throw new TypeError("Eval Origin must be an Object or StackFrame");this.evalOrigin=new StackFrame(v)}},toString:function(){var fileName=this.getFileName()||"",lineNumber=this.getLineNumber()||"",columnNumber=this.getColumnNumber()||"",functionName=this.getFunctionName()||"";return this.getIsEval()?fileName?"[eval] ("+fileName+":"+lineNumber+":"+columnNumber+")":"[eval]:"+lineNumber+":"+columnNumber:functionName?functionName+" ("+fileName+":"+lineNumber+":"+columnNumber+")":fileName+":"+lineNumber+":"+columnNumber}},StackFrame.fromString=function(str){var argsStartIndex=str.indexOf("("),argsEndIndex=str.lastIndexOf(")"),functionName=str.substring(0,argsStartIndex),args=str.substring(argsStartIndex+1,argsEndIndex).split(","),locationString=str.substring(argsEndIndex+1);if(0===locationString.indexOf("@"))var parts=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(locationString,""),fileName=parts[1],lineNumber=parts[2],columnNumber=parts[3];return new StackFrame({functionName:functionName,args:args||void 0,fileName:fileName,lineNumber:lineNumber||void 0,columnNumber:columnNumber||void 0})};for(var i=0;i<booleanProps.length;i++)StackFrame.prototype["get"+_capitalize(booleanProps[i])]=_getter(booleanProps[i]),StackFrame.prototype["set"+_capitalize(booleanProps[i])]=function(p){return function(v){this[p]=Boolean(v)}}(booleanProps[i]);for(var j=0;j<numericProps.length;j++)StackFrame.prototype["get"+_capitalize(numericProps[j])]=_getter(numericProps[j]),StackFrame.prototype["set"+_capitalize(numericProps[j])]=function(p){return function(v){if(!_isNumber(v))throw new TypeError(p+" must be a Number");this[p]=Number(v)}}(numericProps[j]);for(var k=0;k<stringProps.length;k++)StackFrame.prototype["get"+_capitalize(stringProps[k])]=_getter(stringProps[k]),StackFrame.prototype["set"+_capitalize(stringProps[k])]=function(p){return function(v){this[p]=String(v)}}(stringProps[k]);return StackFrame}()}(stackframe),function(module,exports){var StackFrame,FIREFOX_SAFARI_STACK_REGEXP,CHROME_IE_STACK_REGEXP,SAFARI_NATIVE_CODE_REGEXP;module.exports=(StackFrame=stackframe.exports,FIREFOX_SAFARI_STACK_REGEXP=/(^|@)\S+:\d+/,CHROME_IE_STACK_REGEXP=/^\s*at .*(\S+:\d+|\(native\))/m,SAFARI_NATIVE_CODE_REGEXP=/^(eval@)?(\[native code])?$/,{parse:function(error){if(void 0!==error.stacktrace||void 0!==error["opera#sourceloc"])return this.parseOpera(error);if(error.stack&&error.stack.match(CHROME_IE_STACK_REGEXP))return this.parseV8OrIE(error);if(error.stack)return this.parseFFOrSafari(error);throw new Error("Cannot parse given Error object")},extractLocation:function(urlLike){if(-1===urlLike.indexOf(":"))return[urlLike];var parts=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(urlLike.replace(/[()]/g,""));return[parts[1],parts[2]||void 0,parts[3]||void 0]},parseV8OrIE:function(error){return error.stack.split("\n").filter((function(line){return!!line.match(CHROME_IE_STACK_REGEXP)}),this).map((function(line){line.indexOf("(eval ")>-1&&(line=line.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(\),.*$)/g,""));var sanitizedLine=line.replace(/^\s+/,"").replace(/\(eval code/g,"("),location=sanitizedLine.match(/ (\((.+):(\d+):(\d+)\)$)/),tokens=(sanitizedLine=location?sanitizedLine.replace(location[0],""):sanitizedLine).split(/\s+/).slice(1),locationParts=this.extractLocation(location?location[1]:tokens.pop()),functionName=tokens.join(" ")||void 0,fileName=["eval","<anonymous>"].indexOf(locationParts[0])>-1?void 0:locationParts[0];return new StackFrame({functionName:functionName,fileName:fileName,lineNumber:locationParts[1],columnNumber:locationParts[2],source:line})}),this)},parseFFOrSafari:function(error){return error.stack.split("\n").filter((function(line){return!line.match(SAFARI_NATIVE_CODE_REGEXP)}),this).map((function(line){if(line.indexOf(" > eval")>-1&&(line=line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),-1===line.indexOf("@")&&-1===line.indexOf(":"))return new StackFrame({functionName:line});var functionNameRegex=/((.*".+"[^@]*)?[^@]*)(?:@)/,matches=line.match(functionNameRegex),functionName=matches&&matches[1]?matches[1]:void 0,locationParts=this.extractLocation(line.replace(functionNameRegex,""));return new StackFrame({functionName:functionName,fileName:locationParts[0],lineNumber:locationParts[1],columnNumber:locationParts[2],source:line})}),this)},parseOpera:function(e){return!e.stacktrace||e.message.indexOf("\n")>-1&&e.message.split("\n").length>e.stacktrace.split("\n").length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9:function(e){for(var lineRE=/Line (\d+).*script (?:in )?(\S+)/i,lines=e.message.split("\n"),result=[],i=2,len=lines.length;i<len;i+=2){var match=lineRE.exec(lines[i]);match&&result.push(new StackFrame({fileName:match[2],lineNumber:match[1],source:lines[i]}))}return result},parseOpera10:function(e){for(var lineRE=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,lines=e.stacktrace.split("\n"),result=[],i=0,len=lines.length;i<len;i+=2){var match=lineRE.exec(lines[i]);match&&result.push(new StackFrame({functionName:match[3]||void 0,fileName:match[2],lineNumber:match[1],source:lines[i]}))}return result},parseOpera11:function(error){return error.stack.split("\n").filter((function(line){return!!line.match(FIREFOX_SAFARI_STACK_REGEXP)&&!line.match(/^Error created at/)}),this).map((function(line){var argsRaw,tokens=line.split("@"),locationParts=this.extractLocation(tokens.pop()),functionCall=tokens.shift()||"",functionName=functionCall.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0;functionCall.match(/\(([^)]*)\)/)&&(argsRaw=functionCall.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var args=void 0===argsRaw||"[arguments not available]"===argsRaw?void 0:argsRaw.split(",");return new StackFrame({functionName:functionName,args:args,fileName:locationParts[0],lineNumber:locationParts[1],columnNumber:locationParts[2],source:line})}),this)}})}(errorStackParser);var ErrorStackParser=errorStackParser.exports;const IN_NODE="undefined"!=typeof process&&process.release&&"node"===process.release.name&&void 0===process.browser;let nodePathMod,nodeFetch,nodeVmMod,nodeFsPromisesMod,_loadBinaryFile,loadScript;if(_loadBinaryFile=IN_NODE?async function(indexURL,path,_file_sub_resource_hash){if(path.startsWith("/")||path.includes("://")||(path=`${indexURL}${path}`),path.startsWith("file://")&&(path=path.slice("file://".length)),path.includes("://")){let response=await nodeFetch(path);if(!response.ok)throw new Error(`Failed to load '${path}': request failed.`);return new Uint8Array(await response.arrayBuffer())}{const data=await nodeFsPromisesMod.readFile(path);return new Uint8Array(data.buffer,data.byteOffset,data.byteLength)}}:async function(indexURL,path,subResourceHash){const base=new URL(indexURL,location),url=new URL(path,base);let options=subResourceHash?{integrity:subResourceHash}:{},response=await fetch(url,options);if(!response.ok)throw new Error(`Failed to load '${url}': request failed.`);return new Uint8Array(await response.arrayBuffer())},globalThis.document)loadScript=async url=>await import(url);else if(globalThis.importScripts)loadScript=async url=>{try{globalThis.importScripts(url)}catch(e){if(!(e instanceof TypeError))throw e;await import(url)}};else{if(!IN_NODE)throw new Error("Cannot determine runtime environment");loadScript=async function(url){url.startsWith("file://")&&(url=url.slice("file://".length));url.includes("://")?nodeVmMod.runInThisContext(await(await nodeFetch(url)).text()):await import(nodePathMod.resolve(url))}}function setStandardStreams(Module,stdin,stdout,stderr){stdout&&(Module.print=stdout),stderr&&(Module.printErr=stderr),stdin&&Module.preRun.push((function(){Module.FS.init(function(stdin){const encoder=new TextEncoder;let input=new Uint8Array(0),inputIndex=-1;function stdinWrapper(){try{if(-1===inputIndex){let text=stdin();if(null==text)return null;if("string"!=typeof text)throw new TypeError(`Expected stdin to return string, null, or undefined, got type ${typeof text}.`);text.endsWith("\n")||(text+="\n"),input=encoder.encode(text),inputIndex=0}if(inputIndex<input.length){let character=input[inputIndex];return inputIndex++,character}return inputIndex=-1,null}catch(e){throw console.error("Error thrown in stdin:"),console.error(e),e}}return stdinWrapper}(stdin),null,null)}))}function finalizeBootstrap(API,config){API.runPythonInternal_dict=API._pyodide._base.eval_code("{}"),API.importlib=API.runPythonInternal("import importlib; importlib");let import_module=API.importlib.import_module;API.sys=import_module("sys"),API.sys.path.insert(0,config.homedir);let globals=API.runPythonInternal("import __main__; __main__.__dict__"),builtins=API.runPythonInternal("import builtins; builtins.__dict__");var builtins_dict;API.globals=(builtins_dict=builtins,new Proxy(globals,{get:(target,symbol)=>"get"===symbol?key=>{let result=target.get(key);return void 0===result&&(result=builtins_dict.get(key)),result}:"has"===symbol?key=>target.has(key)||builtins_dict.has(key):Reflect.get(target,symbol)}));let importhook=API._pyodide._importhook;importhook.register_js_finder(),importhook.register_js_module("js",config.jsglobals);let pyodide=API.makePublicAPI();return importhook.register_js_module("pyodide_js",pyodide),API.pyodide_py=import_module("pyodide"),API.package_loader=import_module("pyodide._package_loader"),API.version=API.pyodide_py.__version__,pyodide.pyodide_py=API.pyodide_py,pyodide.version=API.version,pyodide.globals=API.globals,pyodide}async function loadPyodide(options={}){options.indexURL||(options.indexURL=function(){let err;try{throw new Error}catch(e){err=e}let fileName=ErrorStackParser.parse(err)[0].fileName;return fileName.slice(0,fileName.lastIndexOf("/"))}());const default_config={fullStdLib:!0,jsglobals:globalThis,stdin:globalThis.prompt?globalThis.prompt:void 0,homedir:"/home/pyodide"},config=Object.assign(default_config,options);config.indexURL.endsWith("/")||(config.indexURL+="/"),await async function(){if(!IN_NODE)return;if(nodePathMod=(await import("path")).default,nodeFsPromisesMod=await import("fs/promises"),nodeFetch=(await import("node-fetch")).default,nodeVmMod=(await import("vm")).default,"undefined"!=typeof require)return;const node_modules={fs:await import("fs"),crypto:await import("crypto"),ws:await import("ws"),child_process:await import("child_process")};globalThis.require=function(mod){return node_modules[mod]}}();const pyodide_py_tar_promise=_loadBinaryFile(config.indexURL,"pyodide_py.tar"),Module={noImageDecoding:!0,noAudioDecoding:!0,noWasmDecoding:!1,preloadedWasm:{},preRun:[]},API={config:config};Module.API=API,setStandardStreams(Module,config.stdin,config.stdout,config.stderr),function(Module,path){Module.preRun.push((function(){try{Module.FS.mkdirTree(path)}catch(e){console.error(`Error occurred while making a home directory '${path}':`),console.error(e),console.error("Using '/' for a home directory instead"),path="/"}Module.ENV.HOME=path,Module.FS.chdir(path)}))}(Module,config.homedir);const moduleLoaded=new Promise((r=>Module.postRun=r));Module.locateFile=path=>config.indexURL+path;const scriptSrc=`${config.indexURL}pyodide.asm.js`;await loadScript(scriptSrc),await _createPyodideModule(Module),await moduleLoaded,Module.locateFile=path=>{throw new Error("Didn't expect to load any more file_packager files!")};const pyodide_py_tar=await pyodide_py_tar_promise;!function(Module,pyodide_py_tar){let stream=Module.FS.open("/pyodide_py.tar","w");Module.FS.write(stream,pyodide_py_tar,0,pyodide_py_tar.byteLength,void 0,!0),Module.FS.close(stream);const code_ptr=Module.stringToNewUTF8('\nfrom sys import version_info\npyversion = f"python{version_info.major}.{version_info.minor}"\nimport shutil\nshutil.unpack_archive("/pyodide_py.tar", f"/lib/{pyversion}/site-packages/")\ndel shutil\nimport importlib\nimportlib.invalidate_caches()\ndel importlib\n ');if(Module._PyRun_SimpleString(code_ptr))throw new Error("OOPS!");Module._free(code_ptr),Module.FS.unlink("/pyodide_py.tar")}(Module,pyodide_py_tar),Module._pyodide_init();const pyodide=finalizeBootstrap(API,config);return pyodide.version.includes("dev")||API.setCdnUrl(`https://cdn.jsdelivr.net/pyodide/v${pyodide.version}/full/`),await API.packageIndexReady,config.fullStdLib&&await pyodide.loadPackage(["distutils"]),pyodide.runPython("print('Python initialization complete')"),pyodide}globalThis.loadPyodide=loadPyodide,exports.loadPyodide=loadPyodide,Object.defineProperty(exports,"__esModule",{value:!0})}));
|
|
2
|
+
//# sourceMappingURL=pyodide.js.map
|