[Distutils] pkg_resources API use according to Nullege search engine

Vinay Sajip vinay_sajip at yahoo.co.uk
Mon Oct 1 09:35:20 CEST 2012


Daniel Holth <dholth <at> gmail.com> writes:

> resource_filename is very popular. I would have thought
> resource_stream would be more popular. Unless your package is zipped
> resource_filename is trivial to implement.

Yes, I find that odd, too. pkg_resources seems to extract files from zip into a
cache folder, then returns filenames from the location in the cache; it seems a
lot of trouble to go to just to be able to deliver a filename.

In the Resource that I implemented in distlib, I have the "path" attribute of a
resource which is analogous, though it's not directly usable as a file path for
resources in a zip. However, since the resource is available as bytes or a
stream, those applications which really need a filename (perhaps to pass to a
third-party API which expects a filename) can handle that themselves, e.g. by
saving the bytes to a temporary location and passing that to whatever needs a
filename.

Regards,

Vinay Sajip



More information about the Distutils-SIG mailing list