Open pthom opened 2 days ago
What about if you run in cibuildwheel
? Building locally with CMake it can easily escape and pick up local libraries, e.g. if there was a find_package(BLAS)
. I'm not familiar enough with such an environment to know if the following is correct:
CC='/var/folders/w1/w77kvvl9613022ksfxj7v8xh0000gn/T/tmpdf290p91/cc'
Could you also print out all of the variables you find after running find_package(Python)
. Just to rule out that there is no system python that is leaking in there somehow.
This might also need support from upstream CMake to detect it (Python_INTERPRETER_ID
) because iiuc it's Python_add_library
that populates this field unless overwritten (Python_SOABI
?).
I'm not familiar enough with such an environment to know if the following is correct:
I agree, this is quite a complex stack of technologies (python, C++, cmake, pyodide, scikit-build-core).
CC='/var/folders/w1/w77kvvl9613022ksfxj7v8xh0000gn/T/tmpdf290p91/cc'
I guess this is part of the pyodide build system, which copies the emscripten compiler. Pyodide include a patched version of emsdk inside pyodide/emsdk/emsdk
Could you also print out all of the variables you find after running find_package(Python). Just to rule out that there is no system python that is leaking in there somehow.
Here are the relevant cmake variables after find_package(Python)
-- PYTHON_EXECUTABLE=/private/var/folders/w1/w77kvvl9613022ksfxj7v8xh0000gn/T/build-env-6b5o7tw1/bin/python
-- PYTHON_INCLUDE_DIR=/Users/pascal/dvp/OpenSource/ImGuiWork/_Bundle/_Pyodide/pyodide/cpython/installs/python-3.12.1/include/python3.12
-- PYTHON_LIBRARY=/Users/pascal/dvp/OpenSource/ImGuiWork/_Bundle/_Pyodide/pyodide/cpython/installs/python-3.12.1/lib/libpython3.12.a
-- Python3_EXECUTABLE=/private/var/folders/w1/w77kvvl9613022ksfxj7v8xh0000gn/T/build-env-6b5o7tw1/bin/python
-- Python3_FIND_REGISTRY=NEVER
-- Python3_INCLUDE_DIR=/Users/pascal/dvp/OpenSource/ImGuiWork/_Bundle/_Pyodide/pyodide/cpython/installs/python-3.12.1/include/python3.12
-- Python3_ROOT_DIR=/private/var/folders/w1/w77kvvl9613022ksfxj7v8xh0000gn/T/build-env-6b5o7tw1
-- Python_EXECUTABLE=/private/var/folders/w1/w77kvvl9613022ksfxj7v8xh0000gn/T/build-env-6b5o7tw1/bin/python
-- Python_FIND_REGISTRY=NEVER
-- Python_INCLUDE_DIR=/Users/pascal/dvp/OpenSource/ImGuiWork/_Bundle/_Pyodide/pyodide/cpython/installs/python-3.12.1/include/python3.12
-- Python_ROOT_DIR=/private/var/folders/w1/w77kvvl9613022ksfxj7v8xh0000gn/T/build-env-6b5o7tw1
This might also need support from upstream CMake to detect it (Python_INTERPRETER_ID) because iiuc it's Python_add_library that populates this field unless overwritten (Python_SOABI?).
This is a part where I must admit that I don't know.
What about if you run in cibuildwheel?
I have not explored using cibuildwheel together with pyodide. I think it might be very useful for the CI. However, my computer uses an ARM cpu, and I believe that cibuildwheel will handle pyodide builds with amd processors (which will be possible in CI, but not during development for me)
I have not explored using cibuildwheel together with pyodide. I think it might be very useful for the CI. However, my computer uses an ARM cpu, and I believe that cibuildwheel will handle pyodide builds with amd processors (which will be possible in CI, but not during development for me)
Afaiu pyodide compiles to the browser's code (WebAssembly?) so it would be architecture and OS independent as long as you have the pyodide environment to run them locally. The scope of pyodide seems to be to make self-contained web applications using python, e.g. interactive jupyter notebooks or the whole holoviews widget ecosystem. @henryiii has more knowledge on this backend.
This might also need support from upstream CMake to detect it (Python_INTERPRETER_ID) because iiuc it's Python_add_library that populates this field unless overwritten (Python_SOABI?).
This is a part where I must admit that I don't know.
Try also to see what SKBUILD_SOABI
gives you. See the warning section here on how to use it if it gives the correct tag. Other than that, everything looks fine, and my only guess is that CMake itself does not support the appropriate tag construction. Don't see any issues in CMake upstream so I'll open one after we gather some more information (primarily the difference between Python_SOABI
given by FindPython
by default and SKBUILD_SOABI
which scikit-build-core
constructs)
This should work, and I know it does in cibuildwheel. pyodide build
will rewrite binary with the correct SOABI for you, but I'm surprised that it doesn't fix the wheel tag. You are cross compiling, but these should work together. Quite a few pyodide package use scikit-bulid-core, like boost-histogram, iminuit, etc. I'll try to test this (much) later today (after teaching a class).
FYI, cibuildwheel is fine to use locally. Ignore the "ci" in the name. :) The binary you produce is in WASM, so the arch doesn't matter. That's one of the key features of WASM, it is the arch, and works on all system arches and platforms. Some tools even use this so they only have to ship one binary (though IIRC it's much easier for that use case to use WASI instead of Emscripten).
Also, pyodide's macOS building support is very limited and has several caveats. It's usually better to build in a docker container. pytest
doesn't work, for example, on macOS, but python -m pytest
does. Lots of weird stuff like that.
Hello
I'm trying to build a pyodide package using scikit-build-core, under macOS (ARM M1).
My issue is that the wheel that is produced is indeed a wasm wheel, but it is named "cp312-cp312-macosx_15_0_arm64.whl".
I know that this kind of issue is tricky because it is mixed in between pyodide and scikit-build-core. Anyhow I'd be interested in if a solution is possible.
Steps to reproduce
In order to reproduce the issue you can use the attached archive: daftsk.tgz
Simply extract it into pyodide/packages, then build it on a Mac with:
Here is a the archive content, which build a simple hello_world function that is bound to python:
here is pyproject.toml
and CMakeLists.txt:
The wheel name is not ok, but its content is actually a wasm module:
Build logs
The build logs are attached in the archive. It ends with "*** Created daftsk-0.0.1-cp312-cp312-macosx_15_0_arm64.whl"
Below is a complete log (except for the final pyodide python exception), with
logging.level = "DEBUG"
Many thanks in advance!