Skip to content

Commit

Permalink
normalized sdist names
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Oct 5, 2022
1 parent f8ecaca commit 2529d75
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/poetry/publishing/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import requests

from poetry.core.masonry.metadata import Metadata
from poetry.core.masonry.utils.helpers import escape_name
from poetry.core.masonry.utils.helpers import distribution_name
from requests import adapters
from requests.exceptions import ConnectionError
from requests.exceptions import HTTPError
Expand Down Expand Up @@ -77,11 +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"{escape_name(self._package.pretty_name)}-{version}-*.whl")
)
tars = list(dist.glob(f"{self._package.pretty_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 @@ -301,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
4 changes: 2 additions & 2 deletions tests/console/commands/test_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def test_publish_dry_run_skip_existing(
error = app_tester.io.fetch_error()

assert "Publishing simple-project (1.2.3) to PyPI" in output
assert "- Uploading simple-project-1.2.3.tar.gz" in error
assert "- Uploading simple_project-1.2.3.tar.gz" in error
assert "- Uploading simple_project-1.2.3-py2.py3-none-any.whl" in error


Expand All @@ -125,4 +125,4 @@ def test_skip_existing_output(
assert exit_code == 0

error = app_tester.io.fetch_error()
assert "- Uploading simple-project-1.2.3.tar.gz File exists. Skipping" in error
assert "- Uploading simple_project-1.2.3.tar.gz File exists. Skipping" in error
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 escape_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/{escape_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 2529d75

Please sign in to comment.