summaryrefslogtreecommitdiff
path: root/setuptools/command/egg_info.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2022-02-06 12:43:29 -0500
committerJason R. Coombs <jaraco@jaraco.com>2022-02-06 13:46:02 -0500
commitb257d137ae2bcf1ef2e188f20e60f3ca5770e090 (patch)
tree4f5bf0e3c019814e1ad92d1060843cf0ef088417 /setuptools/command/egg_info.py
parent161ff0ff6f679967d323e9fd461eff312d0f12e6 (diff)
downloadpython-setuptools-git-b257d137ae2bcf1ef2e188f20e60f3ca5770e090.tar.gz
In egg_info, port use of pkg_resources.EntryPoint to importlib.metadata
Diffstat (limited to 'setuptools/command/egg_info.py')
-rw-r--r--setuptools/command/egg_info.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py
index afab5cd6..2ed58eef 100644
--- a/setuptools/command/egg_info.py
+++ b/setuptools/command/egg_info.py
@@ -16,8 +16,10 @@ import io
import warnings
import time
import collections
+import operator
from .._importlib import metadata
+from .._itertools import ensure_unique
from setuptools import Command
from setuptools.command.sdist import sdist
@@ -26,7 +28,7 @@ from setuptools.command.setopt import edit_config
from setuptools.command import bdist_egg
from pkg_resources import (
Requirement, safe_name, parse_version,
- safe_version, yield_lines, EntryPoint, to_filename)
+ safe_version, yield_lines, to_filename)
import setuptools.unicode_utils as unicode_utils
from setuptools.glob import glob
@@ -721,8 +723,14 @@ def entry_point_definition_to_str(value):
Given a value of an entry point or series of entry points,
return each entry point on a single line.
"""
- parsed = EntryPoint.parse_group('anything', value)
- return '\n'.join(sorted(map(str, parsed.values())))
+ # normalize to a single sequence of lines
+ lines = yield_lines(value)
+ parsed = metadata.EntryPoints._from_text('[x]\n' + '\n'.join(lines))
+ valid = ensure_unique(parsed, key=operator.attrgetter('name'))
+
+ def ep_to_str(ep):
+ return f'{ep.name} = {ep.value}'
+ return '\n'.join(sorted(map(ep_to_str, valid)))
entry_point_definition_to_str.register(str, lambda x: x)