-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CI tests for wasm32-emscripten wheels in Pyodide #244
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From this should I infer that
pyo3_build_config
doesn't configure for pyodide correctly? Do you think we would be able to upstream a fix?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure. I think it may just be that I don't know how to use the tool correctly. How would I check this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So usually in cross-compile situations like for emscripten the
pyo3_build_config
build scripts will try to look for a sysconfigdata file and configure from that. Alternatively, can set theabi3-py310
feature and then it will do a "standard" cross compile, which might just work.I view the
PYO3_CONFIG_FILE
env var as an escape hatch when nothing built-in works, so if either of the above work (or can be made to work) that's probably preferable.