From 9dd6c85c9f9540bf8d67de9d73d91efcb90a8018 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Sun, 25 Sep 2022 13:55:57 +0100 Subject: [PATCH] normalized sdist names --- src/poetry/publishing/uploader.py | 12 ++++++------ tests/console/commands/test_publish.py | 4 ++-- ...ect-1.2.3.tar.gz => simple_project-1.2.3.tar.gz} | Bin tests/helpers.py | 3 +-- 4 files changed, 9 insertions(+), 10 deletions(-) rename tests/fixtures/simple_project/dist/{simple-project-1.2.3.tar.gz => simple_project-1.2.3.tar.gz} (100%) diff --git a/src/poetry/publishing/uploader.py b/src/poetry/publishing/uploader.py index 65163e1bd9d..7b1e8e19048 100644 --- a/src/poetry/publishing/uploader.py +++ b/src/poetry/publishing/uploader.py @@ -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 @@ -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) @@ -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.') diff --git a/tests/console/commands/test_publish.py b/tests/console/commands/test_publish.py index 559f58f323f..f4241a1a870 100644 --- a/tests/console/commands/test_publish.py +++ b/tests/console/commands/test_publish.py @@ -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 @@ -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 diff --git a/tests/fixtures/simple_project/dist/simple-project-1.2.3.tar.gz b/tests/fixtures/simple_project/dist/simple_project-1.2.3.tar.gz similarity index 100% rename from tests/fixtures/simple_project/dist/simple-project-1.2.3.tar.gz rename to tests/fixtures/simple_project/dist/simple_project-1.2.3.tar.gz diff --git a/tests/helpers.py b/tests/helpers.py index 198fa1bc20a..4854b4d136b 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 escape_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/{escape_name(package.name)}" + f"https://foo.bar/files/{package.name.replace('-', '_')}" f"-{package.version.to_string()}-py2.py3-none-any.whl" ) ]