How to determine if installed package meets specification?
pkg_resources
offers an interface require()
, which takes a package spec (name and optional version spec) and returns the resolved Distribution object, raising an exception if the package as specified isn't available (or can't be loaded). pip-run uses this behavior to determine if a particular package is available or needs to be installed. In a world without pkg_resources
it would be nice if there was a similar helper, something like installed()
, to determine if a particular package spec is installed.
I don't see how importlib_metadata
could satisfy this need without incorporating (requiring) the packaging library.
I suspect pip itself is similarly reliant on pkg_resources
for this use-case.