Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

force unpacking of certain egg directories

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?

like image 201
Jeroen Dierckx Avatar asked Nov 19 '09 10:11

Jeroen Dierckx


People also ask

What is egg info directory?

egg-info format: a file or directory placed adjacent to the project's code and resources, that directly contains the project's metadata.

How do I view the contents of an egg file?

You can open and view the contents of an EGG file with PView, a model and animation viewer bundled with Panda3D. To do so: Install Panda3D. Open a command line window.


2 Answers

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)

like image 133
PJ Eby Avatar answered Sep 28 '22 02:09

PJ Eby


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

like image 44
Jeroen Dierckx Avatar answered Sep 28 '22 01:09

Jeroen Dierckx