为嵌入式发行版构建Python26.zip最简单的方法是什么? [英] What is the easiest way to build Python26.zip for embedded distribution?
问题描述
我使用Python作为现有C ++应用程序的插件脚本语言。我可以嵌入python解释器,如Python文档中所述。一切工作成功与初始化和解释器的初始化。但是,我无法加载模块,因为我不能将标准库压缩到一个zip文件(通常是PythonXX.zip,对应于python dll的版本号)。
I am using Python as a plug-in scripting language for an existing C++ application. I am able to embed the python interpreter as stated in the Python documentation. Everything works successfully with the initialization and de-initialization of the interpreter. I am, however, having trouble loading modules because I have not been able to zip up the standard library in to a zip file (normally PythonXX.zip, corresponding to the version number of the python dll).
在优化字节码编译之后,压缩所有标准库的最简单的方法是什么?我正在寻找一个简单的脚本或命令,为我这样做,因为我真的不想这样做手动。
What is the simplest way to zip up all of the standard library after optimized bytecode compiling? I'm looking for a simple script or command to do so for me, as I really don't want to do this by hand.
有什么想法吗?
谢谢!
推荐答案
http://peak.telecommunity.com/DevCenter/setuptools =nofollow> setuptools 创建一个egg(基本上是一个java jar为python)。 setup.py可能看起来像这样:
I would probably use setuptools to create an egg (basically a java jar for python). The setup.py would probably look something like this:
from setuptools import setup, find_packages
setup(
name='python26_stdlib',
package_dir = {'' : '/path/to/python/lib/directory'},
packages = find_packages(),
#any other metadata
)
您可以使用 python setup .py bdist_egg
。一旦你有了鸡蛋,你可以将它添加到python路径,或者你可以使用setuptools安装它。我相信这也应该为你处理pyc的生成。
You could run this using python setup.py bdist_egg
. Once you have the egg, you can either add it to the python path or you can install it using setuptools. I believe this should also handle the generation of pycs for you as well.
注意:我不会使用这个在我的系统python目录。您可能需要为此设置 virtualenv 。
NOTE: I wouldn't use this on my system python directory. You might want to set up a virtualenv for this.
这篇关于为嵌入式发行版构建Python26.zip最简单的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!