问题描述
我知道如何使用cx_freeze编译CPython文件到exe,但是可以使用PyPy到Exe来编译一个简单的程序。
就我所知,没有现成的方法或教程如何从使用PyPy解释器的程序创建一个EXE。
原则上,有两种方法可以考虑使用PyPy的翻译来获取一个EXE文件,要么使用PyPy解释器或者编写自己的RPython程序(PyPy解释器本身就是一个RPython程序,即使用Python的有限子集)。
如果程序使用受限子集的RPython且没有依赖关系,您可以使用 p>
如果程序是一个应用程序,并且依赖于外部包,你应该首先尝试确保你的程序在pypy上工作 - 不是所有的外部库都支持。然后,您可以考虑修改targetpypystandalone脚本以加载应用程序模块。如果有疑问,请尝试在pypy-dev邮件列表或irc.freenode.net上的#pypy频道上获取一些帮助。
I know how to compile CPython file to exe using cx_freeze but is it possible to compile a simple program using PyPy to Exe ?
There is no ready-made way or tutorial on how to do create an EXE from a program using the PyPy interpreter, as far as i know. And it's not exactly trivial to get things going, i am afraid.
In principle, there are two ways to consider for using PyPy's translations to get a EXE file, either using the PyPy interpreter or writing your own RPython program (The PyPy interpreter is itself an RPython program, i.e. using a restricted subset of Python).
If you program uses a restricted subset of RPython and no dependencies, you could look into using the translate script in pypy/translator/goal where you'll also find a lot of target*.py files. Take one and modify it for your purposes. You might first want to play with translating python functions starting from here:
http://doc.pypy.org/en/latest/getting-started-dev.html#trying-out-the-translator
If you program is an application and depends on external packages, you should first try to make sure that your program works on pypy at all - not all external libraries are supported. You might then look into modifying the targetpypystandalone script to load your application modules. If in doubt, try to get some help on the pypy-dev mailing list or the #pypy channel on irc.freenode.net.
这篇关于编译PyPy到Exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!