-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #244 from hoodmane/emscripten-ci2
Add CI tests for wasm32-emscripten wheels in Pyodide
- Loading branch information
Showing
10 changed files
with
200 additions
and
1 deletion.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
builddir | ||
main.* | ||
!main.c | ||
pybuilddir.txt | ||
pyodide | ||
node_modules |
16 changes: 16 additions & 0 deletions
16
emscripten/_sysconfigdata__emscripten_wasm32-emscripten.py
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,16 @@ | ||
# system configuration generated and used by the sysconfig module | ||
build_time_vars = { | ||
"ABIFLAGS": "", | ||
"AR": "/src/emsdk/emsdk/upstream/emscripten/emar", | ||
"ARFLAGS": "rcs", | ||
"BLDSHARED": "emcc -sSIDE_MODULE=1 -L/src/emscripten/python-lib/", | ||
"CC": "emcc -I/src/emscripten/python-include/", | ||
"CCSHARED": "", | ||
"CFLAGS": "-Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g " | ||
"-fwrapv -O3 -Wall -O2 -g0 -fPIC", | ||
"EXT_SUFFIX": ".cpython-310-wasm32-emscripten.so", | ||
"HOST_GNU_TYPE": "wasm32-unknown-emscripten", | ||
"LDSHARED": "emcc -sSIDE_MODULE=1", | ||
"Py_DEBUG": "0", | ||
"py_version_nodot": "310", | ||
} |
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,23 @@ | ||
#!/usr/bin/env python3 | ||
import subprocess | ||
import sys | ||
|
||
|
||
def update_args(args): | ||
# remove -lc. Not sure if it makes a difference but -lc doesn't belong here. | ||
# https://github.com/emscripten-core/emscripten/issues/17191 | ||
for i in reversed(range(len(args))): | ||
if args[i] == "c" and args[i - 1] == "-l": | ||
del args[i - 1 : i + 1] | ||
|
||
return args | ||
|
||
|
||
def main(args): | ||
args = update_args(args) | ||
return subprocess.call(["emcc"] + args) | ||
|
||
|
||
if __name__ == "__main__": | ||
args = sys.argv[1:] | ||
sys.exit(main(args)) |
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,7 @@ | ||
implementation=CPython | ||
version=3.10 | ||
shared=true | ||
abi3=false | ||
lib_name=python3.10 | ||
pointer_width=32 | ||
suppress_build_script_link_lines=false |
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,38 @@ | ||
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("whl")) { | ||
return dirent.name; | ||
} | ||
} | ||
} | ||
|
||
const pkgDir = process.argv[2]; | ||
const distDir = pkgDir + "/dist"; | ||
const testDir = pkgDir + "/tests"; | ||
|
||
async function main() { | ||
const wheelName = await findWheel(distDir); | ||
const wheelURL = `file:${distDir}/${wheelName}`; | ||
|
||
try { | ||
pyodide = await loadPyodide(); | ||
const FS = pyodide.FS; | ||
const NODEFS = FS.filesystems.NODEFS; | ||
FS.mkdir("/test_dir"); | ||
FS.mount(NODEFS, { root: testDir }, "/test_dir"); | ||
await pyodide.loadPackage(["micropip", "pytest", "tomli"]); | ||
const micropip = pyodide.pyimport("micropip"); | ||
await micropip.install(wheelURL); | ||
const pytest = pyodide.pyimport("pytest"); | ||
errcode = pytest.main(pyodide.toPy(["/test_dir", "-vv"])); | ||
} catch (e) { | ||
console.error(e); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import sys | ||
import pytest | ||
|
||
if sys.platform == "emscripten": | ||
|
||
@pytest.fixture | ||
def benchmark(): | ||
def result(func, *args, **kwargs): | ||
return func(*args, **kwargs) | ||
|
||
return result |
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