def dist_to_req(dist):
try:  <EOL><INDENT>from pip._internal.operations.freeze import FrozenRequirement<EOL><DEDENT>except ImportError:  <EOL><INDENT>from pip import FrozenRequirement<EOL><DEDENT>orig_name, dist.project_name = dist.project_name, dist.key<EOL>result = FrozenRequirement.from_dist(dist, [])<EOL>dist.project_name = orig_name<EOL>return result<EOL>
Make a pip.FrozenRequirement from a pkg_resources distribution object