Nuitka Python compiler đź‘Ť

I’ve spent a few hours today trying out Nuitka, compiling a few apps I’d previously created in Python. So far the only hiccup has been that it always seems to include Tk even when it’s not used (which is not a big deal imo).

If you’re unfamiliar with Nuitka: “It translates Python into a C program that then is linked against libpython to execute exactly like CPython”

The distribution folder it outputs seems to start at around 24mb on Win64 (4mb of which is the unrequired Tk libs) and that almost doubled for an app I have that uses wx widgets. The output is a folder containing an *.exe file along with any necessary *.dll and *.pyd files. If you’re unfamiliar with *.pyd it’s really just a *.dll containing function(s) with a specific signature that enables Python to import from it.

So far I’m really impressed with what Nuitka does and how easy it is to use.

1 Like

Cool !
Packaging an exe was always the pain in the butt as far as I’m concerned with python
Does it generate any other executable types (ie/ macOS app bundles ?)

1 Like

Not gonna lie, I’d love nothing more than for the Xojo diaspora to land on python and become a resource for my never-ending questions. Django is on my list of things to-do.

This page has the various downloads.

MacOS says the following:

No installer is available for macOS. Use the source packages, clone from git, or use PyPI.

I’ve only tried it on Windows 10 but I guess it detects the platform it’s running on and builds for that. On Mac I think you have to install with pip:
pip install -U nuitka

Obviously you’ll need a C compiler. On Win10 you can instruct it to fetch one and set it up:
python -m nuitka --mingw64 myapp.py
It will ask you to confirm the download / install [Y/N] and once that’s done you’re away.

After that to compile your app for distribution:
python -m nuitka --standalone --windows-disable-console myapp.py

That will create the folder myapp.dist containing myapp.exe and its dependencies.