Skip to content

Commit

Permalink
normalized name when registering package at upload
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby authored and neersighted committed Oct 6, 2022
1 parent 1215ba8 commit 8e8aa44
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
12 changes: 5 additions & 7 deletions src/poetry/publishing/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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.')
Expand Down
3 changes: 1 addition & 2 deletions tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
)
]
Expand Down

0 comments on commit 8e8aa44

Please sign in to comment.