Distribute Python code as executable for Mac/Windows/Linux

允我心安 提交于 2019-12-12 22:40:43

问题


I am working on an interesting tool which I feel has good value and may eventually want to open source it. However, till I decide, I want to keep it "closed".

The problem is I want to code it in Python and this inherently means shipping the code. I know I can convert Python code into a binary but I want something which works across Windows / Linux / Mac

Can someone please point me to how this can be done?


回答1:


Well, Python is a scripting language, so it's not quite possible to create real .exe file.
However, you might want to compile your code to .pyc and then distribute your application. Running .pyc is the same as regular python file:

$ python code.pyc

compileall - http://docs.python.org/library/compileall.html#module-compileall
Typical usage:

python -m compileall ./

I am not sure about decompilation issues, but I assume it's possible. Java .class files can be decompiled as well.



来源:https://stackoverflow.com/questions/12089254/distribute-python-code-as-executable-for-mac-windows-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!