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