[英]Building a string of Python Code in PyInstaller?
I understand how we can package an .exe by pointing PyInstaller to a file. 我了解如何通过将PyInstaller指向文件来打包.exe。 Such like:
如:
c:\Python25\python c:\Users\Mike\Desktop\pyinstaller-1.4\Makespec.py -F -w sampleApp.py
However is there a way to create an .exe with only a string [and not a file]? 但是,有没有一种方法可以仅使用字符串[而不使用文件]创建.exe? Such as:
如:
string="""
print "Hello world"
"""
buildApplication(string) #Function Does not exist
To the best of my knowledge, I am afraid you won't be able to work around the need to create a temporary file with any of the existing standalone executable creation tools ( py2exe , PyInstaller and cxFreeze ). 就我所知,恐怕您将无法使用任何现有的独立可执行文件创建工具( py2exe , PyInstaller和cxFreeze )创建临时文件。
What I see as the most viable solution is a bit of security through obscurity, combining the following two techniques: 我认为最可行的解决方案是通过结合以下两种技术来提高安全性:
.pyc
) directly, instead of the plaintext .py
file, from the generated code string, using the __builtin__.compile
function (you can find on the source code of the py_compile module how to achieve this. A byte-compiled file will be significantly less useful to prying eyes than the source file. __builtin__.compile
函数从生成的代码字符串中直接创建字节码编译文件( .pyc
),而不是纯文本.py
文件(您可以在py_compile模块的源代码上找到如何实现此目的的方法。字节编译文件在撬动眼睛方面将远没有源文件有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.