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
03ade36c
Unverified
Commit
03ade36c
authored
Mar 16, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the debug:resolve command
parent
b5e3d51d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
1 deletions
+112
-1
CHANGELOG.md
+1
-0
poetry/console/application.py
+10
-1
poetry/console/commands/debug/__init__.py
+1
-0
poetry/console/commands/debug/resolve.py
+100
-0
No files found.
CHANGELOG.md
View file @
03ade36c
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
-
Added support for virtualenv autogeneration (Python 3.6+ only).
-
Added support for virtualenv autogeneration (Python 3.6+ only).
-
Added the
`run`
command to execute commands inside the created virtualenvs.
-
Added the
`run`
command to execute commands inside the created virtualenvs.
-
Added the
`debug:resolve`
command to debug dependency resolution.
### Fixed
### Fixed
...
...
poetry/console/application.py
View file @
03ade36c
...
@@ -20,6 +20,8 @@ from .commands import RunCommand
...
@@ -20,6 +20,8 @@ from .commands import RunCommand
from
.commands
import
ShowCommand
from
.commands
import
ShowCommand
from
.commands
import
UpdateCommand
from
.commands
import
UpdateCommand
from
.commands.debug
import
DebugResolveCommand
class
Application
(
BaseApplication
):
class
Application
(
BaseApplication
):
...
@@ -78,7 +80,7 @@ class Application(BaseApplication):
...
@@ -78,7 +80,7 @@ class Application(BaseApplication):
def
get_default_commands
(
self
)
->
list
:
def
get_default_commands
(
self
)
->
list
:
commands
=
super
(
Application
,
self
)
.
get_default_commands
()
commands
=
super
(
Application
,
self
)
.
get_default_commands
()
return
commands
+
[
commands
+=
[
AboutCommand
(),
AboutCommand
(),
AddCommand
(),
AddCommand
(),
BuildCommand
(),
BuildCommand
(),
...
@@ -92,3 +94,10 @@ class Application(BaseApplication):
...
@@ -92,3 +94,10 @@ class Application(BaseApplication):
ShowCommand
(),
ShowCommand
(),
UpdateCommand
(),
UpdateCommand
(),
]
]
# Debug commands
commands
+=
[
DebugResolveCommand
(),
]
return
commands
poetry/console/commands/debug/__init__.py
0 → 100644
View file @
03ade36c
from
.resolve
import
DebugResolveCommand
poetry/console/commands/debug/resolve.py
0 → 100644
View file @
03ade36c
import
re
from
typing
import
List
from
poetry.packages
import
Dependency
from
poetry.puzzle
import
Solver
from
poetry.repositories.repository
import
Repository
from
poetry.semver.version_parser
import
VersionParser
from
..command
import
Command
class
DebugResolveCommand
(
Command
):
"""
Debugs dependency resolution.
debug:resolve
{ package?* : packages to resolve. }
"""
def
handle
(
self
):
packages
=
self
.
argument
(
'package'
)
if
not
packages
:
package
=
self
.
poetry
.
package
dependencies
=
package
.
requires
+
package
.
dev_requires
else
:
requirements
=
self
.
_determine_requirements
(
packages
)
requirements
=
self
.
_format_requirements
(
requirements
)
# validate requirements format
parser
=
VersionParser
()
for
constraint
in
requirements
.
values
():
parser
.
parse_constraints
(
constraint
)
dependencies
=
[]
for
name
,
constraint
in
requirements
.
items
():
dependencies
.
append
(
Dependency
(
name
,
constraint
)
)
solver
=
Solver
(
self
.
poetry
.
package
,
self
.
poetry
.
pool
,
Repository
(),
self
.
output
)
ops
=
solver
.
solve
(
dependencies
)
self
.
line
(
''
)
self
.
line
(
'Resolution results:'
)
self
.
line
(
''
)
for
op
in
ops
:
package
=
op
.
package
self
.
line
(
f
' - <info>{package.name}</info> '
f
'(<comment>{package.version}</comment>)'
)
def
_determine_requirements
(
self
,
requires
:
List
[
str
])
->
List
[
str
]:
if
not
requires
:
return
[]
requires
=
self
.
_parse_name_version_pairs
(
requires
)
result
=
[]
for
requirement
in
requires
:
if
'version'
not
in
requirement
:
requirement
[
'version'
]
=
'*'
result
.
append
(
f
'{requirement["name"]} {requirement["version"]}'
)
return
result
def
_parse_name_version_pairs
(
self
,
pairs
:
list
)
->
list
:
result
=
[]
for
i
in
range
(
len
(
pairs
)):
pair
=
re
.
sub
(
'^([^=: ]+)[=: ](.*)$'
,
'
\\
1
\\
2'
,
pairs
[
i
]
.
strip
())
pair
=
pair
.
strip
()
if
' '
in
pair
:
name
,
version
=
pair
.
split
(
' '
,
2
)
result
.
append
({
'name'
:
name
,
'version'
:
version
})
else
:
result
.
append
({
'name'
:
pair
})
return
result
def
_format_requirements
(
self
,
requirements
:
List
[
str
])
->
dict
:
requires
=
{}
requirements
=
self
.
_parse_name_version_pairs
(
requirements
)
for
requirement
in
requirements
:
requires
[
requirement
[
'name'
]]
=
requirement
[
'version'
]
return
requires
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