[英]cx_Freeze python single file?
I've been using cx_Freeze for a while now and there is one thing I've really wanted to do: put ALL files into ONE executable that I can distribute. 我已经使用cx_Freeze已有一段时间了,我真正想做的一件事是:将所有文件放入一个我可以分发的可执行文件中。 It's not really user-friendly to send around a folder filled with 30 files, all in the same directory.
在一个文件夹中发送包含30个文件的文件夹,这些文件夹都位于同一目录中,这并不是很友好。 How can I accomplish this?
我该怎么做? Thanks.
谢谢。
It is not supported in cx_freeze. cx_freeze不支持它。 There was discussion about it on mailing list.
在邮件列表上有关于它的讨论。 As I recall, the author stated that others (PyInstaller, Py2Exe) use some dirty hacks to achieve that.
我记得,作者说其他人(PyInstaller,Py2Exe)使用一些肮脏的技巧来实现这一目标。 Some anti-virus programs can consider that behavior as a virus also.
一些防病毒程序也可以将这种行为视为病毒。
I used PyInstaller for some time, but went back to cx_freeze because of Python 2.7 support. 我使用PyInstaller已有一段时间,但是由于对Python 2.7的支持而回到了cx_freeze。 I pack everything using Inno Setup , so it is easy to distribute.
我使用Inno Setup打包所有东西,因此很容易分发。 Depends if you use Windows or not.
取决于您是否使用Windows。
Isn't this what bbfreeze
does? 这不是
bbfreeze
吗?
Tutorial here: http://www.blog.pythonlibrary.org/2010/08/19/a-bbfreeze-tutorial-build-a-binary-series/ 此处的教程: http : //www.blog.pythonlibrary.org/2010/08/19/a-bbfreeze-tutorial-build-a-binary-series/
It's actually not that hard to roll your own with Python zipimport http://docs.python.org/library/zipimport.html 实际上,使用python zipimport http://docs.python.org/library/zipimport.html滚动自己的代码并不难
You may prefer to use something like UPX which is a more general solution, not Python only. 您可能更喜欢使用UPX之类的东西,这是更通用的解决方案,而不仅仅是Python。 http://upx.sourceforge.net/
http://upx.sourceforge.net/
You can use 'bdist_msi' instead of 'build'. 您可以使用“ bdist_msi”而不是“ build”。 This will create a dist folder in the directory with a single setup application .
这将使用单个安装应用程序在目录中创建dist文件夹。
http://cx-freeze.readthedocs.io/en/latest/distutils.html http://cx-freeze.readthedocs.io/en/latest/distutils.html
According to the documentation 根据文档
cx_Freeze does not support building a single file exe, where all of the libraries for your application are embedded in one executable file.
cx_Freeze不支持构建单个文件exe,因为您的应用程序的所有库都嵌入在一个可执行文件中。
The documentation gives some options to obtain a single file. 该文档提供了一些选项来获取单个文件。
A further option under Windows is to use the bdist_msi
command to create a single Microsoft Installer file ( .msi
) for your application, as mentioned by @QuaziRabbi. Windows下的另一个选项是使用
bdist_msi
命令为您的应用程序创建单个Microsoft Installer文件( .msi
),如@QuaziRabbi所述。 This command has few cx_Freeze
-specific options documented here to customize the installer. 此命令此处记录了一些
cx_Freeze
特定于选项的选项,用于自定义安装程序。 This command overloads the bdist_msi
command of the distutils
package which itself brings some more options to customize the installer. 此命令使
distutils
软件包的bdist_msi
命令超载,该软件包本身带来了一些用于自定义安装程序的选项。 The available options are not documented, one need to look at the source code of the distutils
package. 可用选项未记录,需要查看
distutils
软件包的源代码。 Interesting examples are Use cx-freeze to create an msi that adds a shortcut to the desktop and cx_freeze bdist_msi: create registry entries? 有趣的示例是使用cx-freeze创建一个向桌面添加快捷方式的msi,以及cx_freeze bdist_msi:创建注册表项吗?
Another option is to use another tool to create a more customizable single-file installer for the frozen application after the cx_Freeze
build step. 另一种选择是在
cx_Freeze
构建步骤之后,使用另一种工具为冻结的应用程序创建更具可定制性的单文件安装程序。 The script-based tool NSIS (Nullsoft Scriptable Install System) allows one to create a very customizable installer and the use of a script means that this step can be completely automatized. 基于脚本的工具NSIS(Nullsoft可脚本安装系统)允许创建一个非常可定制的安装程序,脚本的使用意味着该步骤可以完全自动化。 @Fenisko's answers mentions another tool, and there are many more.
@Fenisko的答案提到了另一个工具,还有更多工具。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.