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
10957d5a
Commit
10957d5a
authored
Jan 22, 2023
by
David Hotham
Committed by
Bjorn Neergaard
Jan 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't uninstall packages that should be kept
parent
196d6660
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
4 deletions
+35
-4
src/poetry/puzzle/transaction.py
+10
-4
tests/puzzle/test_transaction.py
+25
-0
No files found.
src/poetry/puzzle/transaction.py
View file @
10957d5a
...
@@ -74,6 +74,7 @@ class Transaction:
...
@@ -74,6 +74,7 @@ class Transaction:
operations
.
append
(
Install
(
result_package
,
priority
=
priority
))
operations
.
append
(
Install
(
result_package
,
priority
=
priority
))
if
with_uninstalls
:
if
with_uninstalls
:
uninstalls
:
set
[
str
]
=
set
()
for
current_package
in
self
.
_current_packages
:
for
current_package
in
self
.
_current_packages
:
found
=
any
(
found
=
any
(
current_package
.
name
==
result_package
.
name
current_package
.
name
==
result_package
.
name
...
@@ -83,11 +84,12 @@ class Transaction:
...
@@ -83,11 +84,12 @@ class Transaction:
if
not
found
:
if
not
found
:
for
installed_package
in
self
.
_installed_packages
:
for
installed_package
in
self
.
_installed_packages
:
if
installed_package
.
name
==
current_package
.
name
:
if
installed_package
.
name
==
current_package
.
name
:
uninstalls
.
add
(
installed_package
.
name
)
operations
.
append
(
Uninstall
(
current_package
))
operations
.
append
(
Uninstall
(
current_package
))
if
synchronize
:
if
synchronize
:
curren
t_package_names
=
{
resul
t_package_names
=
{
current_package
.
name
for
current_package
in
self
.
_curren
t_packages
result_package
.
name
for
result_package
,
_
in
self
.
_resul
t_packages
}
}
# We preserve pip/setuptools/wheel when not managed by poetry, this is
# We preserve pip/setuptools/wheel when not managed by poetry, this is
# done to avoid externally managed virtual environments causing
# done to avoid externally managed virtual environments causing
...
@@ -96,9 +98,12 @@ class Transaction:
...
@@ -96,9 +98,12 @@ class Transaction:
"pip"
,
"pip"
,
"setuptools"
,
"setuptools"
,
"wheel"
,
"wheel"
,
}
-
curren
t_package_names
}
-
resul
t_package_names
for
installed_package
in
self
.
_installed_packages
:
for
installed_package
in
self
.
_installed_packages
:
if
installed_package
.
name
in
uninstalls
:
continue
if
(
if
(
self
.
_root_package
self
.
_root_package
and
installed_package
.
name
==
self
.
_root_package
.
name
and
installed_package
.
name
==
self
.
_root_package
.
name
...
@@ -108,7 +113,8 @@ class Transaction:
...
@@ -108,7 +113,8 @@ class Transaction:
if
installed_package
.
name
in
preserved_package_names
:
if
installed_package
.
name
in
preserved_package_names
:
continue
continue
if
installed_package
.
name
not
in
current_package_names
:
if
installed_package
.
name
not
in
result_package_names
:
uninstalls
.
add
(
installed_package
.
name
)
operations
.
append
(
Uninstall
(
installed_package
))
operations
.
append
(
Uninstall
(
installed_package
))
return
sorted
(
return
sorted
(
...
...
tests/puzzle/test_transaction.py
View file @
10957d5a
...
@@ -121,6 +121,31 @@ def test_it_should_remove_installed_packages_if_required():
...
@@ -121,6 +121,31 @@ def test_it_should_remove_installed_packages_if_required():
)
)
def
test_it_should_not_remove_installed_packages_that_are_in_result
():
transaction
=
Transaction
(
[],
[
(
Package
(
"a"
,
"1.0.0"
),
1
),
(
Package
(
"b"
,
"2.0.0"
),
2
),
(
Package
(
"c"
,
"3.0.0"
),
0
),
],
installed_packages
=
[
Package
(
"a"
,
"1.0.0"
),
Package
(
"b"
,
"2.0.0"
),
Package
(
"c"
,
"3.0.0"
),
],
)
check_operations
(
transaction
.
calculate_operations
(
synchronize
=
True
),
[
{
"job"
:
"install"
,
"package"
:
Package
(
"a"
,
"1.0.0"
),
"skipped"
:
True
},
{
"job"
:
"install"
,
"package"
:
Package
(
"b"
,
"2.0.0"
),
"skipped"
:
True
},
{
"job"
:
"install"
,
"package"
:
Package
(
"c"
,
"3.0.0"
),
"skipped"
:
True
},
],
)
def
test_it_should_update_installed_packages_if_sources_are_different
():
def
test_it_should_update_installed_packages_if_sources_are_different
():
transaction
=
Transaction
(
transaction
=
Transaction
(
[
Package
(
"a"
,
"1.0.0"
)],
[
Package
(
"a"
,
"1.0.0"
)],
...
...
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