Bundling python apps with Nuitka in Haiku


#1

This is most probably a corner case for app development in Haiku, but i want to say that you can pack a python application inside a single binary with this lib.

Infoworld article about Nuitka

If you want to install the library, just use pip and make sure you have the python dev package for your favourite version of python (2.x, 3.x) and run:

pip install Nuitka

It wont work “as is”, but will if you tweak the file:

/system/non-packaged/lib/python2.7/site-packages/nuitka/build/SingleExe.scons

And include the line around line 1027 of the file, for python 2.7:

python_header_path = "/system/develop/headers/python2.7/"

All the instructions available in the manual seem to work:

Nuitka Manual

I have been doing some tests on simple helloworld-apps and others than are a bit more complex with success, but as with all this compilers, your mileage may vary.

Running times didnt get faster than running the interpreter itself, but still have the feature of having a single “distributable” binary


#2

“pip install --user” would be preferred.


#3

Agreed, but in systems where the user has no priviledges and… it’s not the case for “user”, isnt it?
Wouldnt be found at the path i posted for tweaking in that case too :thinking:.

Anyway, this is just useful for distributing to a system without the modules you’r working with installed, which
is going to be a very low chance of happening (that’s more common in Windows world).


#4

Thanks for the tip. I have used nuitka before on macos, but couldn’t get it to work on Haiku until now. On my old Mac, pystone runs at double speed when compiled with nuitka. So, depending on the kind of python application, it could indeed make a difference in terms of performance.