[Distutils] pkg_resources API use according to Nullege search engine

PJ Eby pje at telecommunity.com
Tue Oct 2 21:05:53 CEST 2012


On Tue, Oct 2, 2012 at 2:44 PM, Vinay Sajip <vinay_sajip at yahoo.co.uk> wrote:
> Daniel Holth <dholth <at> gmail.com> writes:
>
>> dlopen() is the canonical example of an API that can only use a filename.
>
> Okay. Naturally there is already support for absolute paths in the file system
> for resources which are in the file system, so the question was really for
> resources in zips. Is it expected that the scenario will be quite common to get
> a .so or similar out of a package in a .zip into a cache, so that the name in the
> cache can be passed to dlopen()? Do you know of any specific PyPI distributions
> which do that, so I can look at them for testing etc?

Just install any .egg distribution containing a C extension, without
unzipping it.  (bdist_egg builds eggs with the support for this inside
them, using pkg_resources' API.)

Btw, I think you might be missing part of the point of
resource_filename() - it's not just that there are APIs (and external
programs) that need real filenames, but that there are also C APIs
that operate on OS-level file handles, so just having the bytes or a
Python stream isn't sufficient.  pkg_resources mainly included the
support for this to deal with zipped C extensions, but also to support
migrating code that still uses filenames internally for whatever
reason, or needs them to pass to command line tools or C APIs.
There's little point in making every application develop its own
configuration and implementation for file extraction.


More information about the Distutils-SIG mailing list