pyodide 0.23.4 → 0.24.0
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/ffi.d.ts +268 -36
- package/package.json +5 -11
- package/pyodide-lock.json +3768 -0
- package/pyodide.asm.js +3 -3
- package/pyodide.asm.wasm +0 -0
- package/pyodide.d.ts +373 -52
- package/pyodide.js +12 -1
- package/pyodide.js.map +7 -1
- package/pyodide.mjs +10 -1
- package/pyodide.mjs.map +7 -1
- package/python_stdlib.zip +0 -0
- package/repodata.json +0 -1
package/pyodide.asm.wasm
CHANGED
|
Binary file
|
package/pyodide.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Generated by dts-bundle-generator v6.
|
|
1
|
+
// Generated by dts-bundle-generator v6.13.0
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
@@ -15,33 +15,6 @@ interface CanvasInterface {
|
|
|
15
15
|
setCanvas3D(canvas: HTMLCanvasElement): void;
|
|
16
16
|
getCanvas3D(): HTMLCanvasElement | undefined;
|
|
17
17
|
}
|
|
18
|
-
declare type PyProxyCache = {
|
|
19
|
-
cacheId: number;
|
|
20
|
-
refcnt: number;
|
|
21
|
-
leaked?: boolean;
|
|
22
|
-
};
|
|
23
|
-
declare type PyProxyProps = {
|
|
24
|
-
/**
|
|
25
|
-
* captureThis tracks whether this should be passed as the first argument to
|
|
26
|
-
* the Python function or not. We keep it false by default. To make a PyProxy
|
|
27
|
-
* where the ``this`` argument is included, call the :js:meth:`captureThis` method.
|
|
28
|
-
*/
|
|
29
|
-
captureThis: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* isBound tracks whether bind has been called
|
|
32
|
-
*/
|
|
33
|
-
isBound: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* the ``this`` value that has been bound to the PyProxy
|
|
36
|
-
*/
|
|
37
|
-
boundThis?: any;
|
|
38
|
-
/**
|
|
39
|
-
* Any extra arguments passed to bind are used for partial function
|
|
40
|
-
* application. These are stored here.
|
|
41
|
-
*/
|
|
42
|
-
boundArgs: any[];
|
|
43
|
-
roundtrip: boolean;
|
|
44
|
-
};
|
|
45
18
|
/** @deprecated Use `import type { PyProxy } from "pyodide/ffi"` instead */
|
|
46
19
|
interface PyProxy {
|
|
47
20
|
[x: string]: any;
|
|
@@ -51,16 +24,9 @@ interface PyProxy {
|
|
|
51
24
|
* JavaScript. See :ref:`type-translations-pyproxy`.
|
|
52
25
|
*/
|
|
53
26
|
declare class PyProxy {
|
|
54
|
-
/** @private */
|
|
55
|
-
$$: {
|
|
56
|
-
ptr: number;
|
|
57
|
-
cache: PyProxyCache;
|
|
58
|
-
destroyed_msg?: string;
|
|
59
|
-
};
|
|
60
|
-
/** @private */
|
|
61
|
-
$$props: PyProxyProps;
|
|
62
27
|
/** @private */
|
|
63
28
|
$$flags: number;
|
|
29
|
+
/** @private */
|
|
64
30
|
static [Symbol.hasInstance](obj: any): obj is PyProxy;
|
|
65
31
|
/**
|
|
66
32
|
* @private
|
|
@@ -452,6 +418,272 @@ declare class PyAsyncGeneratorMethods {
|
|
|
452
418
|
*/
|
|
453
419
|
return(v: any): Promise<IteratorResult<any, any>>;
|
|
454
420
|
}
|
|
421
|
+
declare class PySequence extends PyProxy {
|
|
422
|
+
/** @private */
|
|
423
|
+
static [Symbol.hasInstance](obj: any): obj is PyProxy;
|
|
424
|
+
}
|
|
425
|
+
/** @deprecated Use `import type { PySequence } from "pyodide/ffi"` instead */
|
|
426
|
+
interface PySequence extends PySequenceMethods {
|
|
427
|
+
}
|
|
428
|
+
declare class PySequenceMethods {
|
|
429
|
+
get [Symbol.isConcatSpreadable](): boolean;
|
|
430
|
+
/**
|
|
431
|
+
* See :js:meth:`Array.join`. The :js:meth:`Array.join` method creates and
|
|
432
|
+
* returns a new string by concatenating all of the elements in the
|
|
433
|
+
* :py:class:`~collections.abc.Sequence`.
|
|
434
|
+
*
|
|
435
|
+
* @param separator A string to separate each pair of adjacent elements of the
|
|
436
|
+
* Sequence.
|
|
437
|
+
*
|
|
438
|
+
* @returns A string with all Sequence elements joined.
|
|
439
|
+
*/
|
|
440
|
+
join(separator?: string): string;
|
|
441
|
+
/**
|
|
442
|
+
* See :js:meth:`Array.slice`. The :js:meth:`Array.slice` method returns a
|
|
443
|
+
* shallow copy of a portion of a :py:class:`~collections.abc.Sequence` into a
|
|
444
|
+
* new array object selected from ``start`` to ``stop`` (`stop` not included)
|
|
445
|
+
* @param start Zero-based index at which to start extraction. Negative index
|
|
446
|
+
* counts back from the end of the Sequence.
|
|
447
|
+
* @param stop Zero-based index at which to end extraction. Negative index
|
|
448
|
+
* counts back from the end of the Sequence.
|
|
449
|
+
* @returns A new array containing the extracted elements.
|
|
450
|
+
*/
|
|
451
|
+
slice(start?: number, stop?: number): any;
|
|
452
|
+
/**
|
|
453
|
+
* See :js:meth:`Array.lastIndexOf`. Returns the last index at which a given
|
|
454
|
+
* element can be found in the Sequence, or -1 if it is not present.
|
|
455
|
+
* @param elt Element to locate in the Sequence.
|
|
456
|
+
* @param fromIndex Zero-based index at which to start searching backwards,
|
|
457
|
+
* converted to an integer. Negative index counts back from the end of the
|
|
458
|
+
* Sequence.
|
|
459
|
+
* @returns The last index of the element in the Sequence; -1 if not found.
|
|
460
|
+
*/
|
|
461
|
+
lastIndexOf(elt: any, fromIndex?: number): number;
|
|
462
|
+
/**
|
|
463
|
+
* See :js:meth:`Array.indexOf`. Returns the first index at which a given
|
|
464
|
+
* element can be found in the Sequence, or -1 if it is not present.
|
|
465
|
+
* @param elt Element to locate in the Sequence.
|
|
466
|
+
* @param fromIndex Zero-based index at which to start searching, converted to
|
|
467
|
+
* an integer. Negative index counts back from the end of the Sequence.
|
|
468
|
+
* @returns The first index of the element in the Sequence; -1 if not found.
|
|
469
|
+
*/
|
|
470
|
+
indexOf(elt: any, fromIndex?: number): number;
|
|
471
|
+
/**
|
|
472
|
+
* See :js:meth:`Array.forEach`. Executes a provided function once for each
|
|
473
|
+
* ``Sequence`` element.
|
|
474
|
+
* @param callbackfn A function to execute for each element in the ``Sequence``. Its
|
|
475
|
+
* return value is discarded.
|
|
476
|
+
* @param thisArg A value to use as ``this`` when executing ``callbackFn``.
|
|
477
|
+
*/
|
|
478
|
+
forEach(callbackfn: (elt: any) => void, thisArg?: any): void;
|
|
479
|
+
/**
|
|
480
|
+
* See :js:meth:`Array.map`. Creates a new array populated with the results of
|
|
481
|
+
* calling a provided function on every element in the calling ``Sequence``.
|
|
482
|
+
* @param callbackfn A function to execute for each element in the ``Sequence``. Its
|
|
483
|
+
* return value is added as a single element in the new array.
|
|
484
|
+
* @param thisArg A value to use as ``this`` when executing ``callbackFn``.
|
|
485
|
+
*/
|
|
486
|
+
map(callbackfn: (elt: any, index: number, array: any) => void, thisArg?: any): unknown[];
|
|
487
|
+
/**
|
|
488
|
+
* See :js:meth:`Array.filter`. Creates a shallow copy of a portion of a given
|
|
489
|
+
* ``Sequence``, filtered down to just the elements from the given array that pass
|
|
490
|
+
* the test implemented by the provided function.
|
|
491
|
+
* @param callbackfn A function to execute for each element in the array. It
|
|
492
|
+
* should return a truthy value to keep the element in the resulting array,
|
|
493
|
+
* and a falsy value otherwise.
|
|
494
|
+
* @param thisArg A value to use as ``this`` when executing ``predicate``.
|
|
495
|
+
*/
|
|
496
|
+
filter(predicate: (elt: any, index: number, array: any) => boolean, thisArg?: any): any[];
|
|
497
|
+
/**
|
|
498
|
+
* See :js:meth:`Array.some`. Tests whether at least one element in the
|
|
499
|
+
* ``Sequence`` passes the test implemented by the provided function.
|
|
500
|
+
* @param callbackfn A function to execute for each element in the
|
|
501
|
+
* ``Sequence``. It should return a truthy value to indicate the element
|
|
502
|
+
* passes the test, and a falsy value otherwise.
|
|
503
|
+
* @param thisArg A value to use as ``this`` when executing ``predicate``.
|
|
504
|
+
*/
|
|
505
|
+
some(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): boolean;
|
|
506
|
+
/**
|
|
507
|
+
* See :js:meth:`Array.every`. Tests whether every element in the ``Sequence``
|
|
508
|
+
* passes the test implemented by the provided function.
|
|
509
|
+
* @param callbackfn A function to execute for each element in the
|
|
510
|
+
* ``Sequence``. It should return a truthy value to indicate the element
|
|
511
|
+
* passes the test, and a falsy value otherwise.
|
|
512
|
+
* @param thisArg A value to use as ``this`` when executing ``predicate``.
|
|
513
|
+
*/
|
|
514
|
+
every(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): boolean;
|
|
515
|
+
/**
|
|
516
|
+
* See :js:meth:`Array.reduce`. Executes a user-supplied "reducer" callback
|
|
517
|
+
* function on each element of the Sequence, in order, passing in the return
|
|
518
|
+
* value from the calculation on the preceding element. The final result of
|
|
519
|
+
* running the reducer across all elements of the Sequence is a single value.
|
|
520
|
+
* @param callbackfn A function to execute for each element in the ``Sequence``. Its
|
|
521
|
+
* return value is discarded.
|
|
522
|
+
* @param thisArg A value to use as ``this`` when executing ``callbackfn``.
|
|
523
|
+
*/
|
|
524
|
+
reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any) => any, initialValue?: any): any;
|
|
525
|
+
/**
|
|
526
|
+
* See :js:meth:`Array.reduceRight`. Applies a function against an accumulator
|
|
527
|
+
* and each value of the Sequence (from right to left) to reduce it to a
|
|
528
|
+
* single value.
|
|
529
|
+
* @param callbackfn A function to execute for each element in the Sequence.
|
|
530
|
+
* Its return value is discarded.
|
|
531
|
+
* @param thisArg A value to use as ``this`` when executing ``callbackFn``.
|
|
532
|
+
*/
|
|
533
|
+
reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any) => any, initialValue: any): any;
|
|
534
|
+
/**
|
|
535
|
+
* See :js:meth:`Array.at`. Takes an integer value and returns the item at
|
|
536
|
+
* that index.
|
|
537
|
+
* @param index Zero-based index of the Sequence element to be returned,
|
|
538
|
+
* converted to an integer. Negative index counts back from the end of the
|
|
539
|
+
* Sequence.
|
|
540
|
+
* @returns The element in the Sequence matching the given index.
|
|
541
|
+
*/
|
|
542
|
+
at(index: number): any;
|
|
543
|
+
/**
|
|
544
|
+
* The :js:meth:`Array.concat` method is used to merge two or more arrays.
|
|
545
|
+
* This method does not change the existing arrays, but instead returns a new
|
|
546
|
+
* array.
|
|
547
|
+
* @param rest Arrays and/or values to concatenate into a new array.
|
|
548
|
+
* @returns A new Array instance.
|
|
549
|
+
*/
|
|
550
|
+
concat(...rest: ConcatArray<any>[]): any[];
|
|
551
|
+
/**
|
|
552
|
+
* The :js:meth:`Array.includes` method determines whether a Sequence
|
|
553
|
+
* includes a certain value among its entries, returning true or false as
|
|
554
|
+
* appropriate.
|
|
555
|
+
* @param elt
|
|
556
|
+
* @returns
|
|
557
|
+
*/
|
|
558
|
+
includes(elt: any): any;
|
|
559
|
+
/**
|
|
560
|
+
* The :js:meth:`Array.entries` method returns a new iterator object that
|
|
561
|
+
* contains the key/value pairs for each index in the ``Sequence``.
|
|
562
|
+
* @returns A new iterator object.
|
|
563
|
+
*/
|
|
564
|
+
entries(): IterableIterator<[
|
|
565
|
+
number,
|
|
566
|
+
any
|
|
567
|
+
]>;
|
|
568
|
+
/**
|
|
569
|
+
* The :js:meth:`Array.keys` method returns a new iterator object that
|
|
570
|
+
* contains the keys for each index in the ``Sequence``.
|
|
571
|
+
* @returns A new iterator object.
|
|
572
|
+
*/
|
|
573
|
+
keys(): IterableIterator<number>;
|
|
574
|
+
/**
|
|
575
|
+
* The :js:meth:`Array.values` method returns a new iterator object that
|
|
576
|
+
* contains the values for each index in the ``Sequence``.
|
|
577
|
+
* @returns A new iterator object.
|
|
578
|
+
*/
|
|
579
|
+
values(): IterableIterator<any>;
|
|
580
|
+
/**
|
|
581
|
+
* The :js:meth:`Array.find` method returns the first element in the provided
|
|
582
|
+
* array that satisfies the provided testing function.
|
|
583
|
+
* @param predicate A function to execute for each element in the
|
|
584
|
+
* ``Sequence``. It should return a truthy value to indicate a matching
|
|
585
|
+
* element has been found, and a falsy value otherwise.
|
|
586
|
+
* @param thisArg A value to use as ``this`` when executing ``predicate``.
|
|
587
|
+
* @returns The first element in the ``Sequence`` that satisfies the provided
|
|
588
|
+
* testing function.
|
|
589
|
+
*/
|
|
590
|
+
find(predicate: (value: any, index: number, obj: any[]) => any, thisArg?: any): any;
|
|
591
|
+
/**
|
|
592
|
+
* The :js:meth:`Array.findIndex` method returns the index of the first
|
|
593
|
+
* element in the provided array that satisfies the provided testing function.
|
|
594
|
+
* @param predicate A function to execute for each element in the
|
|
595
|
+
* ``Sequence``. It should return a truthy value to indicate a matching
|
|
596
|
+
* element has been found, and a falsy value otherwise.
|
|
597
|
+
* @param thisArg A value to use as ``this`` when executing ``predicate``.
|
|
598
|
+
* @returns The index of the first element in the ``Sequence`` that satisfies
|
|
599
|
+
* the provided testing function.
|
|
600
|
+
*/
|
|
601
|
+
findIndex(predicate: (value: any, index: number, obj: any[]) => any, thisArg?: any): number;
|
|
602
|
+
}
|
|
603
|
+
declare class PyMutableSequence extends PyProxy {
|
|
604
|
+
/** @private */
|
|
605
|
+
static [Symbol.hasInstance](obj: any): obj is PyProxy;
|
|
606
|
+
}
|
|
607
|
+
/** @deprecated Use `import type { PyMutableSequence } from "pyodide/ffi"` instead */
|
|
608
|
+
interface PyMutableSequence extends PyMutableSequenceMethods {
|
|
609
|
+
}
|
|
610
|
+
declare class PyMutableSequenceMethods {
|
|
611
|
+
/**
|
|
612
|
+
* The :js:meth:`Array.reverse` method reverses a ``MutableSequence`` in
|
|
613
|
+
* place.
|
|
614
|
+
* @returns A reference to the same ``MutableSequence``
|
|
615
|
+
*/
|
|
616
|
+
reverse(): this;
|
|
617
|
+
/**
|
|
618
|
+
* The :js:meth:`Array.sort` method sorts the elements of a
|
|
619
|
+
* ``MutableSequence`` in place.
|
|
620
|
+
* @param compareFn A function that defines the sort order.
|
|
621
|
+
* @returns A reference to the same ``MutableSequence``
|
|
622
|
+
*/
|
|
623
|
+
sort(compareFn?: (a: any, b: any) => number): this;
|
|
624
|
+
/**
|
|
625
|
+
* The :js:meth:`Array.splice` method changes the contents of a
|
|
626
|
+
* ``MutableSequence`` by removing or replacing existing elements and/or
|
|
627
|
+
* adding new elements in place.
|
|
628
|
+
* @param start Zero-based index at which to start changing the
|
|
629
|
+
* ``MutableSequence``.
|
|
630
|
+
* @param deleteCount An integer indicating the number of elements in the
|
|
631
|
+
* ``MutableSequence`` to remove from ``start``.
|
|
632
|
+
* @param items The elements to add to the ``MutableSequence``, beginning from
|
|
633
|
+
* ``start``.
|
|
634
|
+
* @returns An array containing the deleted elements.
|
|
635
|
+
*/
|
|
636
|
+
splice(start: number, deleteCount?: number, ...items: any[]): void;
|
|
637
|
+
/**
|
|
638
|
+
* The :js:meth:`Array.push` method adds the specified elements to the end of
|
|
639
|
+
* a ``MutableSequence``.
|
|
640
|
+
* @param elts The element(s) to add to the end of the ``MutableSequence``.
|
|
641
|
+
* @returns The new length property of the object upon which the method was
|
|
642
|
+
* called.
|
|
643
|
+
*/
|
|
644
|
+
push(...elts: any[]): any;
|
|
645
|
+
/**
|
|
646
|
+
* The :js:meth:`Array.pop` method removes the last element from a
|
|
647
|
+
* ``MutableSequence``.
|
|
648
|
+
* @returns The removed element from the ``MutableSequence``; undefined if the
|
|
649
|
+
* ``MutableSequence`` is empty.
|
|
650
|
+
*/
|
|
651
|
+
pop(): void;
|
|
652
|
+
/**
|
|
653
|
+
* The :js:meth:`Array.shift` method removes the first element from a
|
|
654
|
+
* ``MutableSequence``.
|
|
655
|
+
* @returns The removed element from the ``MutableSequence``; undefined if the
|
|
656
|
+
* ``MutableSequence`` is empty.
|
|
657
|
+
*/
|
|
658
|
+
shift(): void;
|
|
659
|
+
/**
|
|
660
|
+
* The :js:meth:`Array.unshift` method adds the specified elements to the
|
|
661
|
+
* beginning of a ``MutableSequence``.
|
|
662
|
+
* @param elts The elements to add to the front of the ``MutableSequence``.
|
|
663
|
+
* @returns The new length of the ``MutableSequence``.
|
|
664
|
+
*/
|
|
665
|
+
unshift(...elts: any[]): any;
|
|
666
|
+
/**
|
|
667
|
+
* The :js:meth:`Array.copyWithin` method shallow copies part of a
|
|
668
|
+
* ``MutableSequence`` to another location in the same ``MutableSequence``
|
|
669
|
+
* without modifying its length.
|
|
670
|
+
* @param target Zero-based index at which to copy the sequence to.
|
|
671
|
+
* @param start Zero-based index at which to start copying elements from.
|
|
672
|
+
* @param end Zero-based index at which to end copying elements from.
|
|
673
|
+
* @returns The modified ``MutableSequence``.
|
|
674
|
+
*/
|
|
675
|
+
copyWithin(target: number, start?: number, end?: number): any;
|
|
676
|
+
/**
|
|
677
|
+
* The :js:meth:`Array.fill` method changes all elements in an array to a
|
|
678
|
+
* static value, from a start index to an end index.
|
|
679
|
+
* @param value Value to fill the array with.
|
|
680
|
+
* @param start Zero-based index at which to start filling. Default 0.
|
|
681
|
+
* @param end Zero-based index at which to end filling. Default
|
|
682
|
+
* ``list.length``.
|
|
683
|
+
* @returns
|
|
684
|
+
*/
|
|
685
|
+
fill(value: any, start?: number, end?: number): any;
|
|
686
|
+
}
|
|
455
687
|
declare class PyAwaitable extends PyProxy {
|
|
456
688
|
/** @private */
|
|
457
689
|
static [Symbol.hasInstance](obj: any): obj is PyProxy;
|
|
@@ -693,7 +925,7 @@ declare function loadPackage(names: string | PyProxy | Array<string>, options?:
|
|
|
693
925
|
messageCallback?: (message: string) => void;
|
|
694
926
|
errorCallback?: (message: string) => void;
|
|
695
927
|
checkIntegrity?: boolean;
|
|
696
|
-
}
|
|
928
|
+
}): Promise<void>;
|
|
697
929
|
declare class PythonError extends Error {
|
|
698
930
|
/**
|
|
699
931
|
* The address of the error we are wrapping. We may later compare this
|
|
@@ -713,18 +945,21 @@ declare class PythonError extends Error {
|
|
|
713
945
|
declare type InFuncType = () => null | undefined | string | ArrayBuffer | Uint8Array | number;
|
|
714
946
|
declare function setStdin(options?: {
|
|
715
947
|
stdin?: InFuncType;
|
|
948
|
+
read?: (buffer: Uint8Array) => number;
|
|
716
949
|
error?: boolean;
|
|
717
950
|
isatty?: boolean;
|
|
718
951
|
autoEOF?: boolean;
|
|
719
952
|
}): void;
|
|
720
953
|
declare function setStdout(options?: {
|
|
721
|
-
batched?: (
|
|
722
|
-
raw?: (
|
|
954
|
+
batched?: (output: string) => void;
|
|
955
|
+
raw?: (charCode: number) => void;
|
|
956
|
+
write?: (buffer: Uint8Array) => number;
|
|
723
957
|
isatty?: boolean;
|
|
724
958
|
}): void;
|
|
725
959
|
declare function setStderr(options?: {
|
|
726
|
-
batched?: (
|
|
727
|
-
raw?: (
|
|
960
|
+
batched?: (output: string) => void;
|
|
961
|
+
raw?: (charCode: number) => void;
|
|
962
|
+
write?: (buffer: Uint8Array) => number;
|
|
728
963
|
isatty?: boolean;
|
|
729
964
|
}): void;
|
|
730
965
|
declare type NativeFS = {
|
|
@@ -758,6 +993,8 @@ declare class PyodideAPI {
|
|
|
758
993
|
PyBuffer: typeof PyBuffer;
|
|
759
994
|
PyBufferView: typeof PyBufferView;
|
|
760
995
|
PythonError: typeof PythonError;
|
|
996
|
+
PySequence: typeof PySequence;
|
|
997
|
+
PyMutableSequence: typeof PyMutableSequence;
|
|
761
998
|
};
|
|
762
999
|
/** @hidden */
|
|
763
1000
|
static setStdin: typeof setStdin;
|
|
@@ -840,14 +1077,13 @@ declare class PyodideAPI {
|
|
|
840
1077
|
* (optional)
|
|
841
1078
|
* @param options.checkIntegrity If true, check the integrity of the downloaded
|
|
842
1079
|
* packages (default: true)
|
|
843
|
-
* @param errorCallbackDeprecated @ignore
|
|
844
1080
|
* @async
|
|
845
1081
|
*/
|
|
846
1082
|
static loadPackagesFromImports(code: string, options?: {
|
|
847
1083
|
messageCallback?: (message: string) => void;
|
|
848
1084
|
errorCallback?: (message: string) => void;
|
|
849
1085
|
checkIntegrity?: boolean;
|
|
850
|
-
}
|
|
1086
|
+
}): Promise<void>;
|
|
851
1087
|
/**
|
|
852
1088
|
* Runs a string of Python code from JavaScript, using :py:func:`~pyodide.code.eval_code`
|
|
853
1089
|
* to evaluate the code. If the last statement in the Python code is an
|
|
@@ -860,12 +1096,32 @@ declare class PyodideAPI {
|
|
|
860
1096
|
* Defaults to :js:attr:`pyodide.globals`.
|
|
861
1097
|
* @param options.locals An optional Python dictionary to use as the locals.
|
|
862
1098
|
* Defaults to the same as ``globals``.
|
|
1099
|
+
* @param options.filename An optional string to use as the filename. Defaults
|
|
1100
|
+
* to "<exec>". If the filename does not start with "<" and end with ">",
|
|
1101
|
+
* the source code will be added to the Python linecache and tracebacks
|
|
1102
|
+
* will show source lines.
|
|
863
1103
|
* @returns The result of the Python code translated to JavaScript. See the
|
|
864
1104
|
* documentation for :py:func:`~pyodide.code.eval_code` for more info.
|
|
1105
|
+
* @example
|
|
1106
|
+
* async function main(){
|
|
1107
|
+
* const pyodide = await loadPyodide();
|
|
1108
|
+
* console.log(pyodide.runPython("1 + 2"));
|
|
1109
|
+
* // 3
|
|
1110
|
+
*
|
|
1111
|
+
* const globals = pyodide.toPy({ x: 3 });
|
|
1112
|
+
* console.log(pyodide.runPython("x + 1", { globals }));
|
|
1113
|
+
* // 4
|
|
1114
|
+
*
|
|
1115
|
+
* const locals = pyodide.toPy({ arr: [1, 2, 3] });
|
|
1116
|
+
* console.log(pyodide.runPython("sum(arr)", { locals }));
|
|
1117
|
+
* // 6
|
|
1118
|
+
* }
|
|
1119
|
+
* main();
|
|
865
1120
|
*/
|
|
866
1121
|
static runPython(code: string, options?: {
|
|
867
1122
|
globals?: PyProxy;
|
|
868
1123
|
locals?: PyProxy;
|
|
1124
|
+
filename?: string;
|
|
869
1125
|
}): any;
|
|
870
1126
|
/**
|
|
871
1127
|
* Run a Python code string with top level await using
|
|
@@ -880,7 +1136,7 @@ declare class PyodideAPI {
|
|
|
880
1136
|
*
|
|
881
1137
|
* let result = await pyodide.runPythonAsync(`
|
|
882
1138
|
* from js import fetch
|
|
883
|
-
* response = await fetch("./
|
|
1139
|
+
* response = await fetch("./pyodide-lock.json")
|
|
884
1140
|
* packages = await response.json()
|
|
885
1141
|
* # If final statement is an expression, its value is returned to JavaScript
|
|
886
1142
|
* len(packages.packages.object_keys())
|
|
@@ -900,12 +1156,17 @@ declare class PyodideAPI {
|
|
|
900
1156
|
* Defaults to :js:attr:`pyodide.globals`.
|
|
901
1157
|
* @param options.locals An optional Python dictionary to use as the locals.
|
|
902
1158
|
* Defaults to the same as ``globals``.
|
|
1159
|
+
* @param options.filename An optional string to use as the filename. Defaults
|
|
1160
|
+
* to "<exec>". If the filename does not start with "<" and end with ">",
|
|
1161
|
+
* the source code will be added to the Python linecache and tracebacks
|
|
1162
|
+
* will show source lines.
|
|
903
1163
|
* @returns The result of the Python code translated to JavaScript.
|
|
904
1164
|
* @async
|
|
905
1165
|
*/
|
|
906
1166
|
static runPythonAsync(code: string, options?: {
|
|
907
1167
|
globals?: PyProxy;
|
|
908
1168
|
locals?: PyProxy;
|
|
1169
|
+
filename?: string;
|
|
909
1170
|
}): Promise<any>;
|
|
910
1171
|
/**
|
|
911
1172
|
* Registers the JavaScript object ``module`` as a JavaScript module named
|
|
@@ -1079,10 +1340,16 @@ declare class PyodideAPI {
|
|
|
1079
1340
|
* @deprecated
|
|
1080
1341
|
*/
|
|
1081
1342
|
static get PythonError(): typeof PythonError;
|
|
1343
|
+
/**
|
|
1344
|
+
* Turn on or off debug mode. In debug mode, some error messages are improved
|
|
1345
|
+
* at a performance cost.
|
|
1346
|
+
* @param debug If true, turn debug mode on. If false, turn debug mode off.
|
|
1347
|
+
* @returns The old value of the debug flag.
|
|
1348
|
+
*/
|
|
1349
|
+
static setDebug(debug: boolean): boolean;
|
|
1082
1350
|
}
|
|
1083
1351
|
/** @hidetype */
|
|
1084
1352
|
export declare type PyodideInterface = typeof PyodideAPI;
|
|
1085
|
-
export declare type Py2JsResult = any;
|
|
1086
1353
|
/**
|
|
1087
1354
|
* See documentation for loadPyodide.
|
|
1088
1355
|
* @private
|
|
@@ -1100,6 +1367,10 @@ export declare type ConfigType = {
|
|
|
1100
1367
|
jsglobals?: object;
|
|
1101
1368
|
args: string[];
|
|
1102
1369
|
_node_mounts: string[];
|
|
1370
|
+
env: {
|
|
1371
|
+
[key: string]: string;
|
|
1372
|
+
};
|
|
1373
|
+
packages: string[];
|
|
1103
1374
|
};
|
|
1104
1375
|
/**
|
|
1105
1376
|
* Load the main Pyodide wasm module and initialize it.
|
|
@@ -1107,6 +1378,16 @@ export declare type ConfigType = {
|
|
|
1107
1378
|
* @returns The :ref:`js-api-pyodide` module.
|
|
1108
1379
|
* @memberof globalThis
|
|
1109
1380
|
* @async
|
|
1381
|
+
* @example
|
|
1382
|
+
* async function main() {
|
|
1383
|
+
* const pyodide = await loadPyodide({
|
|
1384
|
+
* fullStdLib: true,
|
|
1385
|
+
* homedir: "/pyodide",
|
|
1386
|
+
* stdout: (msg) => console.log(`Pyodide: ${msg}`),
|
|
1387
|
+
* });
|
|
1388
|
+
* console.log("Loaded Pyodide");
|
|
1389
|
+
* }
|
|
1390
|
+
* main();
|
|
1110
1391
|
*/
|
|
1111
1392
|
export declare function loadPyodide(options?: {
|
|
1112
1393
|
/**
|
|
@@ -1119,13 +1400,23 @@ export declare function loadPyodide(options?: {
|
|
|
1119
1400
|
*/
|
|
1120
1401
|
indexURL?: string;
|
|
1121
1402
|
/**
|
|
1403
|
+
* The file path where packages will be cached in node. If a package
|
|
1404
|
+
* exists in ``packageCacheDir`` it is loaded from there, otherwise it is
|
|
1405
|
+
* downloaded from the JsDelivr CDN and then cached into ``packageCacheDir``.
|
|
1406
|
+
* Only applies when running in node; ignored in browsers.
|
|
1407
|
+
*
|
|
1408
|
+
* Default: same as indexURL
|
|
1409
|
+
*/
|
|
1410
|
+
packageCacheDir?: string;
|
|
1411
|
+
/**
|
|
1412
|
+
* The URL from which Pyodide will load the Pyodide ``pyodide-lock.json`` lock
|
|
1122
1413
|
* file. You can produce custom lock files with :py:func:`micropip.freeze`.
|
|
1123
|
-
* Default: ```${indexURL}/
|
|
1414
|
+
* Default: ```${indexURL}/pyodide-lock.json```
|
|
1124
1415
|
*/
|
|
1125
1416
|
lockFileURL?: string;
|
|
1126
1417
|
/**
|
|
1127
1418
|
* The home directory which Pyodide will use inside virtual file system.
|
|
1128
|
-
*
|
|
1419
|
+
* This is deprecated, use ``{env: {HOME : some_dir}}`` instead.
|
|
1129
1420
|
*/
|
|
1130
1421
|
homedir?: string;
|
|
1131
1422
|
/**
|
|
@@ -1136,23 +1427,32 @@ export declare function loadPyodide(options?: {
|
|
|
1136
1427
|
fullStdLib?: boolean;
|
|
1137
1428
|
/**
|
|
1138
1429
|
* The URL from which to load the standard library ``python_stdlib.zip``
|
|
1139
|
-
* file. This URL includes the most of the Python
|
|
1430
|
+
* file. This URL includes the most of the Python standard library. Some
|
|
1140
1431
|
* stdlib modules were unvendored, and can be loaded separately
|
|
1141
|
-
* with ``fullStdLib
|
|
1432
|
+
* with ``fullStdLib: true`` option or by their package name.
|
|
1142
1433
|
* Default: ```${indexURL}/python_stdlib.zip```
|
|
1143
1434
|
*/
|
|
1144
1435
|
stdLibURL?: string;
|
|
1145
1436
|
/**
|
|
1146
1437
|
* Override the standard input callback. Should ask the user for one line of
|
|
1147
|
-
* input.
|
|
1438
|
+
* input. The :js:func:`pyodide.setStdin` function is more flexible and
|
|
1439
|
+
* should be preferred.
|
|
1148
1440
|
*/
|
|
1149
1441
|
stdin?: () => string;
|
|
1150
1442
|
/**
|
|
1151
|
-
* Override the standard output callback.
|
|
1443
|
+
* Override the standard output callback. The :js:func:`pyodide.setStdout`
|
|
1444
|
+
* function is more flexible and should be preferred in most cases, but
|
|
1445
|
+
* depending on the ``args`` passed to ``loadPyodide``, Pyodide may write to
|
|
1446
|
+
* stdout on startup, which can only be controlled by passing a custom
|
|
1447
|
+
* ``stdout`` function.
|
|
1152
1448
|
*/
|
|
1153
1449
|
stdout?: (msg: string) => void;
|
|
1154
1450
|
/**
|
|
1155
|
-
* Override the standard error output callback.
|
|
1451
|
+
* Override the standard error output callback. The
|
|
1452
|
+
* :js:func:`pyodide.setStderr` function is more flexible and should be
|
|
1453
|
+
* preferred in most cases, but depending on the ``args`` passed to
|
|
1454
|
+
* ``loadPyodide``, Pyodide may write to stdout on startup, which can only
|
|
1455
|
+
* be controlled by passing a custom ``stdout`` function.
|
|
1156
1456
|
*/
|
|
1157
1457
|
stderr?: (msg: string) => void;
|
|
1158
1458
|
/**
|
|
@@ -1167,6 +1467,27 @@ export declare function loadPyodide(options?: {
|
|
|
1167
1467
|
* more details. Default: ``[]``
|
|
1168
1468
|
*/
|
|
1169
1469
|
args?: string[];
|
|
1470
|
+
/**
|
|
1471
|
+
* Environment variables to pass to Python. This can be accessed inside of
|
|
1472
|
+
* Python at runtime via :py:data:`os.environ`. Certain environment variables change
|
|
1473
|
+
* the way that Python loads:
|
|
1474
|
+
* https://docs.python.org/3.10/using/cmdline.html#environment-variables
|
|
1475
|
+
* Default: ``{}``.
|
|
1476
|
+
* If ``env.HOME`` is undefined, it will be set to a default value of
|
|
1477
|
+
* ``"/home/pyodide"``
|
|
1478
|
+
*/
|
|
1479
|
+
env?: {
|
|
1480
|
+
[key: string]: string;
|
|
1481
|
+
};
|
|
1482
|
+
/**
|
|
1483
|
+
* A list of packages to load as Pyodide is initializing.
|
|
1484
|
+
*
|
|
1485
|
+
* This is the same as loading the packages with
|
|
1486
|
+
* :js:func:`pyodide.loadPackage` after Pyodide is loaded except using the
|
|
1487
|
+
* ``packages`` option is more efficient because the packages are downloaded
|
|
1488
|
+
* while Pyodide bootstraps itself.
|
|
1489
|
+
*/
|
|
1490
|
+
packages?: string[];
|
|
1170
1491
|
/**
|
|
1171
1492
|
* @ignore
|
|
1172
1493
|
*/
|