Protect Data Files
Your program might be using Qt and QML, or other kinds of data file loaded. With Nuitka Commercial, you can produce an executable that contains them and then also covers it under the regular constants data protection automatically.
Your program uses standard Python mechanisms from open
, pkgutil
,
pkg_resources
, importlib.resources
or importlib_resources
and generally similar packages, and these load the data as a file or a
stream from within the binary without ever hitting the disk.
All of this is happening with your original code base, i.e. you are not
making any modification, that is incompatible with Python. Your code
will still run directly in Python during development, and during
deployment, the files are embedded by merely adding an option. One thing
you do have to do, is that you should use open
with paths created
from __file__
(which is correct anyway, and not e.g. rely on the
current directory to be where your script lives).
This means, e.g. rather than this program
PySideQmlPolarchartTest.py
qmlpolarchart/
Example-Icon.png
Example-Icon.svg
main.qml
View1.qml
View2.qml
View3.qml
you get a file layout just simply like this
PySideQmlPolarchartTest.exe
Due to constant data protection, the contents of the files will be inaccessible to anything but the program, and this is very much what people want.
In standard Nuitka, you end up with something like this. And note, that onefile mode is merely a self extracting archive, i.e. these files will be on the customer disk for inspection:
PySideQmlPolarchartTest.exe
qmlpolarchart/
Example-Icon.png
Example-Icon.svg
main.qml
View1.qml
View2.qml
View3.qml
Note
For extension modules and DLLs used, this doesn’t affect things. This
is about merely about data files. This is where --onefile
comes
in and hides these from the view and need for deployment, but it
cannot replace Nuitka commercial and its inclusion of data files
inside the main binary.
Go back to Nuitka commercial overview to learn about more features or to subscribe to Nuitka commercial.