16
16
from typing import Type , Union
17
17
18
18
import mdformat
19
+ from packaging .utils import canonicalize_name
19
20
from packaging .version import parse as parse_version
20
21
from pkginfo import SDist , Wheel
21
22
@@ -396,7 +397,7 @@ def publish_assets(
396
397
397
398
res = python_package .split (":" )
398
399
python_package_path = res [0 ]
399
- python_package_name = res [1 ]. replace ( "-" , "_" ) if len (res ) == 2 else ""
400
+ python_package_name = canonicalize_name ( res [1 ]) if len (res ) == 2 else ""
400
401
401
402
if release_url and len (glob (f"{ dist_dir } /*.whl" )):
402
403
twine_token = python .get_pypi_token (release_url , python_package_path )
@@ -427,7 +428,8 @@ def publish_assets(
427
428
dist : Union [Type [SDist ], Type [Wheel ]]
428
429
dist = SDist if suffix == ".gz" else Wheel
429
430
pkg = dist (path )
430
- if not python_package_name or python_package_name == pkg .name :
431
+ pkg_name = canonicalize_name (pkg .name )
432
+ if not python_package_name or python_package_name == pkg_name :
431
433
env = os .environ .copy ()
432
434
env ["TWINE_PASSWORD" ] = twine_token
433
435
# NOTE: Do not print the env since a twine token extracted from
@@ -436,7 +438,7 @@ def publish_assets(
436
438
found = True
437
439
else :
438
440
warnings .warn (
439
- f"Python package name { pkg . name } does not match with name in "
441
+ f"Python package name { pkg_name } does not match with name in "
440
442
f"jupyter releaser config: { python_package_name } . Skipping uploading dist file { path } " ,
441
443
stacklevel = 2 ,
442
444
)
0 commit comments