PyPy 和 PyInstaller [英] PyPy and PyInstaller
问题描述
是否可以使用 PyInstaller
构建一个使用 pypy
作为解释器的单二进制或单目录包?
Is it possible to build a single-binary or single-directory package with PyInstaller
that uses pypy
as interpreter?
有什么特别的技巧可以做到这一点吗?
Any special tricks to do that?
PyInstaller
的替代品?
如果不是,那么基本的技术原因是什么?
If not, what are the fundamental technical reasons?
注意为什么/如何 pyinstaller 没有开箱即用的 pypy:
Notes why/how pyinstaller doesn't doesn't with pypy out of the box:
- distutils.sysconfig.get_config_h_filename 丢失,已在 pytinstaller 主干中修复
- (distutils.|)sysconfig.(_|)get_makefile_filename 缺失,实际上是可选的
- 尝试在单个可执行文件中链接 libpython2.7.so.1、pypy,而不是共享对象
推荐答案
我已经尝试过这个,但在很多情况下都失败了,因为 PyPy 只能使用 CPython 使用的几个子集.PyInstaller 是一个完整的 CPython 应用程序,因此无法进行通信.
I have tried this out and it failed, on many occasions, because PyPy is only able to work with a few subset of what CPython uses. PyInstaller is a full blown CPython application, so there are not able to communicate.
PyInstaller 的机制对 CPython 的工作方式很敏感,因此 PyPy 可能会引入一些问题.这是尝试在 PyPy 虚拟环境中运行 PyInstaller 时会得到的结果:
PyInstaller's mechanism is sensitive to how CPython works, so PyPy can introduce some issues. This is what you'll get when trying to run PyInstaller in a PyPy virtual environment:
OSError: Python library not found: Python, .Python, libpython3.5.dylib,
libpython3.5m.dylib
This would mean your Python installation doesn't come with proper library files.
This usually happens by missing development package, or unsuitable build
parameters of Python installation.
* On Debian/Ubuntu, you would need to install Python development packages
* apt-get install python3-dev
* apt-get install python-dev
* If you're building Python by yourself, please rebuild your Python with
`--enable-shared` (or, `--enable-framework` on Darwin)
如果您需要提高速度并将您的代码隐藏起来,您可以尝试赛通.我经常使用 Cython 和 PyInstaller,我喜欢它们的跨平台性质.
If you need improved speed and hiding your code away from people, you can try out Cython. I use both Cython and PyInstaller a lot, and I love their cross platform nature.
当您完成这两个操作后,您就可以使用 PyInstaller &CPython 来打包您的应用.
When you are through with both, you can then use PyInstaller & CPython to package your app.
这篇关于PyPy 和 PyInstaller的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!