@@ -690,7 +690,7 @@ def build_sdist(self,
690690 else :
691691 items = self .fn_sdist ()
692692
693- prefix = f'{ self .name } -{ self .version } '
693+ prefix = f'{ _normalise ( self .name ) } -{ self .version } '
694694 os .makedirs (sdist_directory , exist_ok = True )
695695 tarpath = f'{ sdist_directory } /{ prefix } .tar.gz'
696696 log2 (f'Creating sdist: { tarpath } ' )
@@ -823,7 +823,7 @@ def tag_platform(self):
823823 return ret
824824
825825 def wheel_name (self ):
826- return f'{ self .name } -{ self .version } -{ self .tag_python ()} -{ self .tag_abi ()} -{ self .tag_platform ()} .whl'
826+ return f'{ _normalise ( self .name ) } -{ self .version } -{ self .tag_python ()} -{ self .tag_abi ()} -{ self .tag_platform ()} .whl'
827827
828828 def wheel_name_match (self , wheel ):
829829 '''
@@ -852,7 +852,7 @@ def wheel_name_match(self, wheel):
852852 log2 (f'py_limited_api; { tag_python = } compatible with { self .tag_python ()= } .' )
853853 py_limited_api_compatible = True
854854
855- log2 (f'{ self .name == name = } ' )
855+ log2 (f'{ _normalise ( self .name ) == name = } ' )
856856 log2 (f'{ self .version == version = } ' )
857857 log2 (f'{ self .tag_python () == tag_python = } { self .tag_python ()= } { tag_python = } ' )
858858 log2 (f'{ py_limited_api_compatible = } ' )
@@ -861,7 +861,7 @@ def wheel_name_match(self, wheel):
861861 log2 (f'{ self .tag_platform ()= } ' )
862862 log2 (f'{ tag_platform .split ("." )= } ' )
863863 ret = (1
864- and self .name == name
864+ and _normalise ( self .name ) == name
865865 and self .version == version
866866 and (self .tag_python () == tag_python or py_limited_api_compatible )
867867 and self .tag_abi () == tag_abi
@@ -2373,6 +2373,11 @@ def _fs_mtime( filename, default=0):
23732373 return default
23742374
23752375
2376+ def _normalise (name ):
2377+ # https://packaging.python.org/en/latest/specifications/name-normalization/#name-normalization
2378+ return re .sub (r"[-_.]+" , "-" , name ).lower ()
2379+
2380+
23762381def _assert_version_pep_440 (version ):
23772382 assert re .match (
23782383 r'^([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*((a|b|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?$' ,
0 commit comments