From 097e1731bc12bbad2f537b6b0858ebb2996ac389 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Sun, 11 Sep 2022 16:57:16 +0100 Subject: [PATCH 1/2] don't use normalize_version() it's just a complicated way of calling version.to_string() --- src/poetry/publishing/uploader.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/poetry/publishing/uploader.py b/src/poetry/publishing/uploader.py index 566f50eec5e..0ea61361338 100644 --- a/src/poetry/publishing/uploader.py +++ b/src/poetry/publishing/uploader.py @@ -12,7 +12,6 @@ from poetry.core.masonry.metadata import Metadata from poetry.core.masonry.utils.helpers import escape_name from poetry.core.masonry.utils.helpers import escape_version -from poetry.core.utils.helpers import normalize_version from requests import adapters from requests.exceptions import ConnectionError from requests.exceptions import HTTPError @@ -78,7 +77,7 @@ def adapter(self) -> adapters.HTTPAdapter: @property def files(self) -> list[Path]: dist = self._poetry.file.parent / "dist" - version = normalize_version(self._package.version.text) + version = self._package.version.to_string() wheels = list( dist.glob( @@ -305,10 +304,7 @@ 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}-{normalize_version(self._package.version.text)}.tar.gz" # noqa: E501 - ) + file = dist / f"{self._package.name}-{self._package.version.to_string()}.tar.gz" if not file.exists(): raise RuntimeError(f'"{file.name}" does not exist.') From ab767a42cda0f4b17fd32775267fca4a8d9df851 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Sun, 11 Sep 2022 17:19:39 +0100 Subject: [PATCH 2/2] don't use escape_version() version.to_string() already gave an escaped version --- src/poetry/publishing/uploader.py | 6 +----- tests/helpers.py | 3 +-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/poetry/publishing/uploader.py b/src/poetry/publishing/uploader.py index 0ea61361338..60eee2deae4 100644 --- a/src/poetry/publishing/uploader.py +++ b/src/poetry/publishing/uploader.py @@ -11,7 +11,6 @@ from poetry.core.masonry.metadata import Metadata from poetry.core.masonry.utils.helpers import escape_name -from poetry.core.masonry.utils.helpers import escape_version from requests import adapters from requests.exceptions import ConnectionError from requests.exceptions import HTTPError @@ -80,10 +79,7 @@ def files(self) -> list[Path]: version = self._package.version.to_string() wheels = list( - dist.glob( - f"{escape_name(self._package.pretty_name)}-{escape_version(version)}" - "-*.whl" - ) + dist.glob(f"{escape_name(self._package.pretty_name)}-{version}-*.whl") ) tars = list(dist.glob(f"{self._package.pretty_name}-{version}.tar.gz")) diff --git a/tests/helpers.py b/tests/helpers.py index 05c0ea7bdd9..198fa1bc20a 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -12,7 +12,6 @@ from typing import Any from poetry.core.masonry.utils.helpers import escape_name -from poetry.core.masonry.utils.helpers import escape_version from poetry.core.packages.package import Package from poetry.core.packages.utils.link import Link from poetry.core.toml.file import TOMLFile @@ -237,7 +236,7 @@ def find_links_for_package(self, package: Package) -> list[Link]: return [ Link( f"https://foo.bar/files/{escape_name(package.name)}" - f"-{escape_version(package.version.text)}-py2.py3-none-any.whl" + f"-{package.version.to_string()}-py2.py3-none-any.whl" ) ]