Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
d9eab03d
Commit
d9eab03d
authored
Jun 18, 2022
by
David Hotham
Committed by
Randy Döring
Jul 03, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use locally cached wheels during install
parent
ceb35868
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
16 deletions
+26
-16
src/poetry/installation/chef.py
+3
-8
src/poetry/installation/executor.py
+2
-2
tests/installation/test_chef.py
+20
-5
tests/installation/test_executor.py
+1
-1
No files found.
src/poetry/installation/chef.py
View file @
d9eab03d
...
...
@@ -25,15 +25,10 @@ class Chef:
Path
(
config
.
get
(
"cache-dir"
))
.
expanduser
()
.
joinpath
(
"artifacts"
)
)
def
get_cached_archive_for_link
(
self
,
link
:
Link
)
->
Link
:
# If the archive is already a wheel, there is no need to cache it.
if
link
.
is_wheel
:
return
link
def
get_cached_archive_for_link
(
self
,
link
:
Link
)
->
Link
|
None
:
archives
=
self
.
get_cached_archives_for_link
(
link
)
if
not
archives
:
return
link
return
None
candidates
:
list
[
tuple
[
float
|
None
,
Link
]]
=
[]
for
archive
in
archives
:
...
...
@@ -54,7 +49,7 @@ class Chef:
)
if
not
candidates
:
return
link
return
None
return
min
(
candidates
)[
1
]
...
...
src/poetry/installation/executor.py
View file @
d9eab03d
...
...
@@ -614,9 +614,9 @@ class Executor:
def
_download_link
(
self
,
operation
:
Install
|
Update
,
link
:
Link
)
->
Link
|
Path
:
package
=
operation
.
package
archive
:
Link
|
Path
archive
:
Link
|
Path
|
None
archive
=
self
.
_chef
.
get_cached_archive_for_link
(
link
)
if
archive
is
link
:
if
archive
is
None
:
# No cached distributions was found, so we download and prepare it
try
:
archive
=
self
.
_download_archive
(
operation
,
link
)
...
...
tests/installation/test_chef.py
View file @
d9eab03d
...
...
@@ -3,6 +3,8 @@ from __future__ import annotations
from
pathlib
import
Path
from
typing
import
TYPE_CHECKING
import
pytest
from
packaging.tags
import
Tag
from
poetry.core.packages.utils.link
import
Link
...
...
@@ -16,7 +18,22 @@ if TYPE_CHECKING:
from
tests.conftest
import
Config
def
test_get_cached_archive_for_link
(
config
:
Config
,
mocker
:
MockerFixture
):
@pytest.mark.parametrize
(
(
"link"
,
"cached"
),
[
(
"https://files.python-poetry.org/demo-0.1.0.tar.gz"
,
"file:///foo/demo-0.1.0-cp38-cp38-macosx_10_15_x86_64.whl"
,
),
(
"https://example.com/demo-0.1.0-cp38-cp38-macosx_10_15_x86_64.whl"
,
"file:///foo/demo-0.1.0-cp38-cp38-macosx_10_15_x86_64.whl"
,
),
],
)
def
test_get_cached_archive_for_link
(
config
:
Config
,
mocker
:
MockerFixture
,
link
:
str
,
cached
:
str
):
chef
=
Chef
(
config
,
MockEnv
(
...
...
@@ -40,11 +57,9 @@ def test_get_cached_archive_for_link(config: Config, mocker: MockerFixture):
],
)
archive
=
chef
.
get_cached_archive_for_link
(
Link
(
"https://files.python-poetry.org/demo-0.1.0.tar.gz"
)
)
archive
=
chef
.
get_cached_archive_for_link
(
Link
(
link
))
assert
Link
(
"file:///foo/demo-0.1.0-cp38-cp38-macosx_10_15_x86_64.whl"
)
==
archive
assert
Link
(
cached
)
==
archive
def
test_get_cached_archives_for_link
(
config
:
Config
,
mocker
:
MockerFixture
):
...
...
tests/installation/test_executor.py
View file @
d9eab03d
...
...
@@ -369,7 +369,7 @@ def test_executor_should_delete_incomplete_downloads(
)
mocker
.
patch
(
"poetry.installation.chef.Chef.get_cached_archive_for_link"
,
side_effect
=
lambda
link
:
link
,
side_effect
=
lambda
link
:
None
,
)
mocker
.
patch
(
"poetry.installation.chef.Chef.get_cache_directory_for_link"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment