将 PyPy 编译为 Exe [英] Compile PyPy to Exe

查看:52
本文介绍了将 PyPy 编译为 Exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何使用 cx_freeze 将 CPython 文件编译为 exe,但是是否可以使用 PyPy 将一个简单的程序编译为 Exe?

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 ?

推荐答案

就我所知,没有现成的方法或教程来说明如何使用 PyPy 解释器从程序创建 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.

原则上,有两种方法可以考虑使用 PyPy 的翻译来获取 EXE 文件,要么使用 PyPy 解释器,要么编写自己的 RPython 程序(PyPy 解释器本身就是一个 RPython 程序,即使用 Python 的受限子集).

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).

如果您的程序使用 RPython 的受限子集并且没有依赖项,您可以考虑使用 pypy/translator/goal 在这里您还可以找到很多 target*.py 文件.取一个并根据您的目的修改它.您可能首先想从这里开始翻译 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

如果您的程序是一个应用程序并且依赖于外部包,您应该首先尝试确保您的程序完全适用于 pypy - 并非所有外部库都受支持.然后,您可能会考虑修改 targetpypystandalone 脚本以加载您的应用程序模块.如果有疑问,请尝试在 pypy-dev 邮件列表或 irc.freenode.net 上的 #pypy 频道上寻求帮助.

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆