force unpacking of certain egg directories
Asked Answered
C

3

5

I have an egg distribution of a PyQt application which i build myself, and it contains sphinx generated documentation. When i call the help file from the application it opens the sphinx index.html in a QtWebKit.QWebView window. Apparently, only the index.html file is extracted from the egg into the OS's egg-directory (e.g. [..]\Application Data\Python-Eggs\ under Windows).

This results in broken css, broken images, and broken links, because these other files don't seem to get unpacked; they are present in the egg file, but not in the egg-directory.

Am i missing something here? Is there a way to force unpacking all html, css, image file immediately?

Cubit answered 19/11, 2009 at 10:26 Comment(0)
O
4

I see that you've already found another way to do it, but for future reference, here's the non-workaround way to do it automatically, from the documentation at http://peak.telecommunity.com/DevCenter/setuptools#automatic-resource-extraction [emphasis added]:

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

So, in this case, what you want to do is have:

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

in your setup.py, which will cause the 'html' directory to be recursively extracted when you ask for the index.html (assuming that 'doc' in your example is a top-level package).

(You can find out more about the eager_resources keyword in the docs at http://peak.telecommunity.com/DevCenter/setuptools#new-and-changed-setup-keywords)

Obstruct answered 29/1, 2010 at 18:3 Comment(0)
C
2
def get_help_url(self):
    from pkg_resources import resource_filename
    from doc import sphinx
    import os
    from PyQt4.QtCore import QUrl
    html_path = resource_filename(sphinx.__name__, os.path.join('build', 'html'))

    return QUrl(os.path.join(html_path, 'index.html'))

instead of

    html = resource_filename(sphinx.__name__, os.path.join('build', 'html', 'index.html'))

    return QUrl(html)

did the trick

Cubit answered 20/11, 2009 at 13:58 Comment(0)
S
1

Probable cause: not all the files are included in the egg in the first place.

  • Check this by unzipping the .egg (you might need to rename it to a .zip file for that on windows). Check if all the contents are there.

  • Look at how you made the egg. Do you use a MANIFEST.in file to tell setuptools which files to include? If not, you're probably trusting on setuptools' automatic inclusion of subversion files. All subversion'ed files automatically end up in the egg, python files do to, the rest does not.

  • The sphinx documentation is probably generated, so it is not in subversion, so it doesn't get included automatically.

Two solutions:

Sanguinary answered 19/11, 2009 at 12:17 Comment(1)
thanks for the answer, but as i mentioned: "..., because these other files don't seem to get unpacked; they are present in the egg file, but not in the egg-directory." Only index.html is in this directory, nothing else (e.g. css, other html)Cubit

© 2022 - 2024 — McMap. All rights reserved.