可以使用PyPy / RPython来生成一个小的独立可执行文件? [英] Can PyPy/RPython be used to produce a small standalone executable?

查看:755
本文介绍了可以使用PyPy / RPython来生成一个小的独立可执行文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(或者,可以使用PyPy / RPython来编译/翻译Python到C / C ++ 而不需要Python运行时?)

(Or, "Can PyPy/RPython be used to compile/translate Python to C/C++ without requiring the Python runtime?")

我试图理解PyPy与它的RPython和它的Python,它的运行,编译和翻译,有点失败。

I have tried to comprehend PyPy with its RPython and its Python, its running and its compiling and its translating, and have somewhat failed.

我有一个假设的Python项目(适用于Windows);我想保持其大小,在一百千字节(O.N.O.)的数量级,而不是使用py2exe所需的几兆字节(在UPX后)。我可以使用PyPy 1 以任何方式产生一个独立的可执行文件,不依赖于Python26.dll?如果可以,它是否需要遵循RPython限制,如 for 只处理内置类型,或者是完整的Python语法?

I have a hypothetical Python project (for Windows); I would like to keep its size down, in the order of a hundred kilobytes (O.N.O.) rather than the several megabytes that using py2exe entails (after UPX). Can I use PyPy1 in any way to produce a standalone executable which does not depend on Python26.dll? If I can, does it need to follow the RPython restrictions like for only working on builtin types, or is it full Python syntax?

我意识到,如果这可以做,我几乎肯定不能直接使用C模块从Python直接。

I do realise that if this can be done I almost certainly couldn't use C modules from Python directly.

1 (自从提出以来,情况已经变得更加清晰,这部分工具链更清楚地称为RPython而不是PyPy; 2010年不是这样。)

1 (Since the time of asking, the situation has become clearer, and this part of the toolchain is more clearly branded as RPython rather than PyPy; it wasn't so in 2010.)

推荐答案

是的,PyPy可以从RPython代码生成独立的可执行文件。这意味着,在编写代码时,您需要遵循所有尴尬的RPython规则。你的Python代码是完全不可能的开箱即用,移植现有的Python代码通常是没有乐趣。它不会使可执行文件小到C,但是例如rpystone目标(从pypy / translator /目标)使用boehm GC在64位剥离后是80k。

Yes, PyPy can produce standalone executables from RPython code. That means, you need to follow all the awkward RPython rules when it comes to writing code. Your Python code is completely unlikely to function out of the box and porting existing Python code is usually not fun. It won't make executables as small as C, but for example rpystone target (from pypy/translator/goal) using boehm GC is 80k on 64bit after stripping.

这篇关于可以使用PyPy / RPython来生成一个小的独立可执行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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