You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello!
Sorry if that’s a stupid question, please direct me if it should be asked in some different place.
Python 3.12 has dropped pkg_resources module which was providing access to installed packages info. The alternative is importlib.metadata.
I see that the latter works differently: it seems to use METADATA file inside dist-info dir, instead of parsing the package’s name and version directly from dist-info dir’s name. I see it’s most probably intended, but why does it work this way now?
The text was updated successfully, but these errors were encountered:
There are some cases where a version number isn't available or accurate in the metadata file, so importlib metadata attempts to rely on the metadata as the canonical source for all metadata, including version. Another reason for not relying on the filename is that the Python import system offers extensible interfaces for package providers such that the packages and their metadata can exist without a file system at all, where the metadata could be stored in a database for example.
If I had to guess, I expect the reason that pkg_resources relied on the version in the filename was for efficiency - if one can assume the version is in the filename, it can save many stat and read operations to extract the version from the metadata. Unfortunately, that's just not a reliable source of truth, so it's no longer used.
I hope that answers the question. I'll close this for now, but feel free to follow-up if needed.
Hello!
Sorry if that’s a stupid question, please direct me if it should be asked in some different place.
Python 3.12 has dropped
pkg_resources
module which was providing access to installed packages info. The alternative isimportlib.metadata
.I see that the latter works differently: it seems to use
METADATA
file insidedist-info
dir, instead of parsing the package’s name and version directly fromdist-info
dir’s name. I see it’s most probably intended, but why does it work this way now?The text was updated successfully, but these errors were encountered: