pyodide 0.22.0-alpha.3 → 0.23.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/README.md +0 -3
- package/console.html +3 -3
- package/package.json +1 -1
- package/pyodide.asm.data +0 -0
- package/pyodide.asm.js +3 -3
- package/pyodide.asm.wasm +0 -0
- package/pyodide.d.ts +175 -133
- package/pyodide.js +1 -1
- package/pyodide.js.map +1 -1
- package/pyodide.mjs +1 -1
- package/pyodide.mjs.map +1 -1
- package/pyodide_py.tar +0 -0
- package/repodata.json +1 -1
package/pyodide.asm.wasm
CHANGED
|
Binary file
|
package/pyodide.d.ts
CHANGED
|
@@ -47,8 +47,14 @@ declare class PyProxyClass {
|
|
|
47
47
|
};
|
|
48
48
|
$$props: PyProxyProps;
|
|
49
49
|
$$flags: number;
|
|
50
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* @private
|
|
52
|
+
* @hideconstructor
|
|
53
|
+
*/
|
|
51
54
|
constructor();
|
|
55
|
+
/**
|
|
56
|
+
* @private
|
|
57
|
+
*/
|
|
52
58
|
get [Symbol.toStringTag](): string;
|
|
53
59
|
/**
|
|
54
60
|
* The name of the type of the object.
|
|
@@ -71,16 +77,20 @@ declare class PyProxyClass {
|
|
|
71
77
|
* Destroy the ``PyProxy``. This will release the memory. Any further attempt
|
|
72
78
|
* to use the object will raise an error.
|
|
73
79
|
*
|
|
74
|
-
* In a browser supporting
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* a timely manner so it is better to ``destroy`` the proxy explicitly.
|
|
80
|
+
* In a browser supporting :js:data:`FinalizationRegistry`, Pyodide will
|
|
81
|
+
* automatically destroy the ``PyProxy`` when it is garbage collected, however
|
|
82
|
+
* there is no guarantee that the finalizer will be run in a timely manner so
|
|
83
|
+
* it is better to destroy the proxy explicitly.
|
|
79
84
|
*
|
|
80
|
-
* @param
|
|
85
|
+
* @param options
|
|
86
|
+
* @param options.message The error message to print if use is attempted after
|
|
81
87
|
* destroying. Defaults to "Object has already been destroyed".
|
|
88
|
+
*
|
|
82
89
|
*/
|
|
83
|
-
destroy(
|
|
90
|
+
destroy(options?: {
|
|
91
|
+
message?: string;
|
|
92
|
+
destroyRoundtrip?: boolean;
|
|
93
|
+
}): void;
|
|
84
94
|
/**
|
|
85
95
|
* Make a new PyProxy pointing to the same Python object.
|
|
86
96
|
* Useful if the PyProxy is destroyed somewhere else.
|
|
@@ -106,16 +116,17 @@ declare class PyProxyClass {
|
|
|
106
116
|
*/
|
|
107
117
|
pyproxies?: PyProxy[];
|
|
108
118
|
/**
|
|
109
|
-
* If false, ``toJs`` will throw a
|
|
119
|
+
* If false, ``toJs`` will throw a :py:exc:`~pyodide.ffi.ConversionError` rather than
|
|
110
120
|
* producing a ``PyProxy``.
|
|
111
121
|
*/
|
|
112
122
|
create_pyproxies?: boolean;
|
|
113
123
|
/**
|
|
114
124
|
* A function to be called on an iterable of pairs ``[key, value]``. Convert
|
|
115
125
|
* this iterable of pairs to the desired output. For instance,
|
|
116
|
-
*
|
|
117
|
-
* converts it to an
|
|
118
|
-
* it to a
|
|
126
|
+
* :js:func:`Object.fromEntries` would convert the dict to an object,
|
|
127
|
+
* :js:func:`Array.from` converts it to an :js:class:`Array` of pairs, and
|
|
128
|
+
* ``(it) => new Map(it)`` converts it to a :js:class:`Map` (which is the
|
|
129
|
+
* default behavior).
|
|
119
130
|
*/
|
|
120
131
|
dict_converter?: (array: Iterable<[
|
|
121
132
|
key: string,
|
|
@@ -123,7 +134,7 @@ declare class PyProxyClass {
|
|
|
123
134
|
]>) => any;
|
|
124
135
|
/**
|
|
125
136
|
* Optional argument to convert objects with no default conversion. See the
|
|
126
|
-
* documentation of :
|
|
137
|
+
* documentation of :meth:`~pyodide.ffi.to_js`.
|
|
127
138
|
*/
|
|
128
139
|
default_converter?: (obj: PyProxy, convert: (obj: PyProxy) => any, cacheConversion: (obj: PyProxy, result: any) => void) => any;
|
|
129
140
|
}): any;
|
|
@@ -148,28 +159,28 @@ declare class PyProxyClass {
|
|
|
148
159
|
*/
|
|
149
160
|
supportsHas(): this is PyProxyWithHas;
|
|
150
161
|
/**
|
|
151
|
-
* Check whether the PyProxy is iterable
|
|
162
|
+
* Check whether the PyProxy is :term:`iterable`. A Typescript type guard for
|
|
152
163
|
* :any:`PyProxy.[iterator]`.
|
|
153
164
|
*/
|
|
154
165
|
isIterable(): this is PyProxyIterable;
|
|
155
166
|
/**
|
|
156
|
-
* Check whether the PyProxy is iterable
|
|
167
|
+
* Check whether the PyProxy is :term:`iterable`. A Typescript type guard for
|
|
157
168
|
* :any:`PyProxy.next`.
|
|
158
169
|
*/
|
|
159
170
|
isIterator(): this is PyProxyIterator;
|
|
160
171
|
/**
|
|
161
|
-
* Check whether the PyProxy is awaitable
|
|
172
|
+
* Check whether the PyProxy is :ref:`awaitable <asyncio-awaitables>`. A Typescript type guard, if this
|
|
162
173
|
* function returns true Typescript considers the PyProxy to be a ``Promise``.
|
|
163
174
|
*/
|
|
164
175
|
isAwaitable(): this is PyProxyAwaitable;
|
|
165
176
|
/**
|
|
166
|
-
* Check whether the PyProxy
|
|
177
|
+
* Check whether the PyProxy implements the :external:doc:`c-api/buffer`. A Typescript type guard for
|
|
167
178
|
* :any:`PyProxy.getBuffer`.
|
|
168
179
|
*/
|
|
169
180
|
isBuffer(): this is PyProxyBuffer;
|
|
170
181
|
/**
|
|
171
|
-
* Check whether the PyProxy is
|
|
172
|
-
* returns true then Typescript considers the Proxy to be callable of
|
|
182
|
+
* Check whether the PyProxy is :std:term:`callable`. A Typescript type guard,
|
|
183
|
+
* if this returns true then Typescript considers the Proxy to be callable of
|
|
173
184
|
* signature ``(args... : any[]) => PyProxy | number | bigint | string |
|
|
174
185
|
* boolean | undefined``.
|
|
175
186
|
*/
|
|
@@ -180,7 +191,7 @@ declare class PyProxyLengthMethods {
|
|
|
180
191
|
/**
|
|
181
192
|
* The length of the object.
|
|
182
193
|
*
|
|
183
|
-
* Present only if the proxied Python object has a
|
|
194
|
+
* Present only if the proxied Python object has a :meth:`~object.__len__` method.
|
|
184
195
|
*/
|
|
185
196
|
get length(): number;
|
|
186
197
|
}
|
|
@@ -189,7 +200,7 @@ declare class PyProxyGetItemMethods {
|
|
|
189
200
|
/**
|
|
190
201
|
* This translates to the Python code ``obj[key]``.
|
|
191
202
|
*
|
|
192
|
-
* Present only if the proxied Python object has a
|
|
203
|
+
* Present only if the proxied Python object has a :meth:`~object.__getitem__` method.
|
|
193
204
|
*
|
|
194
205
|
* @param key The key to look up.
|
|
195
206
|
* @returns The corresponding value.
|
|
@@ -201,7 +212,7 @@ declare class PyProxySetItemMethods {
|
|
|
201
212
|
/**
|
|
202
213
|
* This translates to the Python code ``obj[key] = value``.
|
|
203
214
|
*
|
|
204
|
-
* Present only if the proxied Python object has a
|
|
215
|
+
* Present only if the proxied Python object has a :meth:`~object.__setitem__` method.
|
|
205
216
|
*
|
|
206
217
|
* @param key The key to set.
|
|
207
218
|
* @param value The value to set it to.
|
|
@@ -210,7 +221,7 @@ declare class PyProxySetItemMethods {
|
|
|
210
221
|
/**
|
|
211
222
|
* This translates to the Python code ``del obj[key]``.
|
|
212
223
|
*
|
|
213
|
-
* Present only if the proxied Python object has a
|
|
224
|
+
* Present only if the proxied Python object has a :meth:`~object.__delitem__` method.
|
|
214
225
|
*
|
|
215
226
|
* @param key The key to delete.
|
|
216
227
|
*/
|
|
@@ -221,7 +232,7 @@ declare class PyProxyContainsMethods {
|
|
|
221
232
|
/**
|
|
222
233
|
* This translates to the Python code ``key in obj``.
|
|
223
234
|
*
|
|
224
|
-
* Present only if the proxied Python object has a
|
|
235
|
+
* Present only if the proxied Python object has a :meth:`~object.__contains__` method.
|
|
225
236
|
*
|
|
226
237
|
* @param key The key to check for.
|
|
227
238
|
* @returns Is ``key`` present?
|
|
@@ -232,11 +243,11 @@ export declare type PyProxyIterable = PyProxy & PyProxyIterableMethods;
|
|
|
232
243
|
declare class PyProxyIterableMethods {
|
|
233
244
|
/**
|
|
234
245
|
* This translates to the Python code ``iter(obj)``. Return an iterator
|
|
235
|
-
* associated to the proxy. See the documentation for
|
|
236
|
-
*
|
|
246
|
+
* associated to the proxy. See the documentation for
|
|
247
|
+
* :js:data:`Symbol.iterator`
|
|
237
248
|
*
|
|
238
|
-
* Present only if the proxied Python object is iterable (i.e.,
|
|
239
|
-
*
|
|
249
|
+
* Present only if the proxied Python object is :std:term:`iterable` (i.e.,
|
|
250
|
+
* has an :meth:`~object.__iter__` method).
|
|
240
251
|
*
|
|
241
252
|
* This will be used implicitly by ``for(let x of proxy){}``.
|
|
242
253
|
*/
|
|
@@ -248,20 +259,19 @@ declare class PyProxyIteratorMethods {
|
|
|
248
259
|
[Symbol.iterator](): this;
|
|
249
260
|
/**
|
|
250
261
|
* This translates to the Python code ``next(obj)``. Returns the next value of
|
|
251
|
-
* the generator. See the documentation for
|
|
252
|
-
*
|
|
253
|
-
* The argument will be sent to the Python generator.
|
|
262
|
+
* the generator. See the documentation for :js:meth:`Generator.next` The
|
|
263
|
+
* argument will be sent to the Python generator.
|
|
254
264
|
*
|
|
255
265
|
* This will be used implicitly by ``for(let x of proxy){}``.
|
|
256
266
|
*
|
|
257
|
-
* Present only if the proxied Python object is
|
|
258
|
-
* has a
|
|
267
|
+
* Present only if the proxied Python object is an :term:`iterator` (i.e.,
|
|
268
|
+
* has a :meth:`~generator.send` or :meth:`~iterator.__next__` method).
|
|
259
269
|
*
|
|
260
270
|
* @param any The value to send to the generator. The value will be assigned
|
|
261
271
|
* as a result of a yield expression.
|
|
262
272
|
* @returns An Object with two properties: ``done`` and ``value``. When the
|
|
263
273
|
* generator yields ``some_value``, ``next`` returns ``{done : false, value :
|
|
264
|
-
* some_value}``. When the generator raises a
|
|
274
|
+
* some_value}``. When the generator raises a :any:`StopIteration`
|
|
265
275
|
* exception, ``next`` returns ``{done : true, value : result_value}``.
|
|
266
276
|
*/
|
|
267
277
|
next(arg?: any): IteratorResult<any, any>;
|
|
@@ -270,30 +280,30 @@ export declare type PyProxyAwaitable = PyProxy & Promise<any>;
|
|
|
270
280
|
export declare type PyProxyCallable = PyProxy & PyProxyCallableMethods & ((...args: any[]) => any);
|
|
271
281
|
declare class PyProxyCallableMethods {
|
|
272
282
|
/**
|
|
273
|
-
* The apply() method calls the specified function with a given this
|
|
274
|
-
* and arguments provided as an array (or an array-like object). Like
|
|
275
|
-
*
|
|
276
|
-
* <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply>`_.
|
|
283
|
+
* The ``apply()`` method calls the specified function with a given this
|
|
284
|
+
* value, and arguments provided as an array (or an array-like object). Like
|
|
285
|
+
* :js:meth:`Function.apply`.
|
|
277
286
|
*
|
|
278
|
-
* Present only if the proxied Python object is callable.
|
|
287
|
+
* Present only if the proxied Python object is :std:term:`callable` (i.e., has a
|
|
288
|
+
* :meth:`~object.__call__` method).
|
|
279
289
|
*
|
|
280
|
-
* @param thisArg The
|
|
281
|
-
* :any:`captureThis` set. If :any:`captureThis` is set, it
|
|
282
|
-
* the first argument to the Python function.
|
|
290
|
+
* @param thisArg The ``this`` argument. Has no effect unless the
|
|
291
|
+
* :any:`PyProxy` has :any:`captureThis` set. If :any:`captureThis` is set, it
|
|
292
|
+
* will be passed as the first argument to the Python function.
|
|
283
293
|
* @param jsargs The array of arguments
|
|
284
294
|
* @returns The result from the function call.
|
|
285
295
|
*/
|
|
286
296
|
apply(thisArg: any, jsargs: any): any;
|
|
287
297
|
/**
|
|
288
298
|
* Calls the function with a given this value and arguments provided
|
|
289
|
-
* individually.
|
|
290
|
-
* function <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call>`_.
|
|
299
|
+
* individually. See :js:meth:`Function.call`.
|
|
291
300
|
*
|
|
292
|
-
* Present only if the proxied Python object is callable.
|
|
301
|
+
* Present only if the proxied Python object is :term:`callable` (i.e., has a
|
|
302
|
+
* :meth:`~object.__call__` method).
|
|
293
303
|
*
|
|
294
|
-
* @param thisArg The ``this`` argument. Has no effect unless the
|
|
295
|
-
* :any:`captureThis` set. If :any:`captureThis` is set, it
|
|
296
|
-
* argument to the Python function.
|
|
304
|
+
* @param thisArg The ``this`` argument. Has no effect unless the
|
|
305
|
+
* :any:`PyProxy` has :any:`captureThis` set. If :any:`captureThis` is set, it
|
|
306
|
+
* will be passed as the first argument to the Python function.
|
|
297
307
|
* @param jsargs The arguments
|
|
298
308
|
* @returns The result from the function call.
|
|
299
309
|
*/
|
|
@@ -301,15 +311,14 @@ declare class PyProxyCallableMethods {
|
|
|
301
311
|
/**
|
|
302
312
|
* Call the function with key word arguments. The last argument must be an
|
|
303
313
|
* object with the keyword arguments. Present only if the proxied Python
|
|
304
|
-
* object is callable.
|
|
314
|
+
* object is :term:`callable` (i.e., has a :meth:`~object.__call__` method).
|
|
305
315
|
*/
|
|
306
316
|
callKwargs(...jsargs: any): any;
|
|
307
317
|
/**
|
|
308
|
-
* The bind() method creates a new function that, when called, has its
|
|
318
|
+
* The ``bind()`` method creates a new function that, when called, has its
|
|
309
319
|
* ``this`` keyword set to the provided value, with a given sequence of
|
|
310
|
-
* arguments preceding any provided when the new function is called. See
|
|
311
|
-
*
|
|
312
|
-
* function <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind>`_.
|
|
320
|
+
* arguments preceding any provided when the new function is called. See
|
|
321
|
+
* :js:meth:`Function.bind`.
|
|
313
322
|
*
|
|
314
323
|
* If the `PyProxy` does not have :any:`captureThis` set, the ``this``
|
|
315
324
|
* parameter will be discarded. If it does have :any:`captureThis` set,
|
|
@@ -317,6 +326,9 @@ declare class PyProxyCallableMethods {
|
|
|
317
326
|
* returned proxy and the original proxy have the same lifetime so destroying
|
|
318
327
|
* either destroys both.
|
|
319
328
|
*
|
|
329
|
+
* Present only if the proxied Python object is :term:`callable` (i.e., has a
|
|
330
|
+
* :meth:`~object.__call__` method)
|
|
331
|
+
*
|
|
320
332
|
* @param thisArg The value to be passed as the ``this`` parameter to the
|
|
321
333
|
* target function ``func`` when the bound function is called.
|
|
322
334
|
* @param jsargs Extra arguments to prepend to arguments provided to the bound
|
|
@@ -333,9 +345,6 @@ declare class PyProxyCallableMethods {
|
|
|
333
345
|
* and the original proxy have the same lifetime so destroying either destroys
|
|
334
346
|
* both.
|
|
335
347
|
*
|
|
336
|
-
* @returns The resulting ``PyProxy``. It has the same lifetime as the
|
|
337
|
-
* original ``PyProxy`` but passes ``this`` to the wrapped function.
|
|
338
|
-
*
|
|
339
348
|
* For example:
|
|
340
349
|
*
|
|
341
350
|
* .. code-block:: js
|
|
@@ -352,6 +361,9 @@ declare class PyProxyCallableMethods {
|
|
|
352
361
|
* obj.f = pyodide.globals.get("f").captureThis();
|
|
353
362
|
* obj.f(); // returns 7
|
|
354
363
|
*
|
|
364
|
+
* @returns The resulting ``PyProxy``. It has the same lifetime as the
|
|
365
|
+
* original ``PyProxy`` but passes ``this`` to the wrapped function.
|
|
366
|
+
*
|
|
355
367
|
*/
|
|
356
368
|
captureThis(): PyProxy;
|
|
357
369
|
}
|
|
@@ -361,31 +373,28 @@ declare class PyProxyBufferMethods {
|
|
|
361
373
|
* Get a view of the buffer data which is usable from JavaScript. No copy is
|
|
362
374
|
* ever performed.
|
|
363
375
|
*
|
|
364
|
-
* Present only if the proxied Python object supports the
|
|
365
|
-
*
|
|
376
|
+
* Present only if the proxied Python object supports the Python
|
|
377
|
+
* :external:doc:`c-api/buffer`.
|
|
366
378
|
*
|
|
367
379
|
* We do not support suboffsets, if the buffer requires suboffsets we will
|
|
368
380
|
* throw an error. JavaScript nd array libraries can't handle suboffsets
|
|
369
381
|
* anyways. In this case, you should use the :any:`toJs` api or copy the
|
|
370
382
|
* buffer to one that doesn't use suboffets (using e.g.,
|
|
371
|
-
*
|
|
372
|
-
* <https://numpy.org/doc/stable/reference/generated/numpy.ascontiguousarray.html>`_).
|
|
383
|
+
* :py:func:`numpy.ascontiguousarray`).
|
|
373
384
|
*
|
|
374
385
|
* If the buffer stores big endian data or half floats, this function will
|
|
375
386
|
* fail without an explicit type argument. For big endian data you can use
|
|
376
|
-
* ``toJs``. `
|
|
377
|
-
*
|
|
378
|
-
* have support for big endian data, so you might want to pass
|
|
379
|
-
* ``'dataview'`` as the type argument in that case.
|
|
387
|
+
* ``toJs``. :js:class:`DataView` has support for big endian data, so you
|
|
388
|
+
* might want to pass ``'dataview'`` as the type argument in that case.
|
|
380
389
|
*
|
|
381
|
-
* @param type The type of the :
|
|
390
|
+
* @param type The type of the :js:attr:`~pyodide.PyBuffer.data` field in the
|
|
382
391
|
* output. Should be one of: ``"i8"``, ``"u8"``, ``"u8clamped"``, ``"i16"``,
|
|
383
392
|
* ``"u16"``, ``"i32"``, ``"u32"``, ``"i32"``, ``"u32"``, ``"i64"``,
|
|
384
393
|
* ``"u64"``, ``"f32"``, ``"f64``, or ``"dataview"``. This argument is
|
|
385
394
|
* optional, if absent ``getBuffer`` will try to determine the appropriate
|
|
386
|
-
* output type based on the buffer
|
|
387
|
-
*
|
|
388
|
-
* @returns :
|
|
395
|
+
* output type based on the buffer format string (see
|
|
396
|
+
* :std:ref:`struct-format-strings`).
|
|
397
|
+
* @returns :js:class:`~pyodide.PyBuffer`
|
|
389
398
|
*/
|
|
390
399
|
getBuffer(type?: string): PyBuffer;
|
|
391
400
|
}
|
|
@@ -393,11 +402,10 @@ export declare type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Arr
|
|
|
393
402
|
export declare type PyProxyDict = PyProxyWithGet & PyProxyWithSet & PyProxyWithHas;
|
|
394
403
|
/**
|
|
395
404
|
* A class to allow access to a Python data buffers from JavaScript. These are
|
|
396
|
-
* produced by :
|
|
397
|
-
* When you are done, release it with the :
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
* <https://docs.python.org/3/c-api/buffer.html>`_ for more information.
|
|
405
|
+
* produced by :js:func:`PyProxy.getBuffer` and cannot be constructed directly.
|
|
406
|
+
* When you are done, release it with the :js:func:`~PyBuffer.release` method.
|
|
407
|
+
* See the Python :external:doc:`c-api/buffer` documentation for more
|
|
408
|
+
* information.
|
|
401
409
|
*
|
|
402
410
|
* To find the element ``x[a_1, ..., a_n]``, you could use the following code:
|
|
403
411
|
*
|
|
@@ -421,19 +429,6 @@ export declare type PyProxyDict = PyProxyWithGet & PyProxyWithSet & PyProxyWithH
|
|
|
421
429
|
* }
|
|
422
430
|
* console.log("entry is", pybuff.data[multiIndexToIndex(pybuff, [2, 0, -1])]);
|
|
423
431
|
*
|
|
424
|
-
* .. admonition:: Contiguity
|
|
425
|
-
* :class: warning
|
|
426
|
-
*
|
|
427
|
-
* If the buffer is not contiguous, the ``data`` TypedArray will contain
|
|
428
|
-
* data that is not part of the buffer. Modifying this data may lead to
|
|
429
|
-
* undefined behavior.
|
|
430
|
-
*
|
|
431
|
-
* .. admonition:: Readonly buffers
|
|
432
|
-
* :class: warning
|
|
433
|
-
*
|
|
434
|
-
* If ``buffer.readonly`` is ``true``, you should not modify the buffer.
|
|
435
|
-
* Modifying a readonly buffer may lead to undefined behavior.
|
|
436
|
-
*
|
|
437
432
|
* .. admonition:: Converting between TypedArray types
|
|
438
433
|
* :class: warning
|
|
439
434
|
*
|
|
@@ -465,59 +460,73 @@ export declare class PyBuffer {
|
|
|
465
460
|
*/
|
|
466
461
|
offset: number;
|
|
467
462
|
/**
|
|
468
|
-
* If the data is readonly, you should not modify it. There is no way
|
|
469
|
-
*
|
|
463
|
+
* If the data is readonly, you should not modify it. There is no way for us
|
|
464
|
+
* to enforce this, but it may cause very weird behavior. See
|
|
465
|
+
* :py:attr:`memoryview.readonly`.
|
|
470
466
|
*/
|
|
471
467
|
readonly: boolean;
|
|
472
468
|
/**
|
|
473
|
-
* The format string for the buffer. See `
|
|
474
|
-
* format
|
|
475
|
-
* <https://docs.python.org/3/library/struct.html#format-strings>`_.
|
|
469
|
+
* The format string for the buffer. See :ref:`struct-format-strings`
|
|
470
|
+
* and :py:attr:`memoryview.format`.
|
|
476
471
|
*/
|
|
477
472
|
format: string;
|
|
478
473
|
/**
|
|
479
|
-
* How large is each entry (in bytes)?
|
|
474
|
+
* How large is each entry (in bytes)? See :any:`memoryview.itemsize`.
|
|
480
475
|
*/
|
|
481
476
|
itemsize: number;
|
|
482
477
|
/**
|
|
483
478
|
* The number of dimensions of the buffer. If ``ndim`` is 0, the buffer
|
|
484
479
|
* represents a single scalar or struct. Otherwise, it represents an
|
|
485
|
-
* array.
|
|
480
|
+
* array. See :py:attr:`memoryview.ndim`.
|
|
486
481
|
*/
|
|
487
482
|
ndim: number;
|
|
488
483
|
/**
|
|
489
484
|
* The total number of bytes the buffer takes up. This is equal to
|
|
490
|
-
* ``buff.data.byteLength``.
|
|
485
|
+
* ``buff.data.byteLength``. See :py:attr:`memoryview.nbytes`.
|
|
491
486
|
*/
|
|
492
487
|
nbytes: number;
|
|
493
488
|
/**
|
|
494
489
|
* The shape of the buffer, that is how long it is in each dimension.
|
|
495
490
|
* The length will be equal to ``ndim``. For instance, a 2x3x4 array
|
|
496
|
-
* would have shape ``[2, 3, 4]``.
|
|
491
|
+
* would have shape ``[2, 3, 4]``. See :py:attr:`memoryview.shape`.
|
|
497
492
|
*/
|
|
498
493
|
shape: number[];
|
|
499
494
|
/**
|
|
500
495
|
* An array of of length ``ndim`` giving the number of elements to skip
|
|
501
496
|
* to get to a new element in each dimension. See the example definition
|
|
502
|
-
* of a ``multiIndexToIndex`` function above.
|
|
497
|
+
* of a ``multiIndexToIndex`` function above. See :py:attr:`memoryview.strides`.
|
|
503
498
|
*/
|
|
504
499
|
strides: number[];
|
|
505
500
|
/**
|
|
506
|
-
* The actual data. A typed array of an appropriate size backed by a
|
|
507
|
-
*
|
|
501
|
+
* The actual data. A typed array of an appropriate size backed by a segment
|
|
502
|
+
* of the WASM memory.
|
|
503
|
+
*
|
|
504
|
+
* The ``type`` argument of :any:`PyProxy.getBuffer` determines which sort of
|
|
505
|
+
* :js:class:`TypedArray` or :js:class:`DataView` to return. By default
|
|
506
|
+
* :any:`PyProxy.getBuffer` will look at the format string to determine the
|
|
507
|
+
* most appropriate option. Most often the result is a :js:class:`Uint8Array`.
|
|
508
|
+
*
|
|
509
|
+
* .. admonition:: Contiguity
|
|
510
|
+
* :class: warning
|
|
511
|
+
*
|
|
512
|
+
* If the buffer is not contiguous, the ``data`` TypedArray will contain
|
|
513
|
+
* data that is not part of the buffer. Modifying this data leads to
|
|
514
|
+
* undefined behavior.
|
|
515
|
+
*
|
|
516
|
+
* .. admonition:: Readonly buffers
|
|
517
|
+
* :class: warning
|
|
518
|
+
*
|
|
519
|
+
* If ``buffer.readonly`` is ``true``, you should not modify the buffer.
|
|
520
|
+
* Modifying a readonly buffer leads to undefined behavior.
|
|
508
521
|
*
|
|
509
|
-
* The ``type`` argument of :any:`PyProxy.getBuffer`
|
|
510
|
-
* determines which sort of ``TypedArray`` this is. By default
|
|
511
|
-
* :any:`PyProxy.getBuffer` will look at the format string to determine the most
|
|
512
|
-
* appropriate option.
|
|
513
522
|
*/
|
|
514
523
|
data: TypedArray;
|
|
515
524
|
/**
|
|
516
|
-
* Is it C contiguous?
|
|
525
|
+
* Is it C contiguous? See :any:`memoryview.c_contiguous`.
|
|
517
526
|
*/
|
|
518
527
|
c_contiguous: boolean;
|
|
519
528
|
/**
|
|
520
|
-
* Is it Fortran contiguous?
|
|
529
|
+
* Is it Fortran contiguous? See :any:`memoryview.f_contiguous`.
|
|
521
530
|
*/
|
|
522
531
|
f_contiguous: boolean;
|
|
523
532
|
/**
|
|
@@ -546,15 +555,38 @@ declare let loadedPackages: {
|
|
|
546
555
|
[key: string]: string;
|
|
547
556
|
};
|
|
548
557
|
declare class PythonError extends Error {
|
|
549
|
-
/**
|
|
558
|
+
/**
|
|
559
|
+
* The address of the error we are wrapping. We may later compare this
|
|
550
560
|
* against sys.last_value.
|
|
551
561
|
* WARNING: we don't own a reference to this pointer, dereferencing it
|
|
552
562
|
* may be a use-after-free error!
|
|
553
563
|
* @private
|
|
554
564
|
*/
|
|
555
565
|
__error_address: number;
|
|
556
|
-
|
|
566
|
+
/**
|
|
567
|
+
* The name of the Python error class, e.g, :any:`RuntimeError` or
|
|
568
|
+
* :any:`KeyError`.
|
|
569
|
+
*/
|
|
570
|
+
type: string;
|
|
571
|
+
constructor(type: string, message: string, error_address: number);
|
|
557
572
|
}
|
|
573
|
+
declare type InFuncType = () => null | undefined | string | ArrayBuffer | ArrayBufferView | number;
|
|
574
|
+
declare function setStdin(options?: {
|
|
575
|
+
stdin?: InFuncType;
|
|
576
|
+
error?: boolean;
|
|
577
|
+
isatty?: boolean;
|
|
578
|
+
autoEOF?: boolean;
|
|
579
|
+
}): void;
|
|
580
|
+
declare function setStdout(options?: {
|
|
581
|
+
batched?: (a: string) => void;
|
|
582
|
+
raw?: (a: number) => void;
|
|
583
|
+
isatty?: boolean;
|
|
584
|
+
}): void;
|
|
585
|
+
declare function setStderr(options?: {
|
|
586
|
+
batched?: (a: string) => void;
|
|
587
|
+
raw?: (a: number) => void;
|
|
588
|
+
isatty?: boolean;
|
|
589
|
+
}): void;
|
|
558
590
|
declare let pyodide_py: PyProxy;
|
|
559
591
|
declare let globals: PyProxy;
|
|
560
592
|
declare function runPython(code: string, options?: {
|
|
@@ -580,7 +612,7 @@ declare function toPy(obj: any, { depth, defaultConverter, }?: {
|
|
|
580
612
|
* Optional argument to convert objects with no default conversion. See the
|
|
581
613
|
* documentation of :any:`JsProxy.to_py`.
|
|
582
614
|
*/
|
|
583
|
-
defaultConverter?: (value: any, converter: (value: any) => any, cacheConversion: (input: any, output: any) =>
|
|
615
|
+
defaultConverter?: (value: any, converter: (value: any) => any, cacheConversion: (input: any, output: any) => void) => any;
|
|
584
616
|
}): any;
|
|
585
617
|
declare function pyimport(mod_name: string): PyProxy;
|
|
586
618
|
declare function unpackArchive(buffer: TypedArray | ArrayBuffer, format: string, options?: {
|
|
@@ -589,11 +621,7 @@ declare function unpackArchive(buffer: TypedArray | ArrayBuffer, format: string,
|
|
|
589
621
|
declare type NativeFS = {
|
|
590
622
|
syncfs: Function;
|
|
591
623
|
};
|
|
592
|
-
declare function mountNativeFS(path: string, fileSystemHandle:
|
|
593
|
-
isSameEntry: Function;
|
|
594
|
-
queryPermission: Function;
|
|
595
|
-
requestPermission: Function;
|
|
596
|
-
}): Promise<NativeFS>;
|
|
624
|
+
declare function mountNativeFS(path: string, fileSystemHandle: FileSystemDirectoryHandle): Promise<NativeFS>;
|
|
597
625
|
declare function setInterruptBuffer(interrupt_buffer: TypedArray): void;
|
|
598
626
|
declare function checkInterrupt(): void;
|
|
599
627
|
export declare type PyodideInterface = {
|
|
@@ -620,10 +648,15 @@ export declare type PyodideInterface = {
|
|
|
620
648
|
registerComlink: typeof registerComlink;
|
|
621
649
|
PythonError: typeof PythonError;
|
|
622
650
|
PyBuffer: typeof PyBuffer;
|
|
651
|
+
setStdin: typeof setStdin;
|
|
652
|
+
setStdout: typeof setStdout;
|
|
653
|
+
setStderr: typeof setStderr;
|
|
623
654
|
};
|
|
624
655
|
declare let FS: any;
|
|
625
656
|
declare let PATH: any;
|
|
626
|
-
declare let ERRNO_CODES:
|
|
657
|
+
declare let ERRNO_CODES: {
|
|
658
|
+
[code: string]: number;
|
|
659
|
+
};
|
|
627
660
|
export declare type Py2JsResult = any;
|
|
628
661
|
/**
|
|
629
662
|
* See documentation for loadPyodide.
|
|
@@ -644,12 +677,6 @@ export declare type ConfigType = {
|
|
|
644
677
|
/**
|
|
645
678
|
* Load the main Pyodide wasm module and initialize it.
|
|
646
679
|
*
|
|
647
|
-
* Only one copy of Pyodide can be loaded in a given JavaScript global scope
|
|
648
|
-
* because Pyodide uses global variables to load packages. If an attempt is made
|
|
649
|
-
* to load a second copy of Pyodide, :any:`loadPyodide` will throw an error.
|
|
650
|
-
* (This can be fixed once `Firefox adopts support for ES6 modules in webworkers
|
|
651
|
-
* <https://bugzilla.mozilla.org/show_bug.cgi?id=1247687>`_.)
|
|
652
|
-
*
|
|
653
680
|
* @returns The :ref:`js-api-pyodide` module.
|
|
654
681
|
* @memberof globalThis
|
|
655
682
|
* @async
|
|
@@ -657,43 +684,58 @@ export declare type ConfigType = {
|
|
|
657
684
|
export declare function loadPyodide(options?: {
|
|
658
685
|
/**
|
|
659
686
|
* The URL from which Pyodide will load the main Pyodide runtime and
|
|
660
|
-
* packages.
|
|
661
|
-
*
|
|
662
|
-
*
|
|
663
|
-
*
|
|
687
|
+
* packages. It is recommended that you leave this unchanged, providing an
|
|
688
|
+
* incorrect value can cause broken behavior.
|
|
689
|
+
*
|
|
690
|
+
* Default: The url that Pyodide is loaded from with the file name
|
|
691
|
+
* (``pyodide.js`` or ``pyodide.mjs``) removed.
|
|
664
692
|
*/
|
|
665
693
|
indexURL?: string;
|
|
666
694
|
/**
|
|
667
|
-
* The URL from which Pyodide will load the Pyodide
|
|
668
|
-
* file.
|
|
669
|
-
*
|
|
695
|
+
* The URL from which Pyodide will load the Pyodide ``repodata.json`` lock
|
|
696
|
+
* file. You can produce custom lock files with :any:`micropip.freeze`.
|
|
697
|
+
* Default: ```${indexURL}/repodata.json```
|
|
670
698
|
*/
|
|
671
699
|
lockFileURL?: string;
|
|
672
700
|
/**
|
|
673
|
-
* The home directory which Pyodide will use inside virtual file system.
|
|
701
|
+
* The home directory which Pyodide will use inside virtual file system.
|
|
702
|
+
* Default: ``"/home/pyodide"``
|
|
674
703
|
*/
|
|
675
704
|
homedir?: string;
|
|
676
|
-
/**
|
|
677
|
-
*
|
|
678
|
-
*
|
|
705
|
+
/**
|
|
706
|
+
* Load the full Python standard library. Setting this to false excludes
|
|
707
|
+
* unvendored modules from the standard library.
|
|
708
|
+
* Default: ``false``
|
|
679
709
|
*/
|
|
680
710
|
fullStdLib?: boolean;
|
|
681
711
|
/**
|
|
682
|
-
* Override the standard input callback. Should ask the user for one line of
|
|
712
|
+
* Override the standard input callback. Should ask the user for one line of
|
|
713
|
+
* input.
|
|
683
714
|
*/
|
|
684
715
|
stdin?: () => string;
|
|
685
716
|
/**
|
|
686
717
|
* Override the standard output callback.
|
|
687
|
-
* Default: undefined
|
|
688
718
|
*/
|
|
689
719
|
stdout?: (msg: string) => void;
|
|
690
720
|
/**
|
|
691
721
|
* Override the standard error output callback.
|
|
692
|
-
* Default: undefined
|
|
693
722
|
*/
|
|
694
723
|
stderr?: (msg: string) => void;
|
|
724
|
+
/**
|
|
725
|
+
* The object that Pyodide will use for the ``js`` module.
|
|
726
|
+
* Default: ``globalThis``
|
|
727
|
+
*/
|
|
695
728
|
jsglobals?: object;
|
|
729
|
+
/**
|
|
730
|
+
* Command line arguments to pass to Python on startup. See `Python command
|
|
731
|
+
* line interface options
|
|
732
|
+
* <https://docs.python.org/3.10/using/cmdline.html#interface-options>`_ for
|
|
733
|
+
* more details. Default: ``[]``
|
|
734
|
+
*/
|
|
696
735
|
args?: string[];
|
|
736
|
+
/**
|
|
737
|
+
* @ignore
|
|
738
|
+
*/
|
|
697
739
|
_node_mounts?: string[];
|
|
698
740
|
}): Promise<PyodideInterface>;
|
|
699
741
|
|