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
1da0690c
Unverified
Commit
1da0690c
authored
May 02, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for extras in the add command
parent
5db5c925
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
6 deletions
+65
-6
CHANGELOG.md
+1
-0
poetry/console/commands/add.py
+5
-1
poetry/repositories/repository.py
+9
-5
tests/console/commands/test_add.py
+50
-0
No files found.
CHANGELOG.md
View file @
1da0690c
...
...
@@ -7,6 +7,7 @@
-
Added the
`cache:clear`
command.
-
Added support for
`git`
dependencies in the
`add`
command.
-
Added support for
`file`
dependencies in the
`add`
command.
-
Added support for extras in the
`add`
command.
-
Added support for
`src/`
layout for packages.
-
Added automatic detection of
`.venv`
virtualenvs.
...
...
poetry/console/commands/add.py
View file @
1da0690c
...
...
@@ -15,6 +15,7 @@ class AddCommand(VenvCommand):
{ --D|dev : Add package as development dependency. }
{ --git= : The url of the Git repository. }
{ --path= : The path to a dependency. }
{ --E|extras=* : Extras to activate for the dependency. }
{ --optional : Add as an optional dependency. }
{ --allow-prereleases : Accept prereleases. }
{ --dry-run : Outputs the operations but will not execute anything
...
...
@@ -37,7 +38,7 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
packages
=
self
.
argument
(
'name'
)
is_dev
=
self
.
option
(
'dev'
)
if
(
self
.
option
(
'git'
)
or
self
.
option
(
'path'
))
and
len
(
packages
)
>
1
:
if
(
self
.
option
(
'git'
)
or
self
.
option
(
'path'
)
or
self
.
option
(
'extras'
)
)
and
len
(
packages
)
>
1
:
raise
ValueError
(
'You can only specify one package '
'when using the --git or --path options'
...
...
@@ -99,6 +100,9 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
if
self
.
option
(
'allow-prereleases'
):
constraint
[
'allows-prereleases'
]
=
True
if
self
.
option
(
'extras'
):
constraint
[
'extras'
]
=
self
.
option
(
'extras'
)
if
len
(
constraint
)
==
1
and
'version'
in
constraint
:
constraint
=
constraint
[
'version'
]
...
...
poetry/repositories/repository.py
View file @
1da0690c
...
...
@@ -46,12 +46,16 @@ class Repository(BaseRepository):
pkg_constraint
=
Constraint
(
'=='
,
package
.
version
)
if
constraint
is
None
or
constraint
.
matches
(
pkg_constraint
):
for
extra
in
extra
s
:
if
extra
in
package
.
extras
:
for
dep
in
package
.
extras
[
extra
]
:
dep
.
activate
()
for
dep
in
package
.
require
s
:
for
extra
in
extras
:
if
extra
not
in
package
.
extras
:
continue
package
.
requires
+=
package
.
extras
[
extra
]
reqs
=
package
.
extras
[
extra
]
for
req
in
reqs
:
if
req
==
dep
.
name
:
dep
.
activate
()
packages
.
append
(
package
)
...
...
tests/console/commands/test_add.py
View file @
1da0690c
...
...
@@ -253,3 +253,53 @@ Writing lock file
assert
content
[
'dependencies'
][
'demo'
]
==
{
'path'
:
'../distributions/demo-0.1.0.tar.gz'
}
def
test_add_constraint_with_extras
(
app
,
repo
,
installer
):
command
=
app
.
find
(
'add'
)
tester
=
CommandTester
(
command
)
cachy2
=
get_package
(
'cachy'
,
'0.2.0'
)
cachy2
.
extras
=
{
'msgpack'
:
[
'msgpack-python'
]
}
msgpack_dep
=
get_dependency
(
'msgpack-python'
,
'>=0.5 <0.6'
,
optional
=
True
)
cachy2
.
requires
=
[
msgpack_dep
,
]
repo
.
add_package
(
get_package
(
'cachy'
,
'0.1.0'
))
repo
.
add_package
(
cachy2
)
repo
.
add_package
(
get_package
(
'msgpack-python'
,
'0.5.3'
))
tester
.
execute
([
(
'command'
,
command
.
get_name
()),
(
'name'
,
[
'cachy=0.2.0'
]),
(
'--extras'
,
[
'msgpack'
])
])
expected
=
"""
\
Updating dependencies
Resolving dependencies
Package operations: 2 installs, 0 updates, 0 removals
Writing lock file
- Installing msgpack-python (0.5.3)
- Installing cachy (0.2.0)
"""
assert
tester
.
get_display
()
==
expected
assert
len
(
installer
.
installs
)
==
2
content
=
app
.
poetry
.
file
.
read
(
raw
=
True
)[
'tool'
][
'poetry'
]
assert
'cachy'
in
content
[
'dependencies'
]
assert
content
[
'dependencies'
][
'cachy'
]
==
{
'version'
:
'0.2.0'
,
'extras'
:
[
'msgpack'
]
}
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