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
186a8309
Unverified
Commit
186a8309
authored
Feb 27, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an actual pip installer
parent
2a104075
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
101 additions
and
20 deletions
+101
-20
poetry/console/application.py
+3
-1
poetry/console/commands/__init__.py
+1
-0
poetry/console/commands/install.py
+1
-1
poetry/console/commands/lock.py
+32
-0
poetry/installation/installer.py
+25
-18
poetry/installation/pip_installer.py
+39
-0
No files found.
poetry/console/application.py
View file @
186a8309
...
@@ -7,6 +7,7 @@ from poetry.utils.venv import Venv
...
@@ -7,6 +7,7 @@ from poetry.utils.venv import Venv
from
.commands
import
AboutCommand
from
.commands
import
AboutCommand
from
.commands
import
InstallCommand
from
.commands
import
InstallCommand
from
.commands
import
LockCommand
class
Application
(
BaseApplication
):
class
Application
(
BaseApplication
):
...
@@ -35,7 +36,8 @@ class Application(BaseApplication):
...
@@ -35,7 +36,8 @@ class Application(BaseApplication):
return
commands
+
[
return
commands
+
[
AboutCommand
(),
AboutCommand
(),
InstallCommand
()
InstallCommand
(),
LockCommand
(),
]
]
def
do_run
(
self
,
i
,
o
)
->
int
:
def
do_run
(
self
,
i
,
o
)
->
int
:
...
...
poetry/console/commands/__init__.py
View file @
186a8309
from
.about
import
AboutCommand
from
.about
import
AboutCommand
from
.install
import
InstallCommand
from
.install
import
InstallCommand
from
.lock
import
LockCommand
poetry/console/commands/install.py
View file @
186a8309
...
@@ -17,7 +17,7 @@ class InstallCommand(Command):
...
@@ -17,7 +17,7 @@ class InstallCommand(Command):
help
=
"""The <info>install</info> command reads the <comment>poetry.lock</> file from
help
=
"""The <info>install</info> command reads the <comment>poetry.lock</> file from
the current directory, processes it, and downloads and installs all the
the current directory, processes it, and downloads and installs all the
libraries and dependencies outlined in that file. If the file does not
libraries and dependencies outlined in that file. If the file does not
exist it will look for <comment>poetry.
json
</> and do the same.
exist it will look for <comment>poetry.
toml
</> and do the same.
<info>poetry install</info>
<info>poetry install</info>
"""
"""
...
...
poetry/console/commands/lock.py
0 → 100644
View file @
186a8309
from
poetry.installation
import
Installer
from
poetry.repositories.pypi_repository
import
PyPiRepository
from
.command
import
Command
class
LockCommand
(
Command
):
"""
Locks the project dependencies.
lock
{ --no-dev : Do not install dev dependencies. }
"""
help
=
"""The <info>lock</info> command reads the <comment>poetry.toml</> file from
the current directory, processes it, and locks the depdencies in the <comment>poetry.lock</> file.
<info>poetry lock</info>
"""
def
handle
(
self
):
installer
=
Installer
(
self
.
output
,
self
.
poetry
.
package
,
self
.
poetry
.
locker
,
PyPiRepository
()
)
installer
.
update
(
True
)
installer
.
execute_operations
(
False
)
return
installer
.
run
()
poetry/installation/installer.py
View file @
186a8309
...
@@ -10,6 +10,8 @@ from poetry.puzzle.operations.operation import Operation
...
@@ -10,6 +10,8 @@ from poetry.puzzle.operations.operation import Operation
from
poetry.repositories
import
Repository
from
poetry.repositories
import
Repository
from
poetry.repositories.installed_repository
import
InstalledRepository
from
poetry.repositories.installed_repository
import
InstalledRepository
from
.pip_installer
import
PipInstaller
class
Installer
:
class
Installer
:
...
@@ -30,6 +32,8 @@ class Installer:
...
@@ -30,6 +32,8 @@ class Installer:
self
.
_dev_mode
=
True
self
.
_dev_mode
=
True
self
.
_execute_operations
=
True
self
.
_execute_operations
=
True
self
.
_installer
=
PipInstaller
(
self
.
_io
.
venv
,
self
.
_io
)
def
run
(
self
):
def
run
(
self
):
# Force update if there is no lock file present
# Force update if there is no lock file present
if
not
self
.
_update
and
not
self
.
_locker
.
is_locked
():
if
not
self
.
_update
and
not
self
.
_locker
.
is_locked
():
...
@@ -78,6 +82,19 @@ class Installer:
...
@@ -78,6 +82,19 @@ class Installer:
def
is_dev_mode
(
self
)
->
bool
:
def
is_dev_mode
(
self
)
->
bool
:
return
self
.
_dev_mode
return
self
.
_dev_mode
def
update
(
self
,
update
=
True
)
->
'Installer'
:
self
.
_update
=
update
return
self
def
is_updating
(
self
)
->
bool
:
return
self
.
_update
def
execute_operations
(
self
,
execute
=
True
)
->
'Installer'
:
self
.
_execute_operations
=
execute
return
self
def
_do_install
(
self
,
local_repo
):
def
_do_install
(
self
,
local_repo
):
locked_repository
=
Repository
()
locked_repository
=
Repository
()
# initialize locked repo if we are installing from lock
# initialize locked repo if we are installing from lock
...
@@ -113,7 +130,7 @@ class Installer:
...
@@ -113,7 +130,7 @@ class Installer:
# if they are present in the local repo
# if they are present in the local repo
# TODO
# TODO
if
ops
:
if
ops
and
self
.
_execute_operations
:
installs
=
[]
installs
=
[]
updates
=
[]
updates
=
[]
uninstalls
=
[]
uninstalls
=
[]
...
@@ -149,7 +166,8 @@ class Installer:
...
@@ -149,7 +166,8 @@ class Installer:
elif
op
.
job_type
==
'update'
:
elif
op
.
job_type
==
'update'
:
local_repo
.
add_package
(
op
.
target_package
)
local_repo
.
add_package
(
op
.
target_package
)
self
.
_execute
(
op
)
if
self
.
_execute_operations
:
self
.
_execute
(
op
)
def
_execute
(
self
,
operation
:
Operation
)
->
None
:
def
_execute
(
self
,
operation
:
Operation
)
->
None
:
"""
"""
...
@@ -160,27 +178,16 @@ class Installer:
...
@@ -160,27 +178,16 @@ class Installer:
getattr
(
self
,
f
'_execute_{method}'
)(
operation
)
getattr
(
self
,
f
'_execute_{method}'
)(
operation
)
def
_execute_install
(
self
,
operation
:
Install
)
->
None
:
def
_execute_install
(
self
,
operation
:
Install
)
->
None
:
self
.
_io
.
writeln
(
self
.
_installer
.
install
(
operation
.
package
)
f
' - Installing <info>{operation.package.name}</> '
f
'(<comment>{operation.package.full_pretty_version}</>)'
)
def
_execute_update
(
self
,
operation
:
Update
)
->
None
:
def
_execute_update
(
self
,
operation
:
Update
)
->
None
:
name
=
operation
.
target_package
.
name
self
.
_installer
.
update
(
original
=
operation
.
initial_package
.
pretty_version
operation
.
initial_package
,
target
=
operation
.
target_package
.
pretty_version
operation
.
target_package
self
.
_io
.
writeln
(
f
' - Updating <info>{name}</> '
f
'(<comment>{original}</>'
f
' -> <comment>{target}</>)'
)
)
def
_execute_uninstall
(
self
,
operation
:
Uninstall
)
->
None
:
def
_execute_uninstall
(
self
,
operation
:
Uninstall
)
->
None
:
self
.
_io
.
writeln
(
self
.
_installer
.
remove
(
operation
.
package
)
f
' - Removing <info>{operation.package.name}</> '
f
'(<comment>{operation.package.full_pretty_version}</>)'
)
def
_get_operations_from_lock
(
self
,
def
_get_operations_from_lock
(
self
,
locked_repository
:
Repository
locked_repository
:
Repository
...
...
poetry/installation/pip_installer.py
0 → 100644
View file @
186a8309
from
poetry.utils.venv
import
Venv
class
PipInstaller
:
def
__init__
(
self
,
venv
:
Venv
,
io
):
self
.
_venv
=
venv
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
:
return
self
.
_venv
.
run
(
'pip'
,
*
args
)
def
requirement
(
self
,
package
)
->
str
:
return
f
'{package.name}=={package.version}'
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