On Mon, Jul 11, 2011 at 12:33 AM, P.J. Eby firstname.lastname@example.org wrote:
At 09:25 PM 7/10/2011 +0200, cool-RR wrote:
I want to use `pkg_resources` to retrieve an image file from a Python package. But I want to do this without importing the actual package. Is this possible using `pkg_resources`, or does it import the package?
It imports the package, as it needs to know what loader object was used, to know whether it will be reading from a zipfile or whatever else.
Hm. Are you familiar with any other method that can be used to get resources without importing?
If you don't, then my next direction is to combine `pkg_resources` with my "module-tasting" technique; using an `__import__` hook to do a very minimialistic import of a module/package, without importing any other modules that it tries to import. Do you think that this minimalistic import will give `pkg_resources` enough data (about the loader or otherwise) to get the resources?