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
68c39f8f
Unverified
Commit
68c39f8f
authored
Sep 13, 2018
by
Sébastien Eustace
Committed by
GitHub
Sep 13, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix handling of Python constraints when solving dependencies (#377)
parent
23667d28
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
25 deletions
+48
-25
poetry/masonry/metadata.py
+1
-1
poetry/packages/project_package.py
+18
-0
poetry/puzzle/provider.py
+21
-15
tests/puzzle/test_solver.py
+8
-9
No files found.
poetry/masonry/metadata.py
View file @
68c39f8f
...
@@ -64,7 +64,7 @@ class Metadata:
...
@@ -64,7 +64,7 @@ class Metadata:
meta
.
maintainer_email
=
meta
.
author_email
meta
.
maintainer_email
=
meta
.
author_email
# Requires python
# Requires python
if
not
package
.
python_constraint
.
is_any
()
:
if
package
.
python_versions
!=
"*"
:
meta
.
requires_python
=
format_python_constraint
(
package
.
python_constraint
)
meta
.
requires_python
=
format_python_constraint
(
package
.
python_constraint
)
meta
.
requires_dist
=
[
d
.
to_pep_508
()
for
d
in
package
.
requires
]
meta
.
requires_dist
=
[
d
.
to_pep_508
()
for
d
in
package
.
requires
]
...
...
poetry/packages/project_package.py
View file @
68c39f8f
from
poetry.semver
import
VersionRange
from
poetry.semver
import
parse_constraint
from
.package
import
Package
from
.package
import
Package
...
@@ -10,6 +13,9 @@ class ProjectPackage(Package):
...
@@ -10,6 +13,9 @@ class ProjectPackage(Package):
self
.
include
=
[]
self
.
include
=
[]
self
.
exclude
=
[]
self
.
exclude
=
[]
if
self
.
_python_versions
==
"*"
:
self
.
_python_constraint
=
parse_constraint
(
"~2.7 || >=3.4"
)
def
is_root
(
self
):
def
is_root
(
self
):
return
True
return
True
...
@@ -19,3 +25,15 @@ class ProjectPackage(Package):
...
@@ -19,3 +25,15 @@ class ProjectPackage(Package):
dependency
.
is_root
=
True
dependency
.
is_root
=
True
return
dependency
return
dependency
@property
def
python_versions
(
self
):
return
self
.
_python_versions
@python_versions.setter
def
python_versions
(
self
,
value
):
self
.
_python_versions
=
value
if
value
==
"*"
or
value
==
VersionRange
():
value
=
"~2.7 || >=3.4"
self
.
_python_constraint
=
parse_constraint
(
value
)
poetry/puzzle/provider.py
View file @
68c39f8f
...
@@ -311,21 +311,27 @@ class Provider:
...
@@ -311,21 +311,27 @@ class Provider:
else
:
else
:
dependencies
=
package
.
requires
dependencies
=
package
.
requires
if
not
self
.
_package
.
python_constraint
.
allows_any
(
package
.
python_constraint
):
if
not
package
.
python_constraint
.
allows_all
(
return
[
self
.
_package
.
python_constraint
Incompatibility
(
):
[
Term
(
package
.
to_dependency
(),
True
)],
return
[
PythonCause
(
package
.
python_versions
,
self
.
_package
.
python_versions
),
Incompatibility
(
)
[
Term
(
package
.
to_dependency
(),
True
)],
]
PythonCause
(
package
.
python_versions
,
self
.
_package
.
python_versions
if
not
self
.
_package
.
platform_constraint
.
matches
(
package
.
platform_constraint
):
),
return
[
)
Incompatibility
(
]
[
Term
(
package
.
to_dependency
(),
True
)],
PlatformCause
(
package
.
platform
),
if
not
self
.
_package
.
platform_constraint
.
matches
(
)
package
.
platform_constraint
]
):
return
[
Incompatibility
(
[
Term
(
package
.
to_dependency
(),
True
)],
PlatformCause
(
package
.
platform
),
)
]
dependencies
=
[
dependencies
=
[
dep
dep
...
...
tests/puzzle/test_solver.py
View file @
68c39f8f
...
@@ -291,17 +291,17 @@ def test_solver_sets_categories(solver, repo, package):
...
@@ -291,17 +291,17 @@ def test_solver_sets_categories(solver, repo, package):
def
test_solver_respects_root_package_python_versions
(
solver
,
repo
,
package
):
def
test_solver_respects_root_package_python_versions
(
solver
,
repo
,
package
):
package
.
python_versions
=
"
^
3.4"
package
.
python_versions
=
"
~
3.4"
package
.
add_dependency
(
"A"
)
package
.
add_dependency
(
"A"
)
package
.
add_dependency
(
"B"
)
package
.
add_dependency
(
"B"
)
package_a
=
get_package
(
"A"
,
"1.0"
)
package_a
=
get_package
(
"A"
,
"1.0"
)
package_b
=
get_package
(
"B"
,
"1.0"
)
package_b
=
get_package
(
"B"
,
"1.0"
)
package_b
.
python_versions
=
"^3.
6
"
package_b
.
python_versions
=
"^3.
3
"
package_c
=
get_package
(
"C"
,
"1.0"
)
package_c
=
get_package
(
"C"
,
"1.0"
)
package_c
.
python_versions
=
"^3.
6
"
package_c
.
python_versions
=
"^3.
4
"
package_c11
=
get_package
(
"C"
,
"1.1"
)
package_c11
=
get_package
(
"C"
,
"1.1"
)
package_c11
.
python_versions
=
"
~3.3
"
package_c11
.
python_versions
=
"
^3.6
"
package_b
.
add_dependency
(
"C"
,
"^1.0"
)
package_b
.
add_dependency
(
"C"
,
"^1.0"
)
repo
.
add_package
(
package_a
)
repo
.
add_package
(
package_a
)
...
@@ -342,16 +342,16 @@ def test_solver_fails_if_mismatch_root_python_versions(solver, repo, package):
...
@@ -342,16 +342,16 @@ def test_solver_fails_if_mismatch_root_python_versions(solver, repo, package):
def
test_solver_solves_optional_and_compatible_packages
(
solver
,
repo
,
package
):
def
test_solver_solves_optional_and_compatible_packages
(
solver
,
repo
,
package
):
package
.
python_versions
=
"
^
3.4"
package
.
python_versions
=
"
~
3.4"
package
.
extras
[
"foo"
]
=
[
get_dependency
(
"B"
)]
package
.
extras
[
"foo"
]
=
[
get_dependency
(
"B"
)]
package
.
add_dependency
(
"A"
,
{
"version"
:
"*"
,
"python"
:
"
~3.5
"
})
package
.
add_dependency
(
"A"
,
{
"version"
:
"*"
,
"python"
:
"
^3.4
"
})
package
.
add_dependency
(
"B"
,
{
"version"
:
"*"
,
"optional"
:
True
})
package
.
add_dependency
(
"B"
,
{
"version"
:
"*"
,
"optional"
:
True
})
package_a
=
get_package
(
"A"
,
"1.0"
)
package_a
=
get_package
(
"A"
,
"1.0"
)
package_b
=
get_package
(
"B"
,
"1.0"
)
package_b
=
get_package
(
"B"
,
"1.0"
)
package_b
.
python_versions
=
"^3.
6
"
package_b
.
python_versions
=
"^3.
3
"
package_c
=
get_package
(
"C"
,
"1.0"
)
package_c
=
get_package
(
"C"
,
"1.0"
)
package_c
.
python_versions
=
"^3.
6
"
package_c
.
python_versions
=
"^3.
4
"
package_b
.
add_dependency
(
"C"
,
"^1.0"
)
package_b
.
add_dependency
(
"C"
,
"^1.0"
)
repo
.
add_package
(
package_a
)
repo
.
add_package
(
package_a
)
...
@@ -377,7 +377,6 @@ def test_solver_solves_while_respecting_root_platforms(solver, repo, package):
...
@@ -377,7 +377,6 @@ def test_solver_solves_while_respecting_root_platforms(solver, repo, package):
package_a
=
get_package
(
"A"
,
"1.0"
)
package_a
=
get_package
(
"A"
,
"1.0"
)
package_b
=
get_package
(
"B"
,
"1.0"
)
package_b
=
get_package
(
"B"
,
"1.0"
)
package_b
.
python_versions
=
"^3.6"
package_c12
=
get_package
(
"C"
,
"1.2"
)
package_c12
=
get_package
(
"C"
,
"1.2"
)
package_c12
.
platform
=
"win32"
package_c12
.
platform
=
"win32"
package_c10
=
get_package
(
"C"
,
"1.0"
)
package_c10
=
get_package
(
"C"
,
"1.0"
)
...
...
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