简体   繁体   English

如何在Windows中创建Python模块安装程序而不包含源文件

[英]How to create Python module installer on Windows without including source files

I would like to create a Windows Installer of my Python module (as explained here https://docs.python.org/2/distutils/builtdist.html ) without including the sources, meaning that the installer should only embed the Python bytecode. 我想创建我的Python模块的Windows Installer(如此处https://docs.python.org/2/distutils/builtdist.html所述 ),而不包括源代码,这意味着该安装程序应仅嵌入Python字节码。

I followed the solution explained here https://stackoverflow.com/a/3444346/343201 and it only works for ZIP distributions. 我遵循此处https://stackoverflow.com/a/3444346/343201解释的解决方案,它仅适用于ZIP发行版。 In other words, if I create a ZIP built distribution, I manage to exclude all sources and export only bytecode (.pyc). 换句话说,如果我创建了一个ZIP发行版,则设法排除所有源并仅导出字节码(.pyc)。 On the other hand, if I create a MSI/WININST built distribution, it will only contain sources (.py). 另一方面,如果我创建MSI / WININST构建的发行版,则它将仅包含源(.py)。

I looked at the output of bdist_wininst and looks like when creating a Windows installer, only source files are exported, bytecode is ignored. 我查看了bdist_wininst的输出,看起来就像在创建Windows安装程序时一样,仅导出源文件,忽略字节码。 Why? 为什么? Is there a way to enforce the installer to embed only bytecode and no source files? 有没有一种方法可以强制安装程序仅嵌入字节码而不嵌入源文件?

Thanks 谢谢

You can use py2exe, though it uses your script files. 您可以使用py2exe,尽管它使用了脚本文件。 It will make a .exe file and the source code stays locked. 它将生成一个.exe文件,并且源代码保持锁定状态。

You can try every way around. 您可以尝试各种方法。 Head over here and try http://www.py2exe.org/old/ 前往此处并尝试http://www.py2exe.org/old/

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM