After making a complete mess with the code due to lack of Git knowledge, and having to redo things a bit, some weeks out of Haiku due to work issues which always results in forgetting about things, I finally got a bit closer to the final result:
The image shows the Application Gamejectder with its icon on the Deskbar. Gamejectder is a Python (PyQt) app. Now, this is not perfect as what I did is use Cython to get the Python script turned into C code and then compile it with GCC. I just did this for the ‘main’ script, the one that launches the app. Other scripts are left as is.
As I have no idea on C, nor C++, nor how to properly use GCC, beware of what you are about to read, might harm the minds of the real devs . This is what I’ve been doing:
1- I tried to Cythonize the inner parts (core and gui), resulting in .so libraries to be used by the final executable that embeds the Python interpreter.
2- I, with some effort, got to Cythonize multiple modules into a single .so library (got 2 .so libraries instead of one per Python module -8 modules = 8 libraries-).
3- Used GCC to link against that library. It results in an executable too, but this executable complains about the .so not found on the system. I don’t want to have those .so installed on the system because those are just used by this small app. That is not the path to follow here.
4- Then, after quite some tedious search, I found that I could join libraries into a static one. So I did with both .so joining them into a lib.a.
5- Used GCC again linking against the new recently created static library, resulting in another executable. Does not run either:
In fact, I should have tried first to import the .so inside the Python interpreter. Both core.so and guis.so don’t work, as they include all the modules below. Not sure yet why. IIRC, having a .so per module seems to load the module correctly inside the Python interpreter. Need more research and study.
Therefore, Cythonizing the program launcher and compiling it (leaving the other modules untouched) allows the software to integrate with Haiku a bit better than just plain Python script (double click, Deskbar icon, Haiku’s application signature…). It still depends on the other modules (python scripts) that need to be packaged with the executable in order to run.
This is not what I was trying to achieve:
- Make a simple Python application for Haiku (done)
- Use Haiku API (not done. Used PyQt)
- Make the Application as close as possible to single file (not achieved)
- Make the Application integrate with Haiku (partial?)
I still need to do some research and study on how to get the whole thing into let’s say, the executable file and a library or two, if that is possible.
The easy part now is the packaging. Making a .hpkg. Before that, I have to do some clean up and update the Git repo with the changes (hope won’t mess it again ). I made some backups, just in case, because I still have to learn how not to mess Git.
Any further improvement on the topic will be added here.
As a side result, I found out that changing the color of an icon (by code) is possible if the icon is properly designed. Gamejectder picks a different random color for each project folder and sets all folders for that project with that color.
I forgot, I checked with PyInstaller, Nuitka, Briefcase. None of them work to “freeze” the Python code into an executable on Haiku. That was one of the goals of this tiny project. Maybe could get one of them to work properly, and that would be a big leap forward, I presume. I checked, iirc, the code of Briefcase, and got it to see Haiku as a platform, but not much more, as they require X11, also iirc. Of course if one of those options end up working on Haiku as a viable way to freeze Python code and distribute software, my time on this would have been wasted
I also found out that to do things on Haiku, one needs to know a lot more than, let’s say i.e., Gnome. The more I dig, the more I know that I don’t know anything yet…