Skip to content

Commit ba6e1a5

Browse files
authored
Normalise package name before comparison (#568)
* Normalise package name before comparison * Use `canonicalize_name` from `packaging`
1 parent e727e21 commit ba6e1a5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

jupyter_releaser/lib.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from typing import Type, Union
1717

1818
import mdformat
19+
from packaging.utils import canonicalize_name
1920
from packaging.version import parse as parse_version
2021
from pkginfo import SDist, Wheel
2122

@@ -396,7 +397,7 @@ def publish_assets(
396397

397398
res = python_package.split(":")
398399
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 ""
400401

401402
if release_url and len(glob(f"{dist_dir}/*.whl")):
402403
twine_token = python.get_pypi_token(release_url, python_package_path)
@@ -427,7 +428,8 @@ def publish_assets(
427428
dist: Union[Type[SDist], Type[Wheel]]
428429
dist = SDist if suffix == ".gz" else Wheel
429430
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:
431433
env = os.environ.copy()
432434
env["TWINE_PASSWORD"] = twine_token
433435
# NOTE: Do not print the env since a twine token extracted from
@@ -436,7 +438,7 @@ def publish_assets(
436438
found = True
437439
else:
438440
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 "
440442
f"jupyter releaser config: {python_package_name}. Skipping uploading dist file {path}",
441443
stacklevel=2,
442444
)

0 commit comments

Comments
 (0)