pyodide/tools
Hood Chatham 7422ab370d
Implement more detailed streams support (#3268)
Resolves https://github.com/pyodide/pyodide/issues/3112
This adds a carefully designed API for controlling stdin, stdout, and stderr. It changes
the default behavior to be a bit more useful, though in doing so introduces some mild
backwards incompatibility. In particular:

1. By default, stdin reads directly from `process.stdin` in node (as before) and raises an
error if in browser (not as before).
2. By default, stdout writes directly to `process.stdout` in node (before it called console.log)
and calls console.log in browser (as before).
3. By default, stderr writes directly to `process.stderr` in node (before it called console.warn)
and calls console.warn in browser (as before).
4. In all three cases, by default isatty(stdin/stdout/stderr) is true in node and false in browser
(in the browser it used to be true).
5. As before, if you pass `stdin`, `stdout`, or `stderr` as arguments to `loadPyodide`, `isatty` of
the corresponding stream is set to false.

The stdin function is now more flexible: we now correctly handle the case where it returns an
ArrayBuffer or ArrayBufferView.

I also added 3 new functions to set streams after Pyodide is loaded which offer additional
control:
* `setStdin({stdin?, error?, isatty = false})` -- Sets the stdin function. The stdin function takes no
arguments and should return null, undefined, a string, or a buffer. Sets and `isatty(stdin)` to 
`isatty` (by default `false`). If error is true, set stdin to always raise an EIO error when it is read.
* `setStdout({raw?, batched?, isatty = false})` -- If neither raw nor batched is passed, restore 
default stdout behavior. If rwa is passed, the raw stdout function receives a byte which it should
interpret as a utf8 character code. Sets `isatty(stdout)` to isatty (by default `false`). If batched is
passed but not raw, it sets a batched stdout function. The stdout function receives a string and
should do something with it. In this case it ignores isatty and sets isatty(stdout) to false.
* `setStderr({raw?, batched?, isatty = false})` -- same but with stderr.
2022-12-18 15:55:52 -08:00
..
cmake/Modules/Platform PKG Add geopandas, fiona, and GDAL (#3213) 2022-11-07 13:44:23 +09:00
symlinks No replay (#2256) 2022-03-13 11:39:06 -07:00
assemble_wat.js Add a tool to allow us to embed wasm modules with hand coded wat (#3230) 2022-11-10 14:22:59 -08:00
buildf2c chore: more pre-commit checking (#2257) 2022-03-07 21:51:20 -08:00
bump_version.py Remove pre-built docker image support (#3342) 2022-12-13 12:04:15 +09:00
calculate_build_cache_key.py CI Fix ccache in package build (#3104) 2022-09-21 09:30:09 +02:00
dependency-check.sh Add `requirements/executable` key in meta.yaml spec (#3300) 2022-11-30 16:40:36 +09:00
deploy_to_npm.sh Correctly specify files to be packed in a npm package (#3168) 2022-10-12 13:54:12 +09:00
pyo3_config.ini Cryptography v36.0.2 w/ Rust (#2378) 2022-06-09 10:57:34 -07:00
pytest_wrapper.py Run core tests in Safari (#2578) 2022-09-08 10:43:55 +09:00
python Implement more detailed streams support (#3268) 2022-12-18 15:55:52 -08:00