pyodide 0.24.1 → 0.25.0-alpha.2

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 CHANGED
@@ -50,30 +50,6 @@ undefined
50
50
  2
51
51
  ```
52
52
 
53
- ### Node.js versions <0.17
54
-
55
- - `Node.js` versions 14.x and 16.x: to use certain features of Pyodide you
56
- need to manually install `node-fetch`, e.g. by doing `npm install node-fetch`.
57
-
58
- - `Node.js v14.x`: you need to pass the option `--experimental-wasm-bigint`
59
- when starting Node. Note that this flag is not documented by `node --help`
60
- and moreover, if you pass `--experimental-wasm-bigint` to node >14 it is an
61
- error:
62
-
63
- ```
64
- $ node -v
65
- v14.20.0
66
-
67
- $ node --experimental-wasm-bigint hello_python.js
68
- warning: no blob constructor, cannot create blobs with mimetypes
69
- warning: no BlobBuilder
70
- Loading distutils
71
- Loaded distutils
72
- Python says that 1+1= 2
73
- ```
74
-
75
- See the [documentation](https://pyodide.org/en/stable/) fore more details.
76
-
77
53
  ## Details
78
54
 
79
55
  The JavaScript code in this package is responsible for the following tasks:
package/console.html CHANGED
@@ -90,6 +90,8 @@
90
90
  }
91
91
  }
92
92
  const { loadPyodide } = await import(indexURL + "pyodide.mjs");
93
+ // to facilitate debugging
94
+ globalThis.loadPyodide = loadPyodide;
93
95
 
94
96
  let term;
95
97
  globalThis.pyodide = await loadPyodide({
package/ffi.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Generated by dts-bundle-generator v6.13.0
1
+ // Generated by dts-bundle-generator v8.1.1
2
2
 
3
3
  interface PyProxy {
4
4
  [x: string]: any;
@@ -13,11 +13,10 @@ declare class PyProxy {
13
13
  /** @private */
14
14
  static [Symbol.hasInstance](obj: any): obj is PyProxy;
15
15
  /**
16
- * @private
17
16
  * @hideconstructor
18
17
  */
19
18
  constructor();
20
- /** @private */
19
+ /** @hidden */
21
20
  get [Symbol.toStringTag](): string;
22
21
  /**
23
22
  * The name of the type of the object.
@@ -35,6 +34,10 @@ declare class PyProxy {
35
34
  *
36
35
  */
37
36
  get type(): string;
37
+ /**
38
+ * Returns `str(o)` (unless `pyproxyToStringRepr: true` was passed to
39
+ * :js:func:`loadPyodide` in which case it will return `repr(o)`)
40
+ */
38
41
  toString(): string;
39
42
  /**
40
43
  * Destroy the :js:class:`~pyodide.ffi.PyProxy`. This will release the memory. Any further attempt
@@ -413,6 +416,10 @@ declare class PyAsyncGeneratorMethods {
413
416
  */
414
417
  return(v: any): Promise<IteratorResult<any, any>>;
415
418
  }
419
+ /**
420
+ * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object is an
421
+ * :py:class:`~collections.abc.Sequence` (i.e., a :py:class:`list`)
422
+ */
416
423
  declare class PySequence extends PyProxy {
417
424
  /** @private */
418
425
  static [Symbol.hasInstance](obj: any): obj is PyProxy;
@@ -420,6 +427,7 @@ declare class PySequence extends PyProxy {
420
427
  interface PySequence extends PySequenceMethods {
421
428
  }
422
429
  declare class PySequenceMethods {
430
+ /** @hidden */
423
431
  get [Symbol.isConcatSpreadable](): boolean;
424
432
  /**
425
433
  * See :js:meth:`Array.join`. The :js:meth:`Array.join` method creates and
@@ -477,7 +485,7 @@ declare class PySequenceMethods {
477
485
  * return value is added as a single element in the new array.
478
486
  * @param thisArg A value to use as ``this`` when executing ``callbackFn``.
479
487
  */
480
- map(callbackfn: (elt: any, index: number, array: any) => void, thisArg?: any): unknown[];
488
+ map<U>(callbackfn: (elt: any, index: number, array: any) => U, thisArg?: any): U[];
481
489
  /**
482
490
  * See :js:meth:`Array.filter`. Creates a shallow copy of a portion of a given
483
491
  * ``Sequence``, filtered down to just the elements from the given array that pass
@@ -594,6 +602,10 @@ declare class PySequenceMethods {
594
602
  */
595
603
  findIndex(predicate: (value: any, index: number, obj: any[]) => any, thisArg?: any): number;
596
604
  }
605
+ /**
606
+ * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object is an
607
+ * :py:class:`~collections.abc.MutableSequence` (i.e., a :py:class:`list`)
608
+ */
597
609
  declare class PyMutableSequence extends PyProxy {
598
610
  /** @private */
599
611
  static [Symbol.hasInstance](obj: any): obj is PyProxy;
@@ -602,68 +614,68 @@ interface PyMutableSequence extends PyMutableSequenceMethods {
602
614
  }
603
615
  declare class PyMutableSequenceMethods {
604
616
  /**
605
- * The :js:meth:`Array.reverse` method reverses a ``MutableSequence`` in
617
+ * The :js:meth:`Array.reverse` method reverses a :js:class:`PyMutableSequence` in
606
618
  * place.
607
- * @returns A reference to the same ``MutableSequence``
619
+ * @returns A reference to the same :js:class:`PyMutableSequence`
608
620
  */
609
- reverse(): this;
621
+ reverse(): PyMutableSequence;
610
622
  /**
611
623
  * The :js:meth:`Array.sort` method sorts the elements of a
612
- * ``MutableSequence`` in place.
624
+ * :js:class:`PyMutableSequence` in place.
613
625
  * @param compareFn A function that defines the sort order.
614
- * @returns A reference to the same ``MutableSequence``
626
+ * @returns A reference to the same :js:class:`PyMutableSequence`
615
627
  */
616
- sort(compareFn?: (a: any, b: any) => number): this;
628
+ sort(compareFn?: (a: any, b: any) => number): PyMutableSequence;
617
629
  /**
618
630
  * The :js:meth:`Array.splice` method changes the contents of a
619
- * ``MutableSequence`` by removing or replacing existing elements and/or
631
+ * :js:class:`PyMutableSequence` by removing or replacing existing elements and/or
620
632
  * adding new elements in place.
621
633
  * @param start Zero-based index at which to start changing the
622
- * ``MutableSequence``.
634
+ * :js:class:`PyMutableSequence`.
623
635
  * @param deleteCount An integer indicating the number of elements in the
624
- * ``MutableSequence`` to remove from ``start``.
625
- * @param items The elements to add to the ``MutableSequence``, beginning from
636
+ * :js:class:`PyMutableSequence` to remove from ``start``.
637
+ * @param items The elements to add to the :js:class:`PyMutableSequence`, beginning from
626
638
  * ``start``.
627
639
  * @returns An array containing the deleted elements.
628
640
  */
629
- splice(start: number, deleteCount?: number, ...items: any[]): void;
641
+ splice(start: number, deleteCount?: number, ...items: any[]): any[];
630
642
  /**
631
643
  * The :js:meth:`Array.push` method adds the specified elements to the end of
632
- * a ``MutableSequence``.
633
- * @param elts The element(s) to add to the end of the ``MutableSequence``.
644
+ * a :js:class:`PyMutableSequence`.
645
+ * @param elts The element(s) to add to the end of the :js:class:`PyMutableSequence`.
634
646
  * @returns The new length property of the object upon which the method was
635
647
  * called.
636
648
  */
637
649
  push(...elts: any[]): any;
638
650
  /**
639
651
  * The :js:meth:`Array.pop` method removes the last element from a
640
- * ``MutableSequence``.
641
- * @returns The removed element from the ``MutableSequence``; undefined if the
642
- * ``MutableSequence`` is empty.
652
+ * :js:class:`PyMutableSequence`.
653
+ * @returns The removed element from the :js:class:`PyMutableSequence`; undefined if the
654
+ * :js:class:`PyMutableSequence` is empty.
643
655
  */
644
- pop(): void;
656
+ pop(): any;
645
657
  /**
646
658
  * The :js:meth:`Array.shift` method removes the first element from a
647
- * ``MutableSequence``.
648
- * @returns The removed element from the ``MutableSequence``; undefined if the
649
- * ``MutableSequence`` is empty.
659
+ * :js:class:`PyMutableSequence`.
660
+ * @returns The removed element from the :js:class:`PyMutableSequence`; undefined if the
661
+ * :js:class:`PyMutableSequence` is empty.
650
662
  */
651
- shift(): void;
663
+ shift(): any;
652
664
  /**
653
665
  * The :js:meth:`Array.unshift` method adds the specified elements to the
654
- * beginning of a ``MutableSequence``.
655
- * @param elts The elements to add to the front of the ``MutableSequence``.
656
- * @returns The new length of the ``MutableSequence``.
666
+ * beginning of a :js:class:`PyMutableSequence`.
667
+ * @param elts The elements to add to the front of the :js:class:`PyMutableSequence`.
668
+ * @returns The new length of the :js:class:`PyMutableSequence`.
657
669
  */
658
670
  unshift(...elts: any[]): any;
659
671
  /**
660
672
  * The :js:meth:`Array.copyWithin` method shallow copies part of a
661
- * ``MutableSequence`` to another location in the same ``MutableSequence``
673
+ * :js:class:`PyMutableSequence` to another location in the same :js:class:`PyMutableSequence`
662
674
  * without modifying its length.
663
675
  * @param target Zero-based index at which to copy the sequence to.
664
676
  * @param start Zero-based index at which to start copying elements from.
665
677
  * @param end Zero-based index at which to end copying elements from.
666
- * @returns The modified ``MutableSequence``.
678
+ * @returns The modified :js:class:`PyMutableSequence`.
667
679
  */
668
680
  copyWithin(target: number, start?: number, end?: number): any;
669
681
  /**
@@ -689,7 +701,7 @@ interface PyAwaitable extends Promise<any> {
689
701
  }
690
702
  /**
691
703
  * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object is
692
- * :std:term:`callable` (i.e., has an :py:meth:`~operator.__call__` method).
704
+ * :std:term:`callable` (i.e., has an :py:meth:`~object.__call__` method).
693
705
  */
694
706
  declare class PyCallable extends PyProxy {
695
707
  /** @private */
@@ -729,6 +741,7 @@ declare class PyCallableMethods {
729
741
  * object with the keyword arguments.
730
742
  */
731
743
  callKwargs(...jsargs: any): any;
744
+ callSyncifying(...jsargs: any): Promise<any>;
732
745
  /**
733
746
  * The ``bind()`` method creates a new function that, when called, has its
734
747
  * ``this`` keyword set to the provided value, with a given sequence of
@@ -819,7 +832,6 @@ declare class PyBufferMethods {
819
832
  */
820
833
  getBuffer(type?: string): PyBufferView;
821
834
  }
822
- export declare type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
823
835
  /**
824
836
  * A :js:class:`~pyodide.ffi.PyProxy` whose proxied Python object is a :py:class:`dict`.
825
837
  */
@@ -960,9 +972,7 @@ declare class PyBufferView {
960
972
  * Is it Fortran contiguous? See :py:attr:`memoryview.f_contiguous`.
961
973
  */
962
974
  f_contiguous: boolean;
963
- /** @private */
964
975
  _released: boolean;
965
- /** @private */
966
976
  _view_ptr: number;
967
977
  /** @private */
968
978
  constructor();
@@ -971,10 +981,11 @@ declare class PyBufferView {
971
981
  */
972
982
  release(): void;
973
983
  }
984
+ export type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
974
985
  /**
975
986
  * A JavaScript error caused by a Python exception.
976
987
  *
977
- * In order to reduce the risk of large memory leaks, the :py:exc:`PythonError`
988
+ * In order to reduce the risk of large memory leaks, the :js:class:`PythonError`
978
989
  * contains no reference to the Python exception that caused it. You can find
979
990
  * the actual Python exception that caused this error as
980
991
  * :py:data:`sys.last_value`.
@@ -1037,4 +1048,4 @@ declare const ffi: {
1037
1048
  };
1038
1049
 
1039
1050
  export type {};
1040
- export type {PyAsyncGenerator, PyAsyncIterable, PyAsyncIterator, PyAwaitable, PyBuffer, PyBufferView, PyCallable, PyDict, PyGenerator, PyIterable, PyIterator, PyProxy, PyProxyWithGet, PyProxyWithHas, PyProxyWithLength, PyProxyWithSet, PythonError};
1051
+ export type {PyAsyncGenerator, PyAsyncIterable, PyAsyncIterator, PyAwaitable, PyBuffer, PyBufferView, PyCallable, PyDict, PyGenerator, PyIterable, PyIterator, PyMutableSequence, PyProxy, PyProxyWithGet, PyProxyWithHas, PyProxyWithLength, PyProxyWithSet, PySequence, PythonError};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pyodide",
3
- "version": "0.24.1",
3
+ "version": "0.25.0-alpha.2",
4
4
  "description": "The Pyodide JavaScript package",
5
5
  "keywords": [
6
6
  "python",
@@ -17,15 +17,14 @@
17
17
  "license": "Apache-2.0",
18
18
  "devDependencies": {
19
19
  "@types/assert": "^1.5.6",
20
- "@types/emscripten": "^1.39.5",
21
20
  "@types/expect": "^24.3.0",
22
21
  "@types/mocha": "^9.1.0",
23
- "@types/node": "^17.0.25",
22
+ "@types/node": "^20.8.4",
24
23
  "@types/ws": "^8.5.3",
25
24
  "chai": "^4.3.6",
26
25
  "chai-as-promised": "^7.1.1",
27
26
  "cross-env": "^7.0.3",
28
- "dts-bundle-generator": "^6.7.0",
27
+ "dts-bundle-generator": "^8.1.1",
29
28
  "error-stack-parser": "^2.1.4",
30
29
  "esbuild": "^0.17.12",
31
30
  "express": "^4.17.3",
@@ -35,8 +34,9 @@
35
34
  "prettier": "^2.2.1",
36
35
  "ts-mocha": "^9.0.2",
37
36
  "tsd": "^0.24.1",
38
- "typedoc": "^0.22.15",
39
- "typescript": "^4.6.4"
37
+ "typedoc": "^0.25.1",
38
+ "typescript": "^4.6.4",
39
+ "wabt": "^1.0.32"
40
40
  },
41
41
  "main": "pyodide.js",
42
42
  "exports": {
@@ -45,6 +45,9 @@
45
45
  "import": "./pyodide.mjs",
46
46
  "types": "./pyodide.d.ts"
47
47
  },
48
+ "./ffi": {
49
+ "types": "./ffi.d.ts"
50
+ },
48
51
  "./pyodide.asm.wasm": "./pyodide.asm.wasm",
49
52
  "./pyodide.asm.js": "./pyodide.asm.js",
50
53
  "./python_stdlib.zip": "./python_stdlib.zip",
@@ -76,8 +79,9 @@
76
79
  "ws": false
77
80
  },
78
81
  "scripts": {
82
+ "build": "tsc --noEmit && node esbuild.config.mjs",
79
83
  "test": "npm-run-all test:*",
80
- "test:unit": "cross-env TEST_NODE=1 ts-mocha -p tsconfig.test.json test/unit/**/*.test.ts",
84
+ "test:unit": "cross-env TEST_NODE=1 ts-mocha --node-option=experimental-loader=./test/loader.mjs --node-option=experimental-wasm-stack-switching -p tsconfig.test.json test/unit/**/*.test.*",
81
85
  "test:node": "cross-env TEST_NODE=1 mocha test/integration/**/*.test.js",
82
86
  "test:browser": "mocha test/integration/**/*.test.js",
83
87
  "tsc": "tsc --noEmit",
@@ -94,9 +98,6 @@
94
98
  "pyodide",
95
99
  "page",
96
100
  "chai"
97
- ],
98
- "file": [
99
- "test/conftest.js"
100
101
  ]
101
102
  },
102
103
  "nyc": {