I’m not following where you’re heading with the argument. There is not a standard format to serialise multiple PEP 508 requirements, so the hook treats this as an implementation detail, and makes the hook caller de-serialise for you. But dist-info has a standard format, so you can de-serialise transparently. Or are you looking for a convenience API to wrap the dist-info de-serialisation part so you don’t have to to it yourself?
import os
from importlib.metadata import Distribution
container = ... # Create an empty directory.
dist_info_name = prepare_metadata_for_build_wheel(container, ...) # Call the hook.
dist = Distribution.from_path(os.path.join(container, dist_info_name))
dist.metadata # This holds metadata.
Oops, so much for writing code on a phone and not running it I greatly overestimated my familiarity with importlib-metadata. Thanks for the correction, I was thinking about Distribution.at().
p.s. IIRC constructing a PathDistribution directly is not public API, only Distribution.at() is.
FWIW, it’s possible this specific method didn’t make it into Python 3.8, given that the relevant API was added as a result of discussion in https://discuss.python.org/t/state-of-importlib-metadata/2055; but the point of having a common shared implementation that’s available across multiple Python versions (which importlib_metadata is) stands.
And, yes, reading the issue I’d filed asking for this functionality, PathDistribution is indeed not a part of the public API.