本文介绍了MANIFEST.in忽视了"蟒蛇的setup.py安装" - 没有安装数据文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我与非code东西简装setup.py脚本删除:

Here's my stripped-down setup.py script with non-code stuff removed:

#!/usr/bin/env python

from distutils.core import setup
from whyteboard.misc import meta


setup(
    name = 'Whyteboard',
    version = meta.version,

    packages = ['whyteboard', 'whyteboard.gui', 'whyteboard.lib', 'whyteboard.lib.pubsub',
                'whyteboard.lib.pubsub.core', 'whyteboard.lib.pubsub.utils', 'whyteboard.misc'],

    py_modules = ['whyteboard'],
    scripts = ['whyteboard.py'],
)

MANIFEST.in:

MANIFEST.in:

include *.txt
include whyteboard-help/*.*
recursive-include locale *.mo
recursive-include images *.png

当我运行蟒蛇的setup.py安装sdist我得到一个不错的名为.tar.gz带有whyteboard-0.41根文件夹,用我的语言环境/图像/和whyteboard的帮助/文件夹内。这也有我从whyteboard源码包内启动我的程序whyteboard.py脚本。

When I run "python setup.py install sdist" I get a nice .tar.gz with a "whyteboard-0.41" root folder, with my locale/ images/ and whyteboard-help/ folders inside. This also has my whyteboard.py script that launches my program from inside the whyteboard source package.

所以:

whyteboard/
 |
 | locale/
 | images
 | whyteboard-help/
 | whyteboard/
    |
    | __init__.py
    | other packages etc
 |
 | whyteboard.py
 | README
 | setup.py
 | CHANGELOG

这反映了我的程序的源代码,就是一切应该如何,以及是正确的。

This mirrors the source of my program, is how everything should be, and is correct.

然而,当我运行蟒蛇的setup.py安装无我的数据文件被写入 - 只有whyteboard源代码包,并whyteboard.py放在/usr/local/lib/python2.6/dist -packages /.

However when I run "python setup.py install" none of my data files are written - only the "whyteboard" source package, and the whyteboard.py is placed in /usr/local/lib/python2.6/dist-packages/.

在理想情况下,我想的相同的目录结构发生了什么,在DIST-包要创建的.tar.gz文件已经生成,因为这是我的计划期望如何寻找它的资源。

Ideally, I'd like the same directory structure as what's been generated in the .tar.gz file to be created in dist-packages, as this is how my program expects to look for its resources.

我怎样才能安装创建这个目录结构?这似乎是无视我的清单文件,据我可以告诉。

How can I get "install" to create this directory structure? It seems to be ignoring my manifest file, as far as I can tell.

推荐答案

另外的一些注意事项,以奈德的回答(这击中的核心问题):

Some notes in addition to Ned's answer (which hits on the core problem):

的Distutils不会在每个项目的子目录中安装Python包和模块站点包(或的dist-包在Debian / Ubuntu的):他们是直接安装到站点包,如您所见。因此,包含 whyteboard-XX 在sdi​​st目录不会在最后的安装形式存在。

Distutils does not install Python packages and modules inside a per-project subdirectory within site-packages (or dist-packages on Debian/Ubuntu): they are installed directly into site-packages, as you've seen. So the containing whyteboard-xx directory in your sdist will not exist in the final installed form.

其中的一个含义是,你应该小心说出你的 data_files 在澄清他们属于,因为这些文件/目录被​​直接安装到什么项目的方式全球站点包目录,里面没有任何含 whyteboard 目录

One implication of this is that you should be careful to name your data_files in a way that clarifies what project they belong to, because those files/directories are installed directly into the global site-packages directory, not inside any containing whyteboard directory.

或者,你可以代替使您的数据 package_data whyteboard 包(这意味着它需要生活里面的那个包,也就是旁边的 __ __初始化。PY ),然后这是没有问题的。

Or you could instead make your data package_data of the whyteboard package (which means it needs to live inside that package, i.e. next to __init__.py), and then this isn't a problem.

最后,它并没有多大意义,在 py_modules 既是 whyteboard.py 模块和 whyteboard / __ __初始化。PY 。两者是相互排斥的,如果您同时,在 whyteboard.py 模块将被进口赞成包同名的忽略。

Lastly, it doesn't make much sense to have both a whyteboard.py module in py_modules and a whyteboard/__init__.py package in packages. The two are mutually exclusive, and if you have both, the whyteboard.py module will be ignored by imports in favor of the package of the same name.

如果 whyteboard.py 只是一个脚本,并且不打算进口的,那么你应该使用的选项它,然后从 py_modules 删除它。

If whyteboard.py is just a script, and is not intended to be imported, then you should use the scripts option for it, and remove it from py_modules.

这篇关于MANIFEST.in忽视了"蟒蛇的setup.py安装" - 没有安装数据文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 00:58