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
aef3d1ec
Unverified
Commit
aef3d1ec
authored
Feb 27, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add update command
parent
186a8309
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
25 deletions
+70
-25
poetry/console/application.py
+2
-0
poetry/console/commands/__init__.py
+1
-0
poetry/console/commands/install.py
+1
-0
poetry/console/commands/update.py
+33
-0
poetry/installation/installer.py
+33
-9
poetry/installation/pip_installer.py
+0
-16
No files found.
poetry/console/application.py
View file @
aef3d1ec
...
...
@@ -8,6 +8,7 @@ from poetry.utils.venv import Venv
from
.commands
import
AboutCommand
from
.commands
import
InstallCommand
from
.commands
import
LockCommand
from
.commands
import
UpdateCommand
class
Application
(
BaseApplication
):
...
...
@@ -38,6 +39,7 @@ class Application(BaseApplication):
AboutCommand
(),
InstallCommand
(),
LockCommand
(),
UpdateCommand
(),
]
def
do_run
(
self
,
i
,
o
)
->
int
:
...
...
poetry/console/commands/__init__.py
View file @
aef3d1ec
from
.about
import
AboutCommand
from
.install
import
InstallCommand
from
.lock
import
LockCommand
from
.update
import
UpdateCommand
poetry/console/commands/install.py
View file @
aef3d1ec
...
...
@@ -31,5 +31,6 @@ exist it will look for <comment>poetry.toml</> and do the same.
)
installer
.
dev_mode
(
not
self
.
option
(
'no-dev'
))
installer
.
dry_run
(
self
.
option
(
'dry-run'
))
return
installer
.
run
()
poetry/console/commands/update.py
0 → 100644
View file @
aef3d1ec
from
poetry.installation
import
Installer
from
poetry.repositories.pypi_repository
import
PyPiRepository
from
.command
import
Command
class
UpdateCommand
(
Command
):
"""
Update dependencies as according to the <comment>poetry.toml</> file.
update
{ packages?* : The packages to update. }
{ --f|features=* : Features to install. }
{ --no-dev : Do not install dev dependencies. }
{ --dry-run : Outputs the operations but will not execute anything
(implicitly enables --verbose). }
"""
def
handle
(
self
):
installer
=
Installer
(
self
.
output
,
self
.
poetry
.
package
,
self
.
poetry
.
locker
,
PyPiRepository
()
)
installer
.
dev_mode
(
not
self
.
option
(
'no-dev'
))
installer
.
dry_run
(
self
.
option
(
'dry-run'
))
# Force update
installer
.
update
(
True
)
return
installer
.
run
()
poetry/installation/installer.py
View file @
aef3d1ec
...
...
@@ -98,18 +98,18 @@ class Installer:
def
_do_install
(
self
,
local_repo
):
locked_repository
=
Repository
()
# initialize locked repo if we are installing from lock
if
not
self
.
_update
:
if
not
self
.
_update
or
self
.
_locker
.
is_locked
()
:
locked_repository
=
self
.
_locker
.
locked_repository
(
self
.
_dev_mode
)
if
self
.
_update
:
self
.
_io
.
writeln
(
'<info>Updating dependencies</>'
)
solver
=
Solver
(
locked_repository
,
self
.
_io
)
request
=
self
.
_package
.
requires
if
self
.
is_dev_mode
():
request
+=
self
.
_package
.
dev_requires
if
self
.
_update
:
self
.
_io
.
writeln
(
'<info>Updating dependencies</>'
)
ops
=
solver
.
solve
(
request
,
self
.
_repository
)
else
:
self
.
_io
.
writeln
(
'<info>Installing dependencies from lock file</>'
)
...
...
@@ -130,7 +130,7 @@ class Installer:
# if they are present in the local repo
# TODO
if
ops
and
self
.
_execute_operations
:
if
ops
and
(
self
.
_execute_operations
or
self
.
_dry_run
)
:
installs
=
[]
updates
=
[]
uninstalls
=
[]
...
...
@@ -166,7 +166,6 @@ class Installer:
elif
op
.
job_type
==
'update'
:
local_repo
.
add_package
(
op
.
target_package
)
if
self
.
_execute_operations
:
self
.
_execute
(
op
)
def
_execute
(
self
,
operation
:
Operation
)
->
None
:
...
...
@@ -178,15 +177,40 @@ class Installer:
getattr
(
self
,
f
'_execute_{method}'
)(
operation
)
def
_execute_install
(
self
,
operation
:
Install
)
->
None
:
self
.
_io
.
writeln
(
f
' - Installing <info>{operation.package.name}</> '
f
'(<comment>{operation.package.full_pretty_version}</>)'
)
if
not
self
.
_execute_operations
:
return
self
.
_installer
.
install
(
operation
.
package
)
def
_execute_update
(
self
,
operation
:
Update
)
->
None
:
self
.
_installer
.
update
(
operation
.
initial_package
,
operation
.
target_package
source
=
operation
.
target_package
target
=
operation
.
target_package
self
.
_io
.
writeln
(
f
' - Updating <info>{target.name}</> '
f
'(<comment>{source.pretty_version}</>'
f
' -> <comment>{target.pretty_version}</>)'
)
if
not
self
.
_execute_operations
:
return
self
.
_installer
.
update
(
source
,
target
)
def
_execute_uninstall
(
self
,
operation
:
Uninstall
)
->
None
:
self
.
_io
.
writeln
(
f
' - Removing <info>{operation.package.name}</> '
f
'(<comment>{operation.package.full_pretty_version}</>)'
)
if
not
self
.
_execute_operations
:
return
self
.
_installer
.
remove
(
operation
.
package
)
def
_get_operations_from_lock
(
self
,
...
...
poetry/installation/pip_installer.py
View file @
aef3d1ec
...
...
@@ -8,28 +8,12 @@ class PipInstaller:
self
.
_io
=
io
def
install
(
self
,
package
):
self
.
_io
.
writeln
(
f
' - Installing <info>{package.name}</> '
f
'(<comment>{package.full_pretty_version}</>)'
)
self
.
run
(
'install'
,
self
.
requirement
(
package
),
'--no-deps'
)
def
update
(
self
,
source
,
target
):
self
.
_io
.
writeln
(
f
' - Updating <info>{target.name}</> '
f
'(<comment>{source.pretty_version}</>'
f
' -> <comment>{target.pretty_version}</>)'
)
self
.
run
(
'install'
,
self
.
requirement
(
target
),
'--no-deps'
,
'-U'
)
def
remove
(
self
,
package
):
self
.
_io
.
writeln
(
f
' - Removing <info>{package.name}</> '
f
'(<comment>{package.full_pretty_version}</>)'
)
self
.
run
(
'uninstall'
,
package
.
name
)
def
run
(
self
,
*
args
)
->
str
:
...
...
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