Release src/js as a npm package (#1762)

This commit is contained in:
Roman Yurchak 2021-07-31 20:46:22 +02:00 committed by GitHub
parent af6dd7be46
commit 66b33226ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 55 additions and 12 deletions

View File

@ -4,7 +4,8 @@
</a>
</div>
[![NPM Latest Release](https://img.shields.io/npm/v/pyodide)](https://www.npmjs.com/package/pyodide)
[![PyPI Latest Release](https://img.shields.io/pypi/v/pyodide-build.svg)](https://pypi.org/project/pyodide-build/)
[![Build Status](https://circleci.com/gh/pyodide/pyodide.png)](https://circleci.com/gh/pyodide/pyodide)
[![Documentation Status](https://readthedocs.org/projects/pyodide/badge/?version=stable)](https://pyodide.readthedocs.io/?badge=stable)
@ -48,8 +49,8 @@ technical resources. These include:
recommended for Windows and macOS users and for Linux users who prefer a
Debian-based Docker image with the dependencies already installed.
## History
Pyodide was created in 2018 by [Michael Droettboom](https://github.com/mdboom)
at Mozilla as part of the [Iodide
project](https://github.com/iodide-project/iodide). Iodide is an experimental

View File

@ -17,7 +17,7 @@
* See Makefile recipe for src/js/pyproxy.js
*/
import { Module } from "../js/module.js";
import { Module } from "./module.js";
/**
* Is the argument a :any:`PyProxy`?

View File

@ -1,12 +1,40 @@
# js/pyodide
# Pyodide Javascript package
The Javascript code in this folder is responsible for the following tasks:
<a href="https://www.npmjs.com/package/pyodide"><img src="https://img.shields.io/npm/v/pyodide" alt="npm"></a>
1. Defines the public Javascript API
## Usage
Download and extract Pyodide packages from [Github
releases](https://github.com/pyodide/pyodide/releases)
(`pyodide-build-*.tar.bz2`). The version of the release needs to match exactly the version of this package.
Then you can load Pyodide in Node.js as follows,
```js
let pyodide_pkg = await import("pyodide/pyodide.js");
let pyodide = await pyodide_pkg.loadPyodide({
indexURL: "<pyodide artifacts folder>",
});
await pyodide.runPythonAsync("1+1");
```
**Note**: To start node REPL with support for top level await, use `node --experimental-repl-await`.
See the [documentation](https://pyodide.org/en/stable/) fore more details.
## Details
The Javascript code in this package is responsible for the following tasks:
1. Defines the public [Javascript API](https://pyodide.org/en/stable/usage/api/js-api.html)
- Package loading code to allow loading of other Python packages.
- Can load micropip.py to bootstrap loading of pure Python wheels
- Can load
[micropip](https://pyodide.org/en/stable/usage/api/micropip-api.html) to
bootstrap loading of pure Python wheels
2. Loads the CPython interpreter and the core/pyodide emscripten application
which embeds the interpreter.
3. Injects the js/pyodide Javascript API into sys.modules. This is the final
runtime dependency for core/pyodide & py/pyodide, so after this step the
interpreter is fully up and running.
3. Injects the `js/pyodide` Javascript API into `sys.modules`. This is the
final runtime dependency for `core/pyodide` & `py/pyodide`, so after this step
the interpreter is fully up and running.

View File

@ -1,6 +1,6 @@
{
"name": "pyodide",
"version": "0.18.0dev0",
"version": "0.18.0-dev.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,20 @@
{
"name": "pyodide",
"version": "0.18.0dev0",
"version": "0.18.0-dev.0",
"description": "The Pyodide JavaScript package",
"keywords": [
"python",
"webassembly"
],
"homepage": "https://github.com/pyodide/pyodide",
"repository": {
"type": "git",
"url": "https://github.com/pyodide/pyodide"
},
"bugs": {
"url": "https://github.com/pyodide/pyodide/issues"
},
"license": "Apache-2.0",
"devDependencies": {
"prettier": "^2.2.1",
"terser": "^5.7.0",