[Distutils] pkg_resources: Loading resources in a uniform fashion

P.J. Eby pje at telecommunity.com
Fri Oct 29 05:24:33 CEST 2010

At 06:18 PM 10/28/2010 +0200, Alan Franzoni wrote:
>lately I was thinking about writing a kind of factory method for
>parsing an url and returning a resource filename or stream, something
>fs_resource = load_resource_filename("file:///etc/software/config.conf")
>pkg_resource = load_resource_filename("pkg://package.something")
>I'd like the first one to just return the file system path
>"/etc/software/config.conf", while I'd like the second one one to do
>something roughly like
>from pkg_resources import resource_filename
>return resource_filename("package", "something")
>This way it would be pretty easy to get a consistent way to describe a
>resource from a stream.
>I've got some questions:
>1) is there anything around that already does something like that?

PEAK does, but it's even less frequently updated than 
setuptools.  ;-)  There may be other things out there as well, I don't know.

>2) would you think it to be a good addition for pkg_resources, or
>would it go beyond its scope?

Way beyond scope.  It makes more sense for it to be part of a url 
management package.

>3) can you see some obvious issues?
>4) how would you handle requirements string?

More information about the Distutils-SIG mailing list