python - 强制解包某些 egg 目录

标签 python setuptools python-sphinx egg

我有一个我自己构建的 PyQt 应用程序的 egg 分发版,它包含 sphinx 生成的文档。当我从应用程序调用帮助文件时,它会在 QtWebKit.QWebView 窗口中打开 sphinx index.html。显然,只有 index.html 文件从 egg 中提取到操作系统的 egg 目录中(例如 [..]\Application Data\Python-Eggs\在 Windows 下)。

这会导致损坏的 css、损坏的图像和损坏的链接,因为这些其他文件似乎没有解压缩;它们存在于 egg 文件中,但不在 egg 目录中。

我在这里遗漏了什么吗?有没有办法立即强制解压所有 html、css、图像文件?

最佳答案

我看到您已经找到了另一种方法,但为了将来引用,这是自动执行此操作的非变通方法,来自 http://peak.telecommunity.com/DevCenter/setuptools#automatic-resource-extraction 的文档。 [重点添加]:

If you are using tools that expect your resources to be "real" files, or your project includes non-extension native libraries or other files that your C extensions expect to be able to access, you may need to list those files in the eager_resources argument to setup(), so that the files will be extracted together

因此,在这种情况下,您要做的是:

eager_resources=['doc/sphinx/build/html', 'doc/sphinx/build/html/index.html']

在您的 setup.py 中,这将导致在您请求 index.html 时递归提取“html”目录(假设您示例中的“doc”是顶级包)。

(您可以在 http://peak.telecommunity.com/DevCenter/setuptools#new-and-changed-setup-keywords 的文档中找到有关 eager_resources 关键字的更多信息)

关于python - 强制解包某些 egg 目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1762306/

相关文章:

python - django-admin.py makemessages 不创建 .po 文件

python - 为 Python 安装 pip、virtualenv 和分发的正确方法是什么?

python - Django 上的 Sphinx-apidoc 在 `django.core.exceptions.AppRegistryNotReady` 上构建 html 失败

django - 如何查看 Django 中生成的 HTML Sphinx?

java - 相当于?在 Java 中用于 Python?

python - conda中的新环境可以从基础环境继承特定的包吗

python - pandas *有效地*按组将有效值复制到其他行

python setup.py 构建忽略一些文件

python - 在 python 包中包含本地化的正确方法是什么?

python - 将 reStructuredText 解析为 HTML