Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: installing wheel from trailing slash url #4619

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions src/poetry/repositories/pypi_repository.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import logging
import os
import urllib.parse

from collections import defaultdict
from pathlib import Path
from pathlib import PurePath
from typing import TYPE_CHECKING
from typing import Dict
from typing import List
Expand Down Expand Up @@ -422,28 +422,35 @@ def _get_info_from_urls(self, urls: Dict[str, List[str]]) -> "PackageInfo":

return self._get_info_from_sdist(urls["sdist"][0])

@staticmethod
def _helper_filename(url: str) -> str:
"""Extract the basename of file at a url, dealing with terminal slash."""
return PurePath(urllib.parse.urlparse(url).path).name

def _get_info_from_wheel(self, url: str) -> "PackageInfo":
from poetry.inspection.info import PackageInfo

wheel_name = urllib.parse.urlparse(url).path.rsplit("/")[-1]
self._log(f"Downloading wheel: {wheel_name}", level="debug")
filename = os.path.basename(wheel_name)
self._log(
f"Downloading wheel: {url}",
level="debug",
)

with temporary_directory() as temp_dir:
filepath = Path(temp_dir) / filename
filepath = Path(temp_dir) / self._helper_filename(url)
self._download(url, str(filepath))

return PackageInfo.from_wheel(filepath)

def _get_info_from_sdist(self, url: str) -> "PackageInfo":
from poetry.inspection.info import PackageInfo

sdist_name = urllib.parse.urlparse(url).path
self._log(f"Downloading sdist: {sdist_name.rsplit('/')[-1]}", level="debug")
filename = os.path.basename(sdist_name)
self._log(
f"Downloading sdist: {url}",
level="debug",
)

with temporary_directory() as temp_dir:
filepath = Path(temp_dir) / filename
filepath = Path(temp_dir) / self._helper_filename(url)
self._download(url, str(filepath))

return PackageInfo.from_sdist(filepath)
Expand Down