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:
- Create an binary with something like pyinstaller. I have heard, however, that this does not really work very well and can be flaky.
- Package up python in my install package with instructions to install it. This is not great, as it is supposed to be a zero-install package (although this might be acceptable).
- Could this be as simple as just creating a python virtual environment? It seems like that includes the python interpreter (venv/bin/python). Someone I work with told me that will not work and python still needs to be installed on host environment. Not sure why.
I am going to play with this last option and see if it works.
You could compile the .py file to an .exe file with the nuitka compiler use
pip install nuitkaand then you can compile the .py withnuitka --onefile --disable-console main.pyyou 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