pyodide 0.25.0 → 0.26.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 +0 -4
- package/console.html +28 -29
- package/ffi.d.ts +27 -1
- package/package.json +5 -2
- package/pyodide-lock.json +1 -1
- package/pyodide.asm.js +2 -3
- package/pyodide.asm.wasm +0 -0
- package/pyodide.d.ts +43 -22
- package/pyodide.js +4 -2
- package/pyodide.js.map +3 -3
- package/pyodide.mjs +4 -2
- package/pyodide.mjs.map +3 -3
- package/python_stdlib.zip +0 -0
package/README.md
CHANGED
|
@@ -28,8 +28,6 @@ hello_python().then((result) => {
|
|
|
28
28
|
|
|
29
29
|
```
|
|
30
30
|
$ node hello_python.js
|
|
31
|
-
Loading distutils
|
|
32
|
-
Loaded distutils
|
|
33
31
|
Python says that 1+1= 2
|
|
34
32
|
```
|
|
35
33
|
|
|
@@ -43,8 +41,6 @@ Type ".help" for more information.
|
|
|
43
41
|
> const { loadPyodide } = require("pyodide");
|
|
44
42
|
undefined
|
|
45
43
|
> let pyodide = await loadPyodide();
|
|
46
|
-
Loading distutils
|
|
47
|
-
Loaded distutils
|
|
48
44
|
undefined
|
|
49
45
|
> await pyodide.runPythonAsync("1+1");
|
|
50
46
|
2
|
package/console.html
CHANGED
|
@@ -101,31 +101,31 @@
|
|
|
101
101
|
return result;
|
|
102
102
|
},
|
|
103
103
|
});
|
|
104
|
-
let
|
|
105
|
-
|
|
104
|
+
let { repr_shorten, BANNER, PyodideConsole } =
|
|
105
|
+
pyodide.pyimport("pyodide.console");
|
|
106
|
+
BANNER =
|
|
107
|
+
`Welcome to the Pyodide ${pyodide.version} terminal emulator 🐍\n` +
|
|
108
|
+
BANNER;
|
|
109
|
+
const pyconsole = PyodideConsole(pyodide.globals);
|
|
110
|
+
|
|
111
|
+
const namespace = pyodide.globals.get("dict")();
|
|
112
|
+
const await_fut = pyodide.runPython(
|
|
106
113
|
`
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
BANNER = "Welcome to the Pyodide terminal emulator 🐍\\n" + BANNER
|
|
112
|
-
pyconsole = PyodideConsole(__main__.__dict__)
|
|
113
|
-
import builtins
|
|
114
|
-
async def await_fut(fut):
|
|
114
|
+
import builtins
|
|
115
|
+
from pyodide.ffi import to_js
|
|
116
|
+
|
|
117
|
+
async def await_fut(fut):
|
|
115
118
|
res = await fut
|
|
116
119
|
if res is not None:
|
|
117
|
-
|
|
120
|
+
builtins._ = res
|
|
118
121
|
return to_js([res], depth=1)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
|
|
123
|
+
await_fut
|
|
124
|
+
`,
|
|
122
125
|
{ globals: namespace },
|
|
123
126
|
);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
let await_fut = namespace.get("await_fut");
|
|
127
|
-
let pyconsole = namespace.get("pyconsole");
|
|
128
|
-
let clear_console = namespace.get("clear_console");
|
|
127
|
+
namespace.destroy();
|
|
128
|
+
|
|
129
129
|
const echo = (msg, ...opts) =>
|
|
130
130
|
term.echo(
|
|
131
131
|
msg
|
|
@@ -133,26 +133,25 @@
|
|
|
133
133
|
.replaceAll("[[", "[["),
|
|
134
134
|
...opts,
|
|
135
135
|
);
|
|
136
|
-
namespace.destroy();
|
|
137
136
|
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
const ps1 = ">>> ";
|
|
138
|
+
const ps2 = "... ";
|
|
140
139
|
|
|
141
140
|
async function lock() {
|
|
142
141
|
let resolve;
|
|
143
|
-
|
|
142
|
+
const ready = term.ready;
|
|
144
143
|
term.ready = new Promise((res) => (resolve = res));
|
|
145
144
|
await ready;
|
|
146
145
|
return resolve;
|
|
147
146
|
}
|
|
148
147
|
|
|
149
148
|
async function interpreter(command) {
|
|
150
|
-
|
|
149
|
+
const unlock = await lock();
|
|
151
150
|
term.pause();
|
|
152
151
|
// multiline should be split (useful when pasting)
|
|
153
152
|
for (const c of command.split("\n")) {
|
|
154
153
|
const escaped = c.replaceAll(/\u00a0/g, " ");
|
|
155
|
-
|
|
154
|
+
const fut = pyconsole.push(escaped);
|
|
156
155
|
term.set_prompt(fut.syntax_check === "incomplete" ? ps2 : ps1);
|
|
157
156
|
switch (fut.syntax_check) {
|
|
158
157
|
case "syntax-error":
|
|
@@ -169,10 +168,10 @@
|
|
|
169
168
|
// awaits, so if an async function returns a future, it will await
|
|
170
169
|
// the inner future too. This is not what we want so we
|
|
171
170
|
// temporarily put it into a list to protect it.
|
|
172
|
-
|
|
171
|
+
const wrapped = await_fut(fut);
|
|
173
172
|
// complete case, get result / error and print it.
|
|
174
173
|
try {
|
|
175
|
-
|
|
174
|
+
const [value] = await wrapped;
|
|
176
175
|
if (value !== undefined) {
|
|
177
176
|
echo(
|
|
178
177
|
repr_shorten.callKwargs(value, {
|
|
@@ -201,7 +200,7 @@
|
|
|
201
200
|
}
|
|
202
201
|
|
|
203
202
|
term = $("body").terminal(interpreter, {
|
|
204
|
-
greetings:
|
|
203
|
+
greetings: BANNER,
|
|
205
204
|
prompt: ps1,
|
|
206
205
|
completionEscape: false,
|
|
207
206
|
completion: function (command, callback) {
|
|
@@ -209,7 +208,7 @@
|
|
|
209
208
|
},
|
|
210
209
|
keymap: {
|
|
211
210
|
"CTRL+C": async function (event, original) {
|
|
212
|
-
|
|
211
|
+
pyconsole.buffer.clear();
|
|
213
212
|
term.enter();
|
|
214
213
|
echo("KeyboardInterrupt");
|
|
215
214
|
term.set_command("");
|
package/ffi.d.ts
CHANGED
|
@@ -690,10 +690,36 @@ declare class PyCallableMethods {
|
|
|
690
690
|
*/
|
|
691
691
|
call(thisArg: any, ...jsargs: any): any;
|
|
692
692
|
/**
|
|
693
|
-
* Call the function with
|
|
693
|
+
* Call the function with keyword arguments. The last argument must be an
|
|
694
694
|
* object with the keyword arguments.
|
|
695
695
|
*/
|
|
696
696
|
callKwargs(...jsargs: any): any;
|
|
697
|
+
/**
|
|
698
|
+
* Call the function in a "relaxed" manner. Any extra arguments will be
|
|
699
|
+
* ignored. This matches the behavior of JavaScript functions more accurately.
|
|
700
|
+
*
|
|
701
|
+
* Any extra arguments will be ignored. This matches the behavior of
|
|
702
|
+
* JavaScript functions more accurately. Missing arguments are **NOT** filled
|
|
703
|
+
* with `None`. If too few arguments are passed, this will still raise a
|
|
704
|
+
* TypeError.
|
|
705
|
+
*
|
|
706
|
+
* This uses :py:func:`pyodide.code.relaxed_call`.
|
|
707
|
+
*/
|
|
708
|
+
callRelaxed(...jsargs: any): any;
|
|
709
|
+
/**
|
|
710
|
+
* Call the function with keyword arguments in a "relaxed" manner. The last
|
|
711
|
+
* argument must be an object with the keyword arguments. Any extra arguments
|
|
712
|
+
* will be ignored. This matches the behavior of JavaScript functions more
|
|
713
|
+
* accurately.
|
|
714
|
+
*
|
|
715
|
+
* Missing arguments are **NOT** filled with `None`. If too few arguments are
|
|
716
|
+
* passed, this will still raise a TypeError. Also, if the same argument is
|
|
717
|
+
* passed as both a keyword argument and a positional argument, it will raise
|
|
718
|
+
* an error.
|
|
719
|
+
*
|
|
720
|
+
* This uses :py:func:`pyodide.code.relaxed_call`.
|
|
721
|
+
*/
|
|
722
|
+
callKwargsRelaxed(...jsargs: any): any;
|
|
697
723
|
/**
|
|
698
724
|
* Call the function with stack switching enabled. Functions called this way
|
|
699
725
|
* can use
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pyodide",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0-alpha.2",
|
|
4
4
|
"description": "The Pyodide JavaScript package",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"python",
|
|
@@ -130,5 +130,8 @@
|
|
|
130
130
|
"base-64": "^1.0.0",
|
|
131
131
|
"ws": "^8.5.0"
|
|
132
132
|
},
|
|
133
|
-
"types": "./pyodide.d.ts"
|
|
133
|
+
"types": "./pyodide.d.ts",
|
|
134
|
+
"engines": {
|
|
135
|
+
"node": ">=18.0.0"
|
|
136
|
+
}
|
|
134
137
|
}
|