-
-
Notifications
You must be signed in to change notification settings - Fork 850
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
How to use the latest Pyodide for Pyxel Web #462
Comments
Hello, Pyodide dev here. I made following changes when porting pyxel:
export RUSTFLAGS="\
-C link-arg=-sUSE_SDL=2 \
-C link-arg=-fPIC \
-C link-arg=-lSDL2 \
"
let sdl2Canvas = document.createElement("canvas");
sdl2Canvas.id = "canvas";
pyodide.canvas.setCanvas2D(sdl2Canvas);
|
Thank you for your information. |
I guess you need to explicitly build SDL2 first with |
@ryanking13 Thank you! It worked.
Other options like this in the same file works:
|
Hmm, yeah I think I also failed to add those configs to When I look at the cargo documentation, there's following explanation. Maybe it's relevant?
|
Thank you for the useful information. In Makefile, actually I use the same commands except the target name. Specifically, I just call |
@kitao It's not read by maturin 0.14, but it's implemented in PyO3/maturin#1405, you can try maturin pre-release to test it out: |
@messense Thank you! And now I changed Maturin 1.0.0-beta.7, but it seems that the configs are not read. |
By the way, thank you for your continued Maturin updates! @messense |
maturin sets
maturin 1.0.0 beta versions read |
Actually |
@messense
|
I'm not sure. Do you have a branch that I can try to debug? |
Now I've pushed the latest test code to the develop brunch. |
One more thing, you can set up the venv environment by type `. scripts/setup_python_venv'. |
I'm seeing this: $ maturin --version
maturin 1.0.0-beta.7
$ make build-wasm
Skipped 4 files
All done! ✨ 🍰 ✨
52 files left unchanged.
info: component 'rust-std' for target 'wasm32-unknown-emscripten' is up to date
2023-04-25T12:16:15.206485Z DEBUG maturin::project_layout: Found pyproject.toml in working directory at "/Users/messense/Projects/pyxel/pyproject.toml"
2023-04-25T12:16:15.207380Z DEBUG maturin::project_layout: Using cargo manifest path from pyproject.toml "crates/pyxel-extension/Cargo.toml"
2023-04-25T12:16:15.207566Z DEBUG maturin::project_layout: Resolving cargo metadata from "/Users/messense/Projects/pyxel/crates/pyxel-extension/Cargo.toml"
2023-04-25T12:16:15.280852Z DEBUG maturin::project_layout: Project layout resolved project_root=/Users/messense/Projects/pyxel python_dir=/Users/messense/Projects/pyxel/python rust_module=/Users/messense/Projects/pyxel/python/pyxel_extension python_module=/Users/messense/Projects/pyxel/python/pyxel_extension extension_name=pyxel_extension
🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.7
⚠️ Warning: skipped unavailable python interpreter 'python3.8' from pyenv
2023-04-25T12:16:15.701007Z DEBUG maturin::python_interpreter: Found CPython interpreter at /opt/homebrew/opt/python@3.9/bin/python3.9
2023-04-25T12:16:15.766912Z DEBUG maturin::python_interpreter: Found CPython interpreter at /opt/homebrew/opt/python@3.10/bin/python3.10
2023-04-25T12:16:15.785802Z DEBUG maturin::python_interpreter: Found CPython interpreter at /Users/messense/.pyenv/versions/test-3.11/bin/python3.11
🐍 Not using a specific python interpreter
2023-04-25T12:16:15.787536Z DEBUG maturin::compile: Setting `-Z link-native-libraries=no` for Emscripten
2023-04-25T12:16:15.787541Z DEBUG maturin::compile: Setting additional linker args for Emscripten: ["-C", "link-arg=-sSIDE_MODULE=2", "-C", "link-arg=-sWASM_BIGINT"]
2023-04-25T12:16:15.787565Z DEBUG maturin::compile: Running CARGO_ENCODED_RUSTFLAGS="-C\u{1f}link-arg=-sUSE_SDL=2\u{1f}-C\u{1f}link-arg=-fPIC\u{1f}-C\u{1f}link-arg=-lSDL2\u{1f}-Z\u{1f}link-native-libraries=no" "cargo" "rustc" "--target" "wasm32-unknown-emscripten" "--message-format" "json" "--manifest-path" "/Users/messense/Projects/pyxel/crates/pyxel-extension/Cargo.toml" "--release" "--lib" "--" "-C" "link-arg=-sSIDE_MODULE=2" "-C" "link-arg=-sWASM_BIGINT"
You can see that the config file is loaded. |
Interesting. On my M2 MacBook Air,
|
Maybe you can try it out in GitHub Actions? Or in a different path that's not in OneDrive? |
I copied the pyxel directory to an other place and tried again for now.
|
Now I'm trying it on GitHub Actions. |
Hmm, in the case of GitHub Actions, it stops with a compilation error on Intel Mac. Is the pyproject.toml setting not enabled by this setting?
|
You are using 0.14.17. |
Could you give me an advice about how to change the requirements.txt? |
Well you can just write |
I changed the requirements.txt, but the old version was installed. I pushed the updated requirements.txt for your check. |
Line 4 in 837949f
I don't think you are following my previous instruction. You need to change it to |
Ah sorry, I didn't commit button yet and now I've pushed it. |
My mistake. Now the correct version of Maturin is installed. |
@messense Thank you. |
@ryanking13 I've faced an another issue.
Is this the result of conflict between the pre-registered Pyxel in Pyodide and the latest Pyxel? |
I don't think so. Is there other error messages showing in browser console? |
There's no error on browser console.
And what pyxel.js does is as follows: async function _loadPyodideAndPyxel(canvas) {
await _loadScript(NO_SLEEP_URL);
let noSleep = new NoSleep();
noSleep.enable();
await _loadScript(PYODIDE_URL);
let pyodide = await loadPyodide();
pyodide._api._skip_unwind_fatal_error = true;
pyodide.canvas.setCanvas2D(canvas);
await pyodide.loadPackage(_scriptDir() + PYXEL_WHEEL_PATH);
let FS = pyodide.FS;
FS.mkdir(PYXEL_WORKING_DIRECTORY);
FS.chdir(PYXEL_WORKING_DIRECTORY);
return pyodide;
} It just does |
Hmm, okay. Could you share the wheel file so that I can test? |
Here's a zipped version of wheel file. |
@kitao It looks like the wheel file does not contain Python files. Maybe maturin didn't correctly detect the source directory for some reason? $ unzip -l pyxel-1.9.14-cp37-abi3-emscripten_3_1_36_wasm32
Archive: pyxel-1.9.14-cp37-abi3-emscripten_3_1_36_wasm32.zip
Length Date Time Name
--------- ---------- ----- ----
28112 2023-04-26 06:01 pyxel-1.9.14.dist-info/METADATA
116 2023-04-26 06:01 pyxel-1.9.14.dist-info/WHEEL
38 2023-04-26 06:01 pyxel-1.9.14.dist-info/entry_points.txt
1069 2023-04-26 06:01 pyxel-1.9.14.dist-info/license_files/LICENSE
143 2023-04-26 06:01 pyxel_extension/__init__.py
3504174 2023-04-26 06:01 pyxel_extension/pyxel_extension.abi3.so
582 2023-04-26 06:01 pyxel-1.9.14.dist-info/RECORD
--------- -------
3534234 7 files |
Thank you for your great effort! |
I tried maturin 0.13.7 which is the previous version Pyxel used just in case and it worked. |
pyxel/crates/pyxel-extension/Cargo.toml Lines 27 to 28 in f34b015
[tool.maturin]
module-name = "pyxel.pyxel_extension" |
@messense Thank you. I modified pyproject.toml as you suggested. |
Sorry I don't understand what was the issue you are facing, the whl looks fine to me: $ unzip -l dist/pyxel-1.9.15-cp37-abi3-emscripten_3_1_36_wasm32.whl
Archive: dist/pyxel-1.9.15-cp37-abi3-emscripten_3_1_36_wasm32.whl
Length Date Time Name
--------- ---------- ----- ----
28111 04-26-2023 11:35 pyxel-1.9.15.dist-info/METADATA
116 04-26-2023 11:35 pyxel-1.9.15.dist-info/WHEEL
38 04-26-2023 11:35 pyxel-1.9.15.dist-info/entry_points.txt
1069 04-26-2023 11:35 pyxel-1.9.15.dist-info/license_files/LICENSE
16362 04-26-2023 11:35 pyxel/__init__.pyi
60 04-26-2023 11:35 pyxel/__init__.py
11094 04-26-2023 11:35 pyxel/cli.py
763 04-26-2023 11:35 pyxel/examples/12_perlin_noise.py
609 04-26-2023 11:35 pyxel/examples/99_flip_animation.py
8638 04-26-2023 11:35 pyxel/examples/09_shooter.py
452 04-26-2023 11:35 pyxel/examples/01_hello_pyxel.py
4375 04-26-2023 11:35 pyxel/examples/03_draw_api.py
29948 04-26-2023 11:35 pyxel/examples/megaball.pyxapp
4211 04-26-2023 11:35 pyxel/examples/02_jump_game.py
1180 04-26-2023 11:35 pyxel/examples/08_triangle_api.py
3693 04-26-2023 11:35 pyxel/examples/04_sound_api.py
3095 04-26-2023 11:35 pyxel/examples/13_bitmap_font.py
7880 04-26-2023 11:35 pyxel/examples/10_platformer.py
4031 04-26-2023 11:35 pyxel/examples/06_click_game.py
7738 04-26-2023 11:35 pyxel/examples/07_snake.py
551 04-26-2023 11:35 pyxel/examples/05_color_palette.py
248 04-26-2023 11:35 pyxel/examples/assets/pyxel_logo_38x16.png
2466 04-26-2023 11:35 pyxel/examples/assets/jump_game.pyxres
1086726 04-26-2023 11:35 pyxel/examples/assets/umplus_j12r.bdf
5635 04-26-2023 11:35 pyxel/examples/assets/platformer.pyxres
1017044 04-26-2023 11:35 pyxel/examples/assets/umplus_j10r.bdf
12895 04-26-2023 11:35 pyxel/examples/assets/sample.pyxres
181 04-26-2023 11:35 pyxel/examples/assets/cat_16x16.png
4154 04-26-2023 11:35 pyxel/examples/assets/offscreen.pyxres
13941 04-26-2023 11:35 pyxel/examples/assets/noguchi_128x128.png
310 04-26-2023 11:35 pyxel/examples/assets/tileset_24x32.png
3839 04-26-2023 11:35 pyxel/examples/11_offscreen.py
20880 04-26-2023 11:35 pyxel/examples/30SecondsOfDaylight.pyxapp
0 04-26-2023 11:35 pyxel/py.typed
29 04-26-2023 11:35 pyxel/__main__.py
5078 04-26-2023 11:35 pyxel/editor/piano_roll.py
6380 04-26-2023 11:35 pyxel/editor/image_viewer.py
4341 04-26-2023 11:35 pyxel/editor/tilemap_editor.py
16961 04-26-2023 11:35 pyxel/editor/canvas_panel.py
4496 04-26-2023 11:35 pyxel/editor/sound_field.py
79 04-26-2023 11:35 pyxel/editor/__init__.py
8294 04-26-2023 11:35 pyxel/editor/sound_editor.py
5276 04-26-2023 11:35 pyxel/editor/piano_keyboard.py
3165 04-26-2023 11:35 pyxel/editor/sound_selector.py
8251 04-26-2023 11:35 pyxel/editor/field_cursor.py
1442 04-26-2023 11:35 pyxel/editor/octave_bar.py
6416 04-26-2023 11:35 pyxel/editor/music_editor.py
1173 04-26-2023 11:35 pyxel/editor/settings.py
7265 04-26-2023 11:35 pyxel/editor/app.py
3390 04-26-2023 11:35 pyxel/editor/music_field.py
1772 04-26-2023 11:35 pyxel/editor/additional_apis.py
1237 04-26-2023 11:35 pyxel/editor/assets/editor_220x160.png
3960 04-26-2023 11:35 pyxel/editor/image_editor.py
2027 04-26-2023 11:35 pyxel/editor/widgets/radio_button.py
9030 04-26-2023 11:35 pyxel/editor/widgets/widget.py
1214 04-26-2023 11:35 pyxel/editor/widgets/toggle_button.py
509 04-26-2023 11:35 pyxel/editor/widgets/__init__.py
6084 04-26-2023 11:35 pyxel/editor/widgets/scroll_bar.py
763 04-26-2023 11:35 pyxel/editor/widgets/image_toggle_button.py
2110 04-26-2023 11:35 pyxel/editor/widgets/color_picker.py
1896 04-26-2023 11:35 pyxel/editor/widgets/button.py
768 04-26-2023 11:35 pyxel/editor/widgets/image_button.py
335 04-26-2023 11:35 pyxel/editor/widgets/settings.py
2095 04-26-2023 11:35 pyxel/editor/widgets/number_picker.py
911 04-26-2023 11:35 pyxel/editor/widgets/widget_var.py
913 04-26-2023 11:35 pyxel/editor/widgets/text_button.py
3329 04-26-2023 11:35 pyxel/editor/editor_base.py
2983 04-26-2023 11:35 pyxel/editor/tilemap_viewer.py
82746781 04-26-2023 11:35 pyxel/pyxel_extension.abi3.so
6102 04-26-2023 11:35 pyxel-1.9.15.dist-info/RECORD
--------- -------
85179188 70 files |
The error was this:
Extension lib exists but is doesn't satisfy some condition? |
You can try this: https://github.com/alexcrichton/curl-rust/pull/283/files |
@messense Thank you. |
@messense |
|
Yes. I had set the targets according to your past advices. I also tried "10.12" for aarch64 but the result was the same though I'm not sure its the proper version. |
I understood it happened when the version was too old and decided to add build.rs for covering old versions. |
Since the latest Pyodide supports SDL2, I'd like update Pyxel Web to work with it instead of the modified version, pyodide-sdl2.
Any help is welcome for that.
@pmp-p, I would appreciate it if you could give me some advice.
The text was updated successfully, but these errors were encountered: