|
7 | 7 | import os
|
8 | 8 | import re
|
9 | 9 | import sys
|
| 10 | +import contextlib |
10 | 11 | from contextlib import suppress
|
11 | 12 | from glob import iglob
|
12 | 13 | from pathlib import Path
|
|
26 | 27 | from .extern.ordered_set import OrderedSet
|
27 | 28 | from .extern.packaging.markers import InvalidMarker, Marker
|
28 | 29 | from .extern.packaging.specifiers import InvalidSpecifier, SpecifierSet
|
| 30 | +from .extern.packaging.utils import canonicalize_name, canonicalize_version |
29 | 31 | from .extern.packaging.version import Version
|
30 | 32 |
|
31 | 33 | from . import _entry_points
|
@@ -964,8 +966,28 @@ def run_command(self, command):
|
964 | 966 | # Postpone defaults until all explicit configuration is considered
|
965 | 967 | # (setup() args, config files, command line and plugins)
|
966 | 968 |
|
967 |
| - super().run_command(command) |
| 969 | + with self._override_get_fullname(): |
| 970 | + super().run_command(command) |
968 | 971 |
|
| 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 |
969 | 991 |
|
970 | 992 | class DistDeprecationWarning(SetuptoolsDeprecationWarning):
|
971 | 993 | """Class for warning about deprecations in dist in
|
|
0 commit comments