importlib_metadata icon indicating copy to clipboard operation
importlib_metadata copied to clipboard

Document how to write a `DistributionFinder` subclass

Open pfmoore opened this issue 2 years ago • 2 comments

I've been asked to implement a meta path hook to provide metadata - see https://github.com/pfmoore/editables/issues/23.

I think that what I need to do is write a custom DistributionFinder subclass which I add to sys.meta_path. But the documentation doesn't give much help on how to do that - and a lot of the key classes appear to be undocumented. For example, PackageMetadata and EntryPoints, as well as any functions/APIs that exist to parse the contents of a METADATA (respectively entry_points.txt) file into those objects (I don't really want to reimplement that functionality myself, when it's clearly already available for the standard finders).

Could the documentation be extended to include an example of how to write a complete distribution finder?

pfmoore avatar Jan 21 '23 14:01 pfmoore

I'll see what I can do. There is one example of which I'm aware in Rinoh, although that project does seem to be exhibiting the concerns you've described. I'll take a look and see if I can't come up with a simpler example.

jaraco avatar Apr 11 '23 02:04 jaraco

I've opened https://github.com/python/cpython/pull/113187 in an attempt to document an example. Please take a look and let me know if that helps or what questions remain.

jaraco avatar Dec 15 '23 17:12 jaraco