在构建环境中安装 python Egg,包括数据文件
这个问题假设我要安装的 python 包是一个 django 应用程序,其中包含模板和媒体文件。但这个问题对于任何不仅包含 .py
文件的 python 包都有效。
我正在使用 buildout 创建一个可重新构建的环境,在其中开发 django 项目。我的 buildout.cfg
看起来像这样:(
[buildout]
parts = python
eggs =
normal-python-package
python-package-with-data-files
find-files =
http://domain-to-python-package-with-data-files
[python]
recipe = zc.recipe.egg
interpreter = python
eggs = ${buildout:eggs}
以及一些 django 相关的东西)。 python-package-with-data-files
可通过 http://domain-to-python-package-with-data-files
页面上的链接获取。
Eggs normal-python-package
和 python-package-with-data-files
已成功安装在 eggs/
目录中。因为 python-package-with-data-files
已在其 setup.py
文件中将 zip_safe
设置为 False
解压后可在 eggs/
中找到。
只有 python-package-with-data-files
的非 .py
文件在 eggs/
解压后的 Egg 中不可用(它们 < em>包含在 .tar.gz
包中,该包位于 http://domain-to-python-package-with-data-files
)。
如何将这些数据文件包含在 Egg 中?我需要更改包的 setup.py
文件吗?还是与扩建有关?
我发现的事情如下:
如果我在python-package-with-data-files
根目录中创建python setup.py sdist
,则所有数据文件都包含在内在创建的 .tar.gz 文件中。但是,如果我创建一个 python setup.py bdist ,它会导致构建不包含数据文件。
这让我认为问题不是特定于扩建的。但也许有一种方法可以告诉 buildout 不要创建 bdist
而是创建 sdist
来创建 Egg 并将包安装到项目中。
我该怎么办?我是 python-package-with-data-files 的维护者,因此我可以根据需要更改 setup.py。
This question assumes that the python package I want to install is a django app that includes templates and media files. But the question is valid for any python package that does not only contain .py
files.
I'm using buildout to create a re-buildable environment in which I'm developing a django project. My buildout.cfg
looks like that:
[buildout]
parts = python
eggs =
normal-python-package
python-package-with-data-files
find-files =
http://domain-to-python-package-with-data-files
[python]
recipe = zc.recipe.egg
interpreter = python
eggs = ${buildout:eggs}
(and some django related stuff). The python-package-with-data-files
is available through a link on the page http://domain-to-python-package-with-data-files
.
The eggs normal-python-package
and python-package-with-data-files
are installed successfully in the eggs/
directory. Because python-package-with-data-files
has set zip_safe
to False
in its setup.py
file it is available unzipped in eggs/
.
Only the non .py
files of python-package-with-data-files
are not available in the unzipped egg in eggs/
(they are included in the .tar.gz
package available at http://domain-to-python-package-with-data-files
).
How do I get these data files to be included in the egg? Do I need to change the setup.py
file of the package? Or is it buildout related?
The things I found out are the following:
If I make a python setup.py sdist
in python-package-with-data-files
root directory, all data files are included in the created .tar.gz file. But if I make a python setup.py bdist
it results in a build without including the data files.
This makes me think that the problem is not buildout specific. But maybe there is a way to tell buildout not to make a bdist
but a sdist
to create the egg and install the package into the project.
What shall I do? I am the maintainer of python-package-with-data-files
, so I can change setup.py
if necessary.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您需要使用 package_data 关键字参数 在你的 setup.py 文件中,所以 distutils 知道这些文件应该与你的包一起安装。
It sounds like you need to make use of the package_data keyword argument in your setup.py file, so distutils knows those files should be installed with your package.