On Thursday, July 5, 2012 10:01:02 AM UTC+1, Richard Jones wrote:
>
> It may be that pyglet.resource needs to be made virtualenv- and 
> setuptools-aware since it was written before those came into broad 
> use. 
>
>
>
Thanks for the info and background, Richard and Andy. Reassuring to see 
that I'm not simply swimming against the current.

I'll therefore think I ought to sidestep pyglet.resource, overcome my 
revulsion and use package_data rather than data_files, and use 
pkg_resources.resource_stream to load images. Hence:

First I moved 'data' dir into 'tanks' dir. (which I regarded as 'yuck', but 
I'm getting used to it. I feel as though setuptools makes this sort of data 
easier to deal with than 'data_files')

Then in my source, I load images using:

    from pkg_resources import resource_stream
    image_stream = resource_stream('tanks', 'data/%s.png' % (name,))
    image = pyglet.image.load('%s.png' % (name,), image_stream)

(where 'tanks' is the name of my project's top-level package)

This works for running in development. For this to work on an installed 
package, I also added a MANIFEST.in:
(so that the images get included in my sdist zip file)

    include tanks/data/*.*

And lines to my setup.py config dictionary:
(so that the images are installed from the sdist to the target python's 
site-packages or virtualenv)

    include_package_data=True,

And I think that's it. Works for me, even though the data files are 
installed inside an '.egg' zipfile. Thanks for chatting me through it.

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/pyglet-users/-/PsItqi7GpkAJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en.

Reply via email to