Skip to content

Commit cfc9a82

Browse files
committed
Try monkeypatching right before we use it instead
1 parent f0aaeb5 commit cfc9a82

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

setuptools/dist.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import os
88
import re
99
import sys
10+
import contextlib
1011
from contextlib import suppress
1112
from glob import iglob
1213
from pathlib import Path
@@ -26,6 +27,7 @@
2627
from .extern.ordered_set import OrderedSet
2728
from .extern.packaging.markers import InvalidMarker, Marker
2829
from .extern.packaging.specifiers import InvalidSpecifier, SpecifierSet
30+
from .extern.packaging.utils import canonicalize_name, canonicalize_version
2931
from .extern.packaging.version import Version
3032

3133
from . import _entry_points
@@ -964,8 +966,28 @@ def run_command(self, command):
964966
# Postpone defaults until all explicit configuration is considered
965967
# (setup() args, config files, command line and plugins)
966968

967-
super().run_command(command)
969+
with self._override_get_fullname():
970+
super().run_command(command)
968971

972+
@contextlib.contextmanager
973+
def _override_get_fullname(self):
974+
def _get_fullname_canonicalized(self):
975+
return "{}-{}".format(
976+
canonicalize_name(self.get_name()),
977+
canonicalize_version(self.get_version()),
978+
)
979+
980+
class NoValue:
981+
pass
982+
983+
orig_val = getattr(self, 'get_fullname', NoValue)
984+
self.get_fullname = _get_fullname_canonicalized.__get__(self)
985+
986+
try:
987+
yield
988+
finally:
989+
if orig_val is not NoValue:
990+
self.get_fullname = orig_val
969991

970992
class DistDeprecationWarning(SetuptoolsDeprecationWarning):
971993
"""Class for warning about deprecations in dist in

0 commit comments

Comments
 (0)