gpt4 book ai didi

python - 强制解包某些 egg 目录

转载 作者:太空狗 更新时间:2023-10-30 00:58:04 25 4
gpt4 key购买 nike

我有一个我自己构建的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com