Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I xfailed most failing tests. Most fall into a few types of expected failure: 1. Any tests that start a thread or subprocess 2. Many tests fail because Wasm doesn't handle floating point errors correctly 3. Some tests that use mmap work correctly, others don't. I think Emscripten's mmap syscalls mostly work but are slightly buggy. This is an area that might be worth investigating in the future to fix upstream. 4. Some precision tests fail, particularly for large floating point types (128, 256). Also some of the branch cut tests. I don't really know what is going on with these
- Loading branch information
Showing
35 changed files
with
295 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Test Emscripten/Pyodide build | ||
|
||
on: | ||
push: | ||
branches: | ||
- emscripten-ci | ||
pull_request: | ||
branches: | ||
- main | ||
- maintenance/** | ||
|
||
jobs: | ||
build-wasm-emscripten: | ||
# run this for now on all CI for now in case something starts breaking it | ||
# if: "success() && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main')" | ||
# needs: [test, lint] | ||
runs-on: ubuntu-latest | ||
env: | ||
PYODIDE_VERSION: '0.21.0' | ||
PYTHON_VERSION: '3.10.2' | ||
NODE_VERSION: 18 | ||
EMSCRIPTEN_VERSION: 3.1.14 | ||
steps: | ||
- name: Checkout numpy | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
# versioneer.py requires the latest tag to be reachable. Here we | ||
# fetch the complete history to get access to the tags. | ||
# A shallow clone can work when the following issue is resolved: | ||
# https://github.com/actions/checkout/issues/338 | ||
fetch-depth: 0 | ||
|
||
- name: set up python | ||
id: setup-python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
- uses: mymindstorm/setup-emsdk@v11 | ||
with: | ||
version: ${{ env.EMSCRIPTEN_VERSION }} | ||
actions-cache-folder: emsdk-cache | ||
|
||
- name: Install pyodide-build | ||
run: pip install pyodide-build==$PYODIDE_VERSION | ||
|
||
- name: Build | ||
run: CFLAGS=-g2 LDFLAGS=-g2 pyodide build | ||
|
||
- name: set up node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ env.NODE_VERSION }} | ||
|
||
- name: install Pyodide | ||
run: | | ||
cd emscripten | ||
npm i pyodide@$PYODIDE_VERSION | ||
- name: Test | ||
run: | | ||
node emscripten/emscripten_runner.js . ./numpy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
const { opendir } = require('node:fs/promises'); | ||
const { loadPyodide } = require('pyodide'); | ||
|
||
async function findWheel(distDir) { | ||
const dir = await opendir(distDir); | ||
for await (const dirent of dir) { | ||
if (dirent.name.endsWith('wasm32.whl')) { | ||
return dirent.name; | ||
} | ||
} | ||
} | ||
|
||
const pkgDir = process.argv[2]; | ||
const distDir = pkgDir + '/dist'; | ||
|
||
function make_tty_ops(stream){ | ||
return { | ||
// get_char has 3 particular return values: | ||
// a.) the next character represented as an integer | ||
// b.) undefined to signal that no data is currently available | ||
// c.) null to signal an EOF | ||
get_char(tty) { | ||
if (!tty.input.length) { | ||
var result = null; | ||
var BUFSIZE = 256; | ||
var buf = Buffer.alloc(BUFSIZE); | ||
var bytesRead = fs.readSync(process.stdin.fd, buf, 0, BUFSIZE, -1); | ||
if (bytesRead === 0) { | ||
return null; | ||
} | ||
result = buf.slice(0, bytesRead); | ||
tty.input = Array.from(result); | ||
} | ||
return tty.input.shift(); | ||
}, | ||
put_char(tty, val) { | ||
try { | ||
if(val !== null){ | ||
tty.output.push(val); | ||
} | ||
if (val === null || val === 10) { | ||
process.stdout.write(Buffer.from(tty.output)); | ||
tty.output = []; | ||
} | ||
} catch(e){ | ||
console.warn(e); | ||
} | ||
}, | ||
flush(tty) { | ||
if (!tty.output || tty.output.length === 0) { | ||
return; | ||
} | ||
stream.write(Buffer.from(tty.output)); | ||
tty.output = []; | ||
} | ||
}; | ||
} | ||
|
||
function setupStreams(FS, TTY){ | ||
let mytty = FS.makedev(FS.createDevice.major++, 0); | ||
let myttyerr = FS.makedev(FS.createDevice.major++, 0); | ||
TTY.register(mytty, make_tty_ops(process.stdout)) | ||
TTY.register(myttyerr, make_tty_ops(process.stderr)) | ||
FS.mkdev('/dev/mytty', mytty); | ||
FS.mkdev('/dev/myttyerr', myttyerr); | ||
FS.unlink('/dev/stdin'); | ||
FS.unlink('/dev/stdout'); | ||
FS.unlink('/dev/stderr'); | ||
FS.symlink('/dev/mytty', '/dev/stdin'); | ||
FS.symlink('/dev/mytty', '/dev/stdout'); | ||
FS.symlink('/dev/myttyerr', '/dev/stderr'); | ||
FS.closeStream(0); | ||
FS.closeStream(1); | ||
FS.closeStream(2); | ||
FS.open('/dev/stdin', 0); | ||
FS.open('/dev/stdout', 1); | ||
FS.open('/dev/stderr', 1); | ||
} | ||
|
||
async function main() { | ||
const wheelName = await findWheel(distDir); | ||
const wheelURL = `file:${distDir}/${wheelName}`; | ||
let exitcode = 0; | ||
try { | ||
pyodide = await loadPyodide(); | ||
const FS = pyodide.FS; | ||
setupStreams(FS, pyodide._module.TTY); | ||
const NODEFS = FS.filesystems.NODEFS; | ||
FS.chdir("/lib/python3.10/site-packages/"); | ||
|
||
await pyodide.loadPackage(['micropip']); | ||
await pyodide.runPythonAsync(` | ||
from pathlib import Path | ||
import micropip | ||
# reqs = [x for x in Path("./test_requirements.txt").read_text().split() if not x.startswith("#")] | ||
reqs = ["cython>=0.29.30,<3.0", | ||
"wheel==0.37.0", | ||
"setuptools==59.2.0", | ||
"hypothesis==6.24.1", | ||
"pytest==6.2.5", | ||
"pytz==2021.3", | ||
"typing_extensions>=4.2.0",] | ||
reqs.extend(["tomli", "${wheelURL}"]) | ||
await micropip.install(reqs) | ||
`); | ||
const pytest = pyodide.pyimport('pytest'); | ||
exitcode = pytest.main(pyodide.toPy([...process.argv.slice(3)])); | ||
} catch (e) { | ||
console.error(e); | ||
exitcode = 1; | ||
} finally { | ||
// worker.terminate(); | ||
process.exit(exitcode); | ||
} | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.