One of the needs for any software is a way to distribute your system in a single package. I will provide a general guide on how to use Nuitka to build a python binary.
We will use the library Nuitka. Nuitka is a Python compiler that allows us to achieve the single binary goal.
Create an entrypoint for the Nuitka.
from sample_python_binary.run import main
if __name__ == '__main__':
main()
Run the following command to build the package
time env/bin/python -m nuitka \
--onefile \
--include-data-files=data_dir/ml_model.txt=data_dir/ \
--include-data-files=data_dir/sample_license=data_dir/ \
--include-module=sqlalchemy.sql.default_comparator \
--include-module=sqlalchemy.dialects \
--linux-onefile-icon=data_dir/python3.xpm \
sample_binary.py # the entrypoint you have created earlier
Once you have run the program above you will now have compiled version of your python application.
As mentioned, Nuitka does a good job of compiling your application but it has some nuances that you need to look out for.