On Mon, Apr 26, 2021 at 9:37 AM Baptiste Carvello < devel2021@baptiste-carvello.net> wrote:
Hi,
sorry for being late to the party, but I may not be the only one wondering…
Le 14/04/2021 à 20:56, Barry Warsaw a écrit :
I’d forgotten that this PEP was in Deferred state. I think it should be
rejected and I plan on making that change. importlib.metadata is a much better approach to programmatically determining package versions.
https://docs.python.org/3/library/importlib.metadata.html#distribution-versi...
This is indeed the correct approach, thanks for letting me learn this.
However, I unsuccessfully searched for the canonical way to look up the distribution name based on either a module name or an imported module object. Is there one?
If you mean how to tie a module back to its name on PyPI, you should be able to look up the "Name" in the project's metadata: https://docs.python.org/3/library/importlib.metadata.html#distribution-metad... . -Brett
Looks like it could be computed based on information in "*.egg-info/installed-files.txt", but it's far from trivial. Is "installed-files.txt" even guaranteed to exist for all distributions?
Cheers, Baptiste _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/SVQ777EG... Code of Conduct: http://python.org/psf/codeofconduct/