17
17
from cleo .io .null_io import NullIO
18
18
from poetry .core .packages .file_dependency import FileDependency
19
19
from poetry .core .packages .utils .link import Link
20
- from poetry .core .packages .utils .utils import url_to_path
21
20
from poetry .core .pyproject .toml import PyProjectTOML
22
21
23
22
from poetry .installation .chef import Chef
@@ -114,7 +113,7 @@ def verbose(self, verbose: bool = True) -> Executor:
114
113
return self
115
114
116
115
def pip_install (
117
- self , req : Path | Link , upgrade : bool = False , editable : bool = False
116
+ self , req : Path , upgrade : bool = False , editable : bool = False
118
117
) -> int :
119
118
try :
120
119
pip_install (req , self ._env , upgrade = upgrade , editable = editable )
@@ -463,7 +462,7 @@ def _install(self, operation: Install | Update) -> int:
463
462
if package .source_type == "git" :
464
463
return self ._install_git (operation )
465
464
466
- archive : Link | Path
465
+ archive : Path
467
466
if package .source_type == "file" :
468
467
archive = self ._prepare_file (operation )
469
468
elif package .source_type == "url" :
@@ -606,15 +605,15 @@ def _install_git(self, operation: Install | Update) -> int:
606
605
607
606
return status_code
608
607
609
- def _download (self , operation : Install | Update ) -> Link | Path :
608
+ def _download (self , operation : Install | Update ) -> Path :
610
609
link = self ._chooser .choose_for (operation .package )
611
610
612
611
return self ._download_link (operation , link )
613
612
614
- def _download_link (self , operation : Install | Update , link : Link ) -> Link | Path :
613
+ def _download_link (self , operation : Install | Update , link : Link ) -> Path :
615
614
package = operation .package
616
615
617
- archive : Link | Path | None
616
+ archive : Path | None
618
617
archive = self ._chef .get_cached_archive_for_link (link )
619
618
if archive is None :
620
619
# No cached distributions was found, so we download and prepare it
@@ -638,20 +637,14 @@ def _download_link(self, operation: Install | Update, link: Link) -> Link | Path
638
637
return archive
639
638
640
639
@staticmethod
641
- def _validate_archive_hash (archive : Path | Link , package : Package ) -> str :
642
- archive_path = (
643
- url_to_path (archive .url ) if isinstance (archive , Link ) else archive
644
- )
645
- file_dep = FileDependency (
646
- package .name ,
647
- archive_path ,
648
- )
640
+ def _validate_archive_hash (archive : Path , package : Package ) -> str :
641
+ file_dep = FileDependency (package .name , archive )
649
642
archive_hash : str = "sha256:" + file_dep .hash ()
650
643
known_hashes = {f ["hash" ] for f in package .files }
651
644
652
645
if archive_hash not in known_hashes :
653
646
raise RuntimeError (
654
- f"Hash for { package } from archive { archive_path .name } not found in"
647
+ f"Hash for { package } from archive { archive .name } not found in"
655
648
f" known hashes (was: { archive_hash } )"
656
649
)
657
650
0 commit comments