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
20c87bc0
Unverified
Commit
20c87bc0
authored
May 22, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for specifying platform for dependencies
parent
2bfc6f8d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
134 additions
and
0 deletions
+134
-0
CHANGELOG.md
+3
-0
poetry/console/commands/add.py
+8
-0
poetry/json/schemas/poetry-schema.json
+16
-0
poetry/packages/dependency.py
+7
-0
tests/console/commands/test_add.py
+85
-0
tests/packages/test_dependency.py
+15
-0
No files found.
CHANGELOG.md
View file @
20c87bc0
...
...
@@ -9,6 +9,9 @@
-
Added a new setting
`settings.virtualenvs.in-project`
to make
`poetry`
create the project's virtualenv inside the project's directory.
-
Added the
`--extras`
and
`--python`
options to
`debug:resolve`
to help debug dependency resolution.
-
Added a
`--src`
option to new to create an
`src`
layout.
-
Added support for specifying the
`platform`
for dependencies.
-
Added the
`--python`
option to the
`add`
command.
-
Added the
`--platform`
option to the
`add`
command.
### Changed
...
...
poetry/console/commands/add.py
View file @
20c87bc0
...
...
@@ -13,6 +13,8 @@ class AddCommand(VenvCommand, InitCommand):
{ --path= : The path to a dependency. }
{ --E|extras=* : Extras to activate for the dependency. }
{ --optional : Add as an optional dependency. }
{ --python= : Python version( for which the dependencies must be installed. }
{ --platform= : Platforms for which the dependencies must be installed. }
{ --allow-prereleases : Accept prereleases. }
{ --dry-run : Outputs the operations but will not execute anything
(implicitly enables --verbose). }
...
...
@@ -98,6 +100,12 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
if
self
.
option
(
'extras'
):
constraint
[
'extras'
]
=
self
.
option
(
'extras'
)
if
self
.
option
(
'python'
):
constraint
[
'python'
]
=
self
.
option
(
'python'
)
if
self
.
option
(
'platform'
):
constraint
[
'platform'
]
=
self
.
option
(
'platform'
)
if
len
(
constraint
)
==
1
and
'version'
in
constraint
:
constraint
=
constraint
[
'version'
]
...
...
poetry/json/schemas/poetry-schema.json
View file @
20c87bc0
...
...
@@ -182,6 +182,10 @@
"type"
:
"string"
,
"description"
:
"The python versions for which the dependency should be installed."
},
"platform"
:
{
"type"
:
"string"
,
"description"
:
"The platform(s) for which the dependency should be installed."
},
"allows-prereleases"
:
{
"type"
:
"boolean"
,
"description"
:
"Whether the dependency allows prereleases or not."
...
...
@@ -225,6 +229,10 @@
"type"
:
"string"
,
"description"
:
"The python versions for which the dependency should be installed."
},
"platform"
:
{
"type"
:
"string"
,
"description"
:
"The platform(s) for which the dependency should be installed."
},
"allows-prereleases"
:
{
"type"
:
"boolean"
,
"description"
:
"Whether the dependency allows prereleases or not."
...
...
@@ -255,6 +263,10 @@
"type"
:
"string"
,
"description"
:
"The python versions for which the dependency should be installed."
},
"platform"
:
{
"type"
:
"string"
,
"description"
:
"The platform(s) for which the dependency should be installed."
},
"optional"
:
{
"type"
:
"boolean"
,
"description"
:
"Whether the dependency is optional or not."
...
...
@@ -281,6 +293,10 @@
"type"
:
"string"
,
"description"
:
"The python versions for which the dependency should be installed."
},
"platform"
:
{
"type"
:
"string"
,
"description"
:
"The platform(s) for which the dependency should be installed."
},
"optional"
:
{
"type"
:
"boolean"
,
"description"
:
"Whether the dependency is optional or not."
...
...
poetry/packages/dependency.py
View file @
20c87bc0
...
...
@@ -151,6 +151,13 @@ class Dependency(object):
self
.
_create_nested_marker
(
'python_version'
,
python_constraint
)
)
if
self
.
platform
!=
'*'
:
platform_constraint
=
self
.
platform_constraint
markers
.
append
(
self
.
_create_nested_marker
(
'sys_platform'
,
platform_constraint
)
)
in_extras
=
' || '
.
join
(
self
.
_in_extras
)
if
in_extras
and
with_extras
:
markers
.
append
(
...
...
tests/console/commands/test_add.py
View file @
20c87bc0
import
sys
from
cleo.testers
import
CommandTester
from
tests.helpers
import
get_dependency
...
...
@@ -303,3 +305,86 @@ Writing lock file
'version'
:
'0.2.0'
,
'extras'
:
[
'msgpack'
]
}
def
test_add_constraint_with_python
(
app
,
repo
,
installer
):
command
=
app
.
find
(
'add'
)
tester
=
CommandTester
(
command
)
cachy2
=
get_package
(
'cachy'
,
'0.2.0'
)
repo
.
add_package
(
get_package
(
'cachy'
,
'0.1.0'
))
repo
.
add_package
(
cachy2
)
tester
.
execute
([
(
'command'
,
command
.
get_name
()),
(
'name'
,
[
'cachy=0.2.0'
]),
(
'--python'
,
'>=2.7'
)
])
expected
=
"""
\
Updating dependencies
Resolving dependencies...
Package operations: 1 install, 0 updates, 0 removals
Writing lock file
- Installing cachy (0.2.0)
"""
assert
tester
.
get_display
()
==
expected
assert
len
(
installer
.
installs
)
==
1
content
=
app
.
poetry
.
file
.
read
(
raw
=
True
)[
'tool'
][
'poetry'
]
assert
'cachy'
in
content
[
'dependencies'
]
assert
content
[
'dependencies'
][
'cachy'
]
==
{
'version'
:
'0.2.0'
,
'python'
:
'>=2.7'
}
def
test_add_constraint_with_platform
(
app
,
repo
,
installer
):
platform
=
sys
.
platform
command
=
app
.
find
(
'add'
)
tester
=
CommandTester
(
command
)
cachy2
=
get_package
(
'cachy'
,
'0.2.0'
)
repo
.
add_package
(
get_package
(
'cachy'
,
'0.1.0'
))
repo
.
add_package
(
cachy2
)
tester
.
execute
([
(
'command'
,
command
.
get_name
()),
(
'name'
,
[
'cachy=0.2.0'
]),
(
'--platform'
,
platform
)
])
expected
=
"""
\
Updating dependencies
Resolving dependencies...
Package operations: 1 install, 0 updates, 0 removals
Writing lock file
- Installing cachy (0.2.0)
"""
assert
tester
.
get_display
()
==
expected
assert
len
(
installer
.
installs
)
==
1
content
=
app
.
poetry
.
file
.
read
(
raw
=
True
)[
'tool'
][
'poetry'
]
assert
'cachy'
in
content
[
'dependencies'
]
assert
content
[
'dependencies'
][
'cachy'
]
==
{
'version'
:
'0.2.0'
,
'platform'
:
platform
}
tests/packages/test_dependency.py
View file @
20c87bc0
...
...
@@ -70,6 +70,21 @@ def test_to_pep_508():
'or (python_version >= "3.6" and python_version < "4.0")'
def
test_to_pep_508_with_platform
():
dependency
=
Dependency
(
'Django'
,
'^1.23'
)
dependency
.
python_versions
=
'~2.7 || ^3.6'
dependency
.
platform
=
'linux || linux2'
result
=
dependency
.
to_pep_508
()
assert
result
==
(
'Django (>=1.23,<2.0); '
'((python_version >= "2.7" and python_version < "2.8") '
'or (python_version >= "3.6" and python_version < "4.0"))'
' and (sys_platform == "linux" or sys_platform == "linux2")'
)
def
test_to_pep_508_wilcard
():
dependency
=
Dependency
(
'Django'
,
'*'
)
...
...
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