pyodide 0.21.0-alpha.1 → 0.21.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/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # Pyodide JavaScript package
2
+
3
+ <a href="https://www.npmjs.com/package/pyodide"><img src="https://img.shields.io/npm/v/pyodide" alt="npm"></a>
4
+
5
+ ## Usage
6
+
7
+ Download and extract Pyodide packages from [Github
8
+ releases](https://github.com/pyodide/pyodide/releases)
9
+ (`pyodide-build-*.tar.bz2`). The version of the release needs to match exactly the version of this package.
10
+
11
+ Then you can load Pyodide in Node.js as follows,
12
+
13
+ ```js
14
+ // hello_python.js
15
+ const { loadPyodide } = require("pyodide");
16
+
17
+ async function hello_python() {
18
+ let pyodide = await loadPyodide({
19
+ indexURL: "<pyodide artifacts folder>",
20
+ });
21
+ return pyodide.runPythonAsync("1+1");
22
+ }
23
+
24
+ hello_python().then((result) => {
25
+ console.log("Python says that 1+1 =", result);
26
+ });
27
+ ```
28
+
29
+ ```
30
+ $ node hello_python.js
31
+ Loading distutils
32
+ Loaded distutils
33
+ Python initialization complete
34
+ Python says that 1+1= 2
35
+ ```
36
+
37
+ Or you can use the REPL. To start the Node.js REPL with support for top level
38
+ await, use `node --experimental-repl-await`:
39
+
40
+ ```
41
+ $ node --experimental-repl-await
42
+ Welcome to Node.js v18.5.0.
43
+ Type ".help" for more information.
44
+ > const { loadPyodide } = require("pyodide");
45
+ undefined
46
+ > let pyodide = await loadPyodide();
47
+ Loading distutils
48
+ Loaded distutils
49
+ Python initialization complete
50
+ undefined
51
+ > await pyodide.runPythonAsync("1+1");
52
+ 2
53
+ ```
54
+
55
+ ### Node.js versions <0.17
56
+
57
+ - `Node.js` versions 14.x and 16.x: to use certain features of Pyodide you
58
+ need to manually install `node-fetch`, e.g. by doing `npm install node-fetch`.
59
+
60
+ - `Node.js v14.x`: you need to pass the option `--experimental-wasm-bigint`
61
+ when starting Node. Note that this flag is not documented by `node --help`
62
+ and moreover, if you pass `--experimental-wasm-bigint` to node >14 it is an
63
+ error:
64
+
65
+ ```
66
+ $ node -v
67
+ v14.20.0
68
+
69
+ $ node --experimental-wasm-bigint hello_python.js
70
+ warning: no blob constructor, cannot create blobs with mimetypes
71
+ warning: no BlobBuilder
72
+ Loading distutils
73
+ Loaded distutils
74
+ Python initialization complete
75
+ Python says that 1+1= 2
76
+ ```
77
+
78
+ See the [documentation](https://pyodide.org/en/stable/) fore more details.
79
+
80
+ ## Details
81
+
82
+ The JavaScript code in this package is responsible for the following tasks:
83
+
84
+ 1. Defines the public [JavaScript API](https://pyodide.org/en/stable/usage/api/js-api.html)
85
+ - Package loading code to allow loading of other Python packages.
86
+ - Can load
87
+ [micropip](https://pyodide.org/en/stable/usage/api/micropip-api.html) to
88
+ bootstrap loading of pure Python wheels
89
+ 2. Loads the CPython interpreter and the core/pyodide emscripten application
90
+ which embeds the interpreter.
91
+ 3. Injects the `js/pyodide` JavaScript API into `sys.modules`. This is the
92
+ final runtime dependency for `core/pyodide` & `py/pyodide`, so after this step
93
+ the interpreter is fully up and running.
package/console.html CHANGED
@@ -84,7 +84,7 @@
84
84
  pyodide.runPython(
85
85
  `
86
86
  import sys
87
- from pyodide import to_js
87
+ from pyodide.ffi import to_js
88
88
  from pyodide.console import PyodideConsole, repr_shorten, BANNER
89
89
  import __main__
90
90
  BANNER = "Welcome to the Pyodide terminal emulator 🐍\\n" + BANNER
@@ -107,7 +107,9 @@
107
107
  let clear_console = namespace.get("clear_console");
108
108
  const echo = (msg, ...opts) =>
109
109
  term.echo(
110
- msg.replace("]]", "&rsqb;&rsqb;").replace("[[", "&lsqb;&lsqb;"),
110
+ msg
111
+ .replaceAll("]]", "&rsqb;&rsqb;")
112
+ .replaceAll("[[", "&lsqb;&lsqb;"),
111
113
  ...opts
112
114
  );
113
115
  namespace.destroy();
package/distutils.tar CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pyodide",
3
- "version": "0.21.0-alpha.1",
3
+ "version": "0.21.0",
4
4
  "description": "The Pyodide JavaScript package",
5
5
  "keywords": [
6
6
  "python",
@@ -29,7 +29,7 @@
29
29
  "chai-as-promised": "^7.1.1",
30
30
  "cross-env": "^7.0.3",
31
31
  "dts-bundle-generator": "^6.7.0",
32
- "error-stack-parser": "^2.0.6",
32
+ "error-stack-parser": "^2.1.4",
33
33
  "express": "^4.17.3",
34
34
  "mocha": "^9.0.2",
35
35
  "npm-run-all": "^4.1.5",
@@ -53,11 +53,12 @@
53
53
  },
54
54
  "./pyodide.mjs": "./pyodide.mjs",
55
55
  "./pyodide.js": "./pyodide.js",
56
- "./package.json": "./package.json"
56
+ "./package.json": "./package.json",
57
+ "./repodata.json": "./repodata.json"
57
58
  },
58
59
  "files": [
59
60
  "pyodide*",
60
- "packages.json",
61
+ "repodata.json",
61
62
  "distutils.tar",
62
63
  "console.html"
63
64
  ],
package/pyodide.asm.data CHANGED
Binary file