MANIFEST.in 在“python setup.py install"上被忽略- 没有安装数据文件? [英] MANIFEST.in ignored on "python setup.py install" - no data files installed?

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

问题描述

这是我删除了非代码内容的精简 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

当我运行python setup.py install sdist"时,我得到了一个不错的 .tar.gz 文件,里面有一个whyteboard-0.41"根文件夹,里面有我的 locale/images/和 whyteboard-help/文件夹.这也有我的whyteboard.py 脚本,它从whyteboard 源包中启动我的程序.

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.

然而,当我运行python setup.py install"时,我的数据文件都没有被写入——只有whyteboard"源包,而whyteboard.py被放置在/usr/local/lib/python2.6/dist-包/.

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-packages 中创建与在 .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.

推荐答案

除了 Ned 的回答(触及核心问题)之外的一些注释:

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

Distutils 不会在 site-packages(或 Debian/Ubuntu 上的 dist-packages)内的每个项目子目录中安装 Python 包和模块:它们是直接安装的如您所见,进入 site-packages.因此,sdist 中包含的 whyteboard-xx 目录在最终安装的形式中将不存在.

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,因为这些文件/目录直接安装到全局 站点中-packages 目录,不在任何包含 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.

或者,您可以改为制作 whyteboard 包的数据 package_data(这意味着它需要位于该包内,即 __init__.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_moduleswhyteboard/__init__.py 中同时拥有 whyteboard.py 模块没有多大意义包在 packages 中.两者是互斥的,如果两者都有,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 只是一个脚本,不打算导入,那么您应该使用 scripts 选项,并将其从 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 在“python setup.py install"上被忽略- 没有安装数据文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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