Skip to content

Commit

Permalink
fix: cache URLs on Windows
Browse files Browse the repository at this point in the history
Closes python-poetry#4479

The previous implementation would fail to install packages on Windows
because it creates a `Path` starting with a slash. Such a `Path` is
invalid on Windows. Instead, use the utility function url_to_path.
  • Loading branch information
serverwentdown committed Nov 12, 2021
1 parent 51a112f commit 76e9560
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions poetry/installation/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from poetry.core.packages.file_dependency import FileDependency
from poetry.core.packages.package import Package
from poetry.core.packages.utils.utils import url_to_path
from poetry.core.packages.utils.link import Link
from poetry.core.pyproject.toml import PyProjectTOML
from poetry.utils._compat import decode
Expand Down Expand Up @@ -678,10 +679,10 @@ def _download_link(self, operation: Union[Install, Update], link: Link) -> Link:
return archive

@staticmethod
def _validate_archive_hash(archive: Path, package: Package) -> str:
def _validate_archive_hash(archive: Union[Path, Link], package: Package) -> str:
file_dep = FileDependency(
package.name,
Path(archive.path) if isinstance(archive, Link) else archive,
url_to_path(archive.url) if isinstance(archive, Link) else archive,
)
archive_hash = "sha256:" + file_dep.hash()
known_hashes = {f["hash"] for f in package.files}
Expand Down

0 comments on commit 76e9560

Please sign in to comment.