pythonpyinstallerpython-venvpython-packaging

How can I distribute a Python application into an empty environment?


I have a python3 app that I have written I need to install on a production, linux, server. For various reasons, this linux installation is very barebones. It will not have any version of python. It will not have Docker or anything similar. I don't know why that is the case, but those are my requirements. How can I deploy my python app to this server so it will function.

I had a few ideas:

I am going to play with this last option and see if it works.


Solution

  • You could compile the .py file to an .exe file with the nuitka compiler use pip install nuitka and then you can compile the .py with nuitka --onefile --disable-console main.py you can try to leave out the --disable-console if you need the console. The Nuitka compiler doesnt compile like Pyinstaller by just packing the python interpreter. Nuitka compiles using gcc meaning c code. The .exe is then not obfuscated but actually compiled.

    Here is a proper youtube tutorial for Nuitka: https://www.youtube.com/watch?v=z2aHkuBCLN8