python / importlib_metadata

Library to access metadata for Python packages
https://importlib-metadata.readthedocs.io
Apache License 2.0
123 stars 80 forks source link

Document how to write a `DistributionFinder` subclass #427

Open pfmoore opened 1 year ago

pfmoore commented 1 year ago

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?

jaraco commented 1 year ago

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 commented 8 months ago

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.