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
a408cb14
Unverified
Commit
a408cb14
authored
Sep 13, 2018
by
Sébastien Eustace
Committed by
GitHub
Sep 13, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for multi-constraints dependencies (#406)
parent
68c39f8f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
130 additions
and
1 deletions
+130
-1
docs/docs/versions.md
+24
-1
poetry/json/schemas/poetry-schema.json
+26
-0
poetry/poetry.py
+12
-0
tests/fixtures/project_with_multi_constraints_dependency/project/__init__.py
+0
-0
tests/fixtures/project_with_multi_constraints_dependency/pyproject.toml
+19
-0
tests/masonry/builders/test_sdist.py
+39
-0
tests/test_poetry.py
+10
-0
No files found.
docs/docs/versions.md
View file @
a408cb14
...
@@ -113,7 +113,7 @@ my-package = { path = "../my-package/dist/my-package-0.1.0.tar.gz" }
...
@@ -113,7 +113,7 @@ my-package = { path = "../my-package/dist/my-package-0.1.0.tar.gz" }
You can install path dependencies in editable/development mode.
You can install path dependencies in editable/development mode.
Just pass `--develop my-package` (repeatable as much as you want) to
Just pass `--develop my-package` (repeatable as much as you want) to
the `install` command.
the `install` command.
### Python restricted dependencies
### Python restricted dependencies
...
@@ -128,3 +128,26 @@ pathlib2 = { version = "^2.2", python = "~2.7" }
...
@@ -128,3 +128,26 @@ pathlib2 = { version = "^2.2", python = "~2.7" }
[tool.poetry.dependencies]
[tool.poetry.dependencies]
pathlib2
=
{
version
=
"^2.2"
,
python
=
[
"~2.7"
,
"^3.2"
]
}
pathlib2
=
{
version
=
"^2.2"
,
python
=
[
"~2.7"
,
"^3.2"
]
}
```
```
### Multiple constraints dependencies
Sometimes, one of your dependency may have different version ranges depending
on the target Python versions.
Let's say you have a dependency on the package
`foo`
which is only compatible
with Python <3.0 up to version 1.9 and compatible with Python 3.4+ from version 2.0:
you would declare it like so:
```
toml
[tool.poetry.dependencies]
foo
=
[
{version
=
"<=1.9"
,
python
=
"^2.7"
}
,
{version
=
"^2.0"
,
python
=
"^3.4"
}
]
```
!!!note
The constraints **must** have different requirements (like `python`)
otherwise it will cause an error when resolving dependencies.
poetry/json/schemas/poetry-schema.json
View file @
a408cb14
...
@@ -183,6 +183,9 @@
...
@@ -183,6 +183,9 @@
},
},
{
{
"$ref"
:
"#/definitions/path-dependency"
"$ref"
:
"#/definitions/path-dependency"
},
{
"$ref"
:
"#/definitions/multiple-constraints-dependency"
}
}
]
]
}
}
...
@@ -345,6 +348,29 @@
...
@@ -345,6 +348,29 @@
}
}
}
}
},
},
"multiple-constraints-dependency"
:
{
"type"
:
"array"
,
"minItems"
:
1
,
"items"
:
{
"oneOf"
:
[
{
"$ref"
:
"#/definitions/dependency"
},
{
"$ref"
:
"#/definitions/long-dependency"
},
{
"$ref"
:
"#/definitions/git-dependency"
},
{
"$ref"
:
"#/definitions/file-dependency"
},
{
"$ref"
:
"#/definitions/path-dependency"
}
]
}
},
"repository"
:
{
"repository"
:
{
"type"
:
"object"
,
"type"
:
"object"
,
"properties"
:
{
"properties"
:
{
...
...
poetry/poetry.py
View file @
a408cb14
...
@@ -120,10 +120,22 @@ class Poetry:
...
@@ -120,10 +120,22 @@ class Poetry:
package
.
python_versions
=
constraint
package
.
python_versions
=
constraint
continue
continue
if
isinstance
(
constraint
,
list
):
for
_constraint
in
constraint
:
package
.
add_dependency
(
name
,
_constraint
)
continue
package
.
add_dependency
(
name
,
constraint
)
package
.
add_dependency
(
name
,
constraint
)
if
"dev-dependencies"
in
local_config
:
if
"dev-dependencies"
in
local_config
:
for
name
,
constraint
in
local_config
[
"dev-dependencies"
]
.
items
():
for
name
,
constraint
in
local_config
[
"dev-dependencies"
]
.
items
():
if
isinstance
(
constraint
,
list
):
for
_constraint
in
constraint
:
package
.
add_dependency
(
name
,
_constraint
)
continue
package
.
add_dependency
(
name
,
constraint
,
category
=
"dev"
)
package
.
add_dependency
(
name
,
constraint
,
category
=
"dev"
)
extras
=
local_config
.
get
(
"extras"
,
{})
extras
=
local_config
.
get
(
"extras"
,
{})
...
...
tests/fixtures/project_with_multi_constraints_dependency/project/__init__.py
0 → 100644
View file @
a408cb14
tests/fixtures/project_with_multi_constraints_dependency/pyproject.toml
0 → 100644
View file @
a408cb14
[tool.poetry]
name
=
"project-with-multi-constraints-dependency"
version
=
"1.2.3"
description
=
"This is a description"
authors
=
[
"Your Name <you@example.com>"
]
license
=
"MIT"
packages
=
[
{include
=
"project"
}
]
[tool.poetry.dependencies]
python
=
"*"
pendulum
=
[
{
version
=
"^1.5"
,
python
=
"<3.4"
}
,
{
version
=
"^2.0"
,
python
=
"^3.4"
}
]
[tool.poetry.dev-dependencies]
tests/masonry/builders/test_sdist.py
View file @
a408cb14
...
@@ -197,6 +197,45 @@ def test_find_files_to_add():
...
@@ -197,6 +197,45 @@ def test_find_files_to_add():
)
)
def
test_make_pkg_info_multi_constraints_dependency
():
poetry
=
Poetry
.
create
(
Path
(
__file__
)
.
parent
.
parent
.
parent
/
"fixtures"
/
"project_with_multi_constraints_dependency"
)
builder
=
SdistBuilder
(
poetry
,
NullEnv
(),
NullIO
())
pkg_info
=
builder
.
build_pkg_info
()
p
=
Parser
()
parsed
=
p
.
parsestr
(
to_str
(
pkg_info
))
requires
=
parsed
.
get_all
(
"Requires-Dist"
)
assert
requires
==
[
'pendulum (>=1.5,<2.0); python_version < "3.4"'
,
'pendulum (>=2.0,<3.0); python_version >= "3.4" and python_version < "4.0"'
,
]
def
test_find_files_to_add
():
poetry
=
Poetry
.
create
(
project
(
"complete"
))
builder
=
SdistBuilder
(
poetry
,
NullEnv
(),
NullIO
())
result
=
builder
.
find_files_to_add
()
assert
sorted
(
result
)
==
sorted
(
[
Path
(
"LICENSE"
),
Path
(
"README.rst"
),
Path
(
"my_package/__init__.py"
),
Path
(
"my_package/data1/test.json"
),
Path
(
"my_package/sub_pkg1/__init__.py"
),
Path
(
"my_package/sub_pkg2/__init__.py"
),
Path
(
"my_package/sub_pkg2/data2/data.json"
),
Path
(
"pyproject.toml"
),
]
)
def
test_find_packages
():
def
test_find_packages
():
poetry
=
Poetry
.
create
(
project
(
"complete"
))
poetry
=
Poetry
.
create
(
project
(
"complete"
))
...
...
tests/test_poetry.py
View file @
a408cb14
...
@@ -123,6 +123,16 @@ def test_poetry_with_packages_and_includes():
...
@@ -123,6 +123,16 @@ def test_poetry_with_packages_and_includes():
assert
package
.
include
==
[
"extra_dir/vcs_excluded.txt"
,
"notes.txt"
]
assert
package
.
include
==
[
"extra_dir/vcs_excluded.txt"
,
"notes.txt"
]
def
test_poetry_with_multi_constraints_dependency
():
poetry
=
Poetry
.
create
(
str
(
fixtures_dir
/
"project_with_multi_constraints_dependency"
)
)
package
=
poetry
.
package
assert
len
(
package
.
requires
)
==
2
def
test_check
():
def
test_check
():
complete
=
TomlFile
(
fixtures_dir
/
"complete.toml"
)
complete
=
TomlFile
(
fixtures_dir
/
"complete.toml"
)
content
=
complete
.
read
()[
"tool"
][
"poetry"
]
content
=
complete
.
read
()[
"tool"
][
"poetry"
]
...
...
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