Skip to content

Commit

Permalink
Prefer setuptools._normalization instead of pkg_resources in egg_info.py
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Jan 23, 2023
1 parent daadc5a commit 61ad58b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions setuptools/command/egg_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import collections

from .._importlib import metadata
from .. import _entry_points
from .. import _entry_points, _normalization

from setuptools import Command
from setuptools.command.sdist import sdist
Expand Down Expand Up @@ -125,10 +125,11 @@ class InfoCommon:

@property
def name(self):
return safe_name(self.distribution.get_name())
return _normalization.safe_name(self.distribution.get_name())

def tagged_version(self):
return safe_version(self._maybe_tag(self.distribution.get_version()))
tagged = self._maybe_tag(self.distribution.get_version())
return _normalization.best_effort_version(tagged)

def _maybe_tag(self, version):
"""
Expand All @@ -148,7 +149,7 @@ def _already_tagged(self, version: str) -> bool:
def _safe_tags(self) -> str:
# To implement this we can rely on `safe_version` pretending to be version 0
# followed by tags. Then we simply discard the starting 0 (fake version number)
return safe_version(f"0{self.vtags}")[1:]
return _normalization.best_effort_version(f"0{self.vtags}")[1:]

def tags(self) -> str:
version = ''
Expand Down Expand Up @@ -233,7 +234,7 @@ def finalize_options(self):
self.egg_base = (dirs or {}).get('', os.curdir)

self.ensure_dirname('egg_base')
self.egg_info = to_filename(self.egg_name) + '.egg-info'
self.egg_info = self.egg_name.replace("-", "_") + '.egg-info'
if self.egg_base != os.curdir:
self.egg_info = os.path.join(self.egg_base, self.egg_info)
if '-' in self.egg_name:
Expand Down

0 comments on commit 61ad58b

Please sign in to comment.