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
6359a8bc
Unverified
Commit
6359a8bc
authored
Feb 28, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix operations solving
parent
7b606248
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
47 deletions
+48
-47
poetry/installation/installer.py
+41
-40
poetry/puzzle/solver.py
+7
-7
No files found.
poetry/installation/installer.py
View file @
6359a8bc
...
...
@@ -135,19 +135,9 @@ class Installer:
# If we are installing from lock
# Filter the operations by comparing it with what is
# currently installed
ops
=
[]
for
package
in
locked_repository
.
packages
:
ops
.
append
(
Install
(
package
))
ops
=
self
.
_get_operations_from_lock
(
locked_repository
)
for
op
in
ops
:
if
op
.
job_type
==
'install'
:
local_repo
.
add_package
(
op
.
package
)
elif
op
.
job_type
==
'update'
:
local_repo
.
add_package
(
op
.
target_package
)
elif
op
.
job_type
==
'uninstall'
:
local_repo
.
remove_package
(
op
.
package
)
ops
=
self
.
_filter_operations
(
ops
)
self
.
_populate_local_repo
(
local_repo
,
ops
,
locked_repository
)
self
.
_io
.
new_line
()
...
...
@@ -247,44 +237,55 @@ class Installer:
self
.
_installer
.
remove
(
operation
.
package
)
def
_filter_operations
(
self
,
ops
:
List
[
Operation
]
)
->
List
[
Operation
]:
installed_repo
=
InstalledRepository
.
load
(
self
.
_io
.
venv
)
new_ops
=
[]
def
_populate_local_repo
(
self
,
local_repo
,
ops
,
locked_repository
):
# Add all locked packages from the lock and go from there
for
package
in
locked_repository
.
packages
:
local_repo
.
add_package
(
package
)
# Now, walk through all operations and add/remove/update accordingly
for
op
in
ops
:
if
isinstance
(
op
,
Update
):
package
=
op
.
target_package
else
:
package
=
op
.
package
is_installed
=
False
for
installed
in
installed_repo
.
packages
:
if
package
.
name
==
installed
.
name
:
is_installed
=
True
if
op
.
job_type
==
'uninstall'
:
new_ops
.
append
(
op
)
break
if
package
.
version
!=
installed
.
version
:
new_ops
.
append
(
Update
(
installed
,
package
))
elif
package
.
category
==
'dev'
and
not
self
.
is_dev_mode
():
if
op
.
job_type
==
'uninstall'
:
new_ops
.
append
(
op
)
else
:
new_ops
.
append
(
Uninstall
(
installed
))
else
:
# Nothing to do
break
acted_on
=
False
for
pkg
in
local_repo
.
packages
:
if
pkg
.
name
==
package
.
name
:
# The package we operate on is in the local repo
if
op
.
job_type
==
'update'
:
if
pkg
.
version
==
package
.
version
:
break
if
not
is_installed
:
if
op
.
job_type
in
[
'update'
,
'uninstall'
]:
continue
local_repo
.
remove_package
(
pkg
)
local_repo
.
add_package
(
op
.
target_package
)
elif
op
.
job_type
==
'uninstall'
:
local_repo
.
remove_package
(
op
.
package
)
new_ops
.
append
(
op
)
acted_on
=
True
return
new_ops
if
not
acted_on
:
local_repo
.
add_package
(
package
)
def
_get_operations_from_lock
(
self
,
locked_repository
:
Repository
)
->
List
[
Operation
]:
installed_repo
=
InstalledRepository
.
load
(
self
.
_io
.
venv
)
ops
=
[]
for
locked
in
locked_repository
.
packages
:
is_installed
=
False
for
installed
in
installed_repo
.
packages
:
if
locked
.
name
==
installed
.
name
:
is_installed
=
True
if
locked
.
category
==
'dev'
and
not
self
.
is_dev_mode
():
ops
.
append
(
Uninstall
(
locked
))
elif
locked
.
version
!=
installed
.
version
:
ops
.
append
(
Update
(
installed
,
locked
))
if
not
is_installed
:
ops
.
append
(
Install
(
locked
))
return
ops
poetry/puzzle/solver.py
View file @
6359a8bc
...
...
@@ -16,8 +16,8 @@ from .ui import UI
class
Solver
:
def
__init__
(
self
,
install
ed
,
io
):
self
.
_
installed
=
install
ed
def
__init__
(
self
,
lock
ed
,
io
):
self
.
_
locked
=
lock
ed
self
.
_io
=
io
def
solve
(
self
,
requested
,
repository
,
fixed
=
None
)
->
List
[
Operation
]:
...
...
@@ -46,21 +46,21 @@ class Solver:
operations
=
[]
for
package
in
packages
:
process
ed
=
False
for
pkg
in
self
.
_
install
ed
.
packages
:
install
ed
=
False
for
pkg
in
self
.
_
lock
ed
.
packages
:
if
package
.
name
==
pkg
.
name
:
installed
=
True
# Checking version
if
package
.
version
!=
pkg
.
version
:
processed
=
True
operations
.
append
(
Update
(
pkg
,
package
))
break
if
not
process
ed
:
if
not
install
ed
:
operations
.
append
(
Install
(
package
))
# Checking for removals
for
pkg
in
self
.
_
install
ed
.
packages
:
for
pkg
in
self
.
_
lock
ed
.
packages
:
remove
=
True
for
package
in
packages
:
if
pkg
.
name
==
package
.
name
:
...
...
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