From d33a04e6b2cef019c43e33a9c8f0cc6d66587425 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Sun, 25 Sep 2022 13:55:57 +0100 Subject: [PATCH] normalized name when registering package at upload --- src/poetry/publishing/uploader.py | 12 +++++------- tests/helpers.py | 3 +-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/poetry/publishing/uploader.py b/src/poetry/publishing/uploader.py index 4f57b370b8b..7b1e8e19048 100644 --- a/src/poetry/publishing/uploader.py +++ b/src/poetry/publishing/uploader.py @@ -77,13 +77,10 @@ def adapter(self) -> adapters.HTTPAdapter: def files(self) -> list[Path]: dist = self._poetry.file.parent / "dist" version = self._package.version.to_string() + escaped_name = distribution_name(self._package.name) - wheels = list( - dist.glob(f"{distribution_name(self._package.name)}-{version}-*.whl") - ) - tars = list( - dist.glob(f"{distribution_name(self._package.name)}-{version}.tar.gz") - ) + wheels = list(dist.glob(f"{escaped_name}-{version}-*.whl")) + tars = list(dist.glob(f"{escaped_name}-{version}.tar.gz")) return sorted(wheels + tars) @@ -303,7 +300,8 @@ def _register(self, session: requests.Session, url: str) -> requests.Response: Register a package to a repository. """ dist = self._poetry.file.parent / "dist" - file = dist / f"{self._package.name}-{self._package.version.to_string()}.tar.gz" + escaped_name = distribution_name(self._package.name) + file = dist / f"{escaped_name}-{self._package.version.to_string()}.tar.gz" if not file.exists(): raise RuntimeError(f'"{file.name}" does not exist.') diff --git a/tests/helpers.py b/tests/helpers.py index ca3a93b9ce6..2e57f1b2356 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -11,7 +11,6 @@ from typing import TYPE_CHECKING from typing import Any -from poetry.core.masonry.utils.helpers import distribution_name from poetry.core.packages.package import Package from poetry.core.packages.utils.link import Link from poetry.core.toml.file import TOMLFile @@ -235,7 +234,7 @@ def find_packages(self, dependency: Dependency) -> list[Package]: def find_links_for_package(self, package: Package) -> list[Link]: return [ Link( - f"https://foo.bar/files/{distribution_name(package.name)}" + f"https://foo.bar/files/{package.name.replace('-', '_')}" f"-{package.version.to_string()}-py2.py3-none-any.whl" ) ]