简体   繁体   English

如何部署Python桌面应用程序?

[英]How do I deploy a Python desktop application?

I have started on a personal python application that runs on the desktop. 我已经开始在桌面上运行个人python应用程序了。 I am using wxPython as a GUI toolkit. 我使用wxPython作为GUI工具包。 Should there be a demand for this type of application, I would possibly like to commercialize it. 如果需要这种类型的应用程序,我可能希望将其商业化。

I have no knowledge of deploying "real-life" Python applications, though I have used py2exe in the past with varied success. 我不知道部署“真实”Python应用程序,虽然我过去使用过py2exe并取得了不同程度的成功。 How would I obfuscate the code? 我如何模糊代码? Can I somehow deploy only the bytecode? 我可以以某种方式只部署字节码吗?

An ideal solution would not jeopardize my intellectual property (source code), would not require a direct installation of Python (though I'm sure it will need to have some embedded interpreter), and would be cross-platform (Windows, Mac, and Linux). 一个理想的解决方案不会危及我的知识产权(源代码),不需要直接安装Python(虽然我确定它需要一些嵌入式解释器),并且是跨平台的(Windows,Mac和Linux的)。 Does anyone know of any tools or resources in this area? 有谁知道这个领域的任何工具或资源?

Thanks. 谢谢。

You can distribute the compiled Python bytecode (.pyc files) instead of the source. 您可以分发已编译的Python字节码(.pyc文件)而不是源代码。 You can't prevent decompilation in Python (or any other language, really). 你无法阻止Python(或其他任何语言)的反编译。 You could use an obfuscator like pyobfuscate to make it more annoying for competitors to decipher your decompiled source. 您可以使用像pyobfuscate这样的混淆来让竞争对手破解您的反编译源更加烦人。

As Alex Martelli says in this thread , if you want to keep your code a secret, you shouldn't run it on other people's machines. 正如Alex Martelli 在这篇帖子中所说,如果你想保密你的代码,就不应该在其他人的机器上运行它。

IIRC, the last time I used cx_Freeze it created a DLL for Windows that removed the necessity for a native Python installation. IIRC,我最后一次使用cx_Freeze它为Windows创建了一个DLL,它消除了本机Python安装的必要性。 This is at least worth checking out. 这至少值得一试。

Wow, there are a lot of questions in there: 哇,那里有很多问题:

  • It is possible to run the bytecode (.pyc) file directly from the Python interpreter, but I haven't seen any bytecode obfuscation tools available. 可以直接从Python解释器运行字节码(.pyc)文件,但我还没有看到任何可用的字节码混淆工具。

  • I'm not aware of any "all in one" deployment solution, but: 我不知道任何“一体化”部署解决方案,但是:

    • For Windows you could use NSIS( http://nsis.sourceforge.net/Main_Page ). 对于Windows,您可以使用NSIS( http://nsis.sourceforge.net/Main_Page )。 The problem here is that while OSX/*nix comes with python, Windows doesn't. 这里的问题是,虽然OSX / * nix附带python,但Windows没有。 If you're not willing to build a binary with py2exe, I'm not sure what the licensing issues would be surrounding distribution of the Python runtime environment (not to mention the technical ones). 如果您不愿意使用py2exe构建二进制文件,我不确定围绕Python运行时环境分发的许可问题(更不用说技术问题)。

    • You could package up the OS X distribution using the "bundle" format, and *NIX has it's own conventions for installing software-- typically a "make install" script. 您可以使用“bundle”格式打包OS X发行版,而* NIX有自己的安装软件约定 - 通常是“make install”脚本。

Hope that was helpful. 希望这很有帮助。

Maybe IronPython can provide something for you? 也许IronPython可以为您提供一些东西? I bet those .exe/.dll-files can be pretty locked down. 我打赌那些.exe / .dll文件可以被锁定。 Not sure how such features work on mono, thus no idea how this works on Linux/OS X... 不确定这些功能如何在单声道上工作,因此不知道这在Linux / OS X上是如何工作的......

Try to use scraZ obfuscator ( http://scraZ.me ). 尝试使用scraZ混淆器( http://scraZ.me )。 This is obfuscator for bytecode, not for source code. 这是字节码的混淆器,而不是源代码。 Free version have good, but not perfect obfuscation methods. 免费版有很好但不完美的混淆方法。 PRO version have very very strong protection for bytecode. PRO版本对字节码有很强的保护作用。 (after bytecode obfuscation a decompilation is impossible) (在字节码混淆之后,反编译是不可能的)

I have been using py2exe with good success on Windows. 我一直在使用py2exe在Windows上取得了很好的成功。 The code needs to be modified a bit so that the code analysis picks up all modules needed, but apart from that, it works. 代码需要稍微修改一下,以便代码分析能够获取所需的所有模块,但除此之外,它还可以工作。

As for Linux, there are several important distribution formats: 至于Linux,有几种重要的分发格式:

  • DEB (Debian, Ubuntu and other derivatives) DEB(Debian,Ubuntu和其他衍生品)
  • RPM (RedHat, Fedora, openSuSE) RPM(RedHat,Fedora,openSuSE)

DEBs aren't particularly difficult to make, especially when you're already using distutils/setuptools. DEB并不是特别难以制作,特别是当您已经使用distutils / setuptools时。 Some hints are given in the policy document , examples for packaging Python applications can be found in the repository . 策略文档中给出了一些提示,可以在存储库中找到打包Python应用程序的示例。

I don't have any experience with RPM, but I'm sure there are enough examples to be found. 我对RPM没有任何经验,但我确信有足够的例子可以找到。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 Python PyQt5 应用程序部署到嵌入式 Linux? - How do I deploy a Python PyQt5 Application to an embedded Linux? 如何将python应用程序部署到外部服务器? - How do I deploy a python application to an external server? 如何在 cPanel 上部署 FastAPI 应用程序? - How do I deploy a FastAPI application on cPanel? 如何在 IIS 中部署 Flask 应用程序? - How do I deploy a Flask application in IIS? 如何以跨平台的方式为python存储桌面应用程序数据? - How do I store desktop application data in a cross platform way for python? 如何使用python-dbus在桌面应用程序中获取选定的文本? - How do I get the selected text in desktop application using python-dbus? 如何从Jenkins将Python应用程序部署到Amazon Elastic Beanstalk? - How do I deploy a Python application to Amazon Elastic Beanstalk from Jenkins? 如何将我创建的应用程序下载到桌面上的文件夹中,以便设置路径然后进行部署? - How do I download the app I created to a folder on my desktop so that I can set the path and then deploy? 如何为PyGTK桌面应用程序连贯地组织模块? - How do I coherently organize modules for a PyGTK desktop application? 如何制作便携式python桌面应用程序? - How can I make portable python desktop application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM