Add a simple example about how to build your own C++ Pyodide package
See original GitHub issue📚 Documentation
I saw that there is already a page on the Pyodide website titled “Creating a Pyodide package”, but for a C/C++
developer it is not clear how to proceed.
In my conversation here, @JeanChristopherMorinPerso informed me that it is possible to create Pyodide packages from C++
code that has the Pybind11
wrapper and that he made it himself for his project.
My C++
library already has the Pybind11
wrapper, but even so, I’m not finding documentation or a simple example that I can follow and get a valid Pyodide package.
Finally, I tried to understand what was the reasoning behind compiling Pyodide packages which were originally written in C/C++
contained on Github in the ‘packges’ folder, (example: ‘numpy’), but I couldn’t understand the logic of the contents of these folders and how everything is actually working.
So for libraries written in C/C++
I have 2 suggestions:
Suggestion 01: C++ code without Pybind11 wrapper
Adding to the documentation (maybe even in the README
) is a simple little example of how to create a Pyodide package from a C++
library.
This simple example could be named: Hello World
.
Example:
#include <iostream>
class HelloWorld
{
public:
HelloWorld() {
std::cout << "Hello" << std::endl;
}
}
Suggestion 02: Code with Pybind11 wrapper
Add the same type of simple example mentioned above to the documentation but that contains a Pybind11
wrapper
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:8 (6 by maintainers)
What I had in mind is that you’d create a Python package that uses C++ and Pybind11 like you normally would (I.e. ignore the Pyodide aspect). You’d just create this package in a new Github repo, and then publish the package to PyPi, and then run the commands in this comment sequentially, where
<package-name>
is the name of the PyPi package that you published.IIUC, that should work “out of the box” for simple C++/Python packages. If it doesn’t, then we can troubleshoot from there and add extra steps to the “hello world” tutorial that we write.
Nor is it easy for me. My approach is to ask henryiii or ryanking13.