未从 python .egg 文件安装的包数据 [英] package data not installed from python .egg file

查看:72
本文介绍了未从 python .egg 文件安装的包数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 setuptools package_data 选项在 python 包中包含一些数据文件.然后我使用 pkg_resources 访问这些文件.当 python .egg 文件按原样安装(即仍然压缩)时,这非常有效.但是在安装过程中解压egg文件时,并没有安装数据文件.

I'm trying to include some data files in a python package using the setuptools package_data option. I'm then accessing the files with pkg_resources. This works perfectly when the python .egg file is installed as-is (i.e. still zipped). But when the egg file is unzipped during installation, the data files are not installed.

换句话说,如果我跑:

python setup.py bdist_egg
cd dist
sudo easy_install -z EnrichPy-0.1.001-py2.6.egg

然后安装了egg文件(数据安全地压缩在里面)并且一切正常.

then the egg file is installed (with the data safely zipped inside) and everything works.

另一方面,如果我跑

sudo easy_install -Z EnrichPy-0.1.001-py2.6.egg

那么数据文件没有安装.我有一个目录叫EnrichPy-0.1.001-py2.6.egg/enrichpy/ 在 dist-packages 下,但它只包含我的源文件,不包含我的数据文件.

then the data files are not installed. I have a directory called EnrichPy-0.1.001-py2.6.egg/enrichpy/ under dist-packages, but it contains only my source files, not my data files.

有人可以建议我在easy_install解压egg文件时需要做什么才能安装package_data文件吗?

Can anyone suggest what I need to do to get the package_data files to be installed when easy_install unzips the egg file?

注意事项:

该软件包可在 http://github.com/roban/EnrichPy

我可以通过运行来测试它:导入enrichpy.yieldsrichpy.yields.Data_vdHG().data如果没有错误退出,则 pkg_resources 正在查找已安装的数据.

I can test it by running: import enrichpy.yields enrichpy.yields.Data_vdHG().data If that exits without errors, then pkg_resources is finding the installed data.

推荐答案

问题得到解决,感谢来自 distutils-sig 电子邮件列表中的 P.J. Eby 的帮助:

Problem solved, thanks to help from P.J. Eby on the distutils-sig email list:

http://mail.python.org/pipermail/distutils-sig/2010-November/017054.html

只需要重命名文件以避免'..'字符串.

Just needed to rename files to avoid the '..' string.

这篇关于未从 python .egg 文件安装的包数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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