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
0adbac0f
Unverified
Commit
0adbac0f
authored
Mar 06, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Dependency.to_pep_508() method
parent
b6115051
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
18 deletions
+48
-18
poetry/packages/dependency.py
+21
-11
poetry/semver/constraints/constraint.py
+5
-0
tests/masonry/builders/test_sdist.py
+7
-7
tests/packages/test_dependency.py
+15
-0
No files found.
poetry/packages/dependency.py
View file @
0adbac0f
...
@@ -107,11 +107,11 @@ class Dependency:
...
@@ -107,11 +107,11 @@ class Dependency:
requirement
=
f
'{self.pretty_name}'
requirement
=
f
'{self.pretty_name}'
if
isinstance
(
self
.
constraint
,
MultiConstraint
):
if
isinstance
(
self
.
constraint
,
MultiConstraint
):
requirement
+=
','
.
join
(
requirement
+=
'
({})'
.
format
(
'
,'
.
join
(
[
str
(
c
)
.
replace
(
' '
,
''
)
for
c
in
self
.
constraint
.
constraints
]
[
str
(
c
)
.
replace
(
' '
,
''
)
for
c
in
self
.
constraint
.
constraints
]
)
)
)
else
:
else
:
requirement
+=
str
(
self
.
constraint
)
.
replace
(
' '
,
''
)
requirement
+=
' ({})'
.
format
(
str
(
self
.
constraint
)
.
replace
(
' '
,
''
)
)
# Markers
# Markers
markers
=
[]
markers
=
[]
...
@@ -119,21 +119,31 @@ class Dependency:
...
@@ -119,21 +119,31 @@ class Dependency:
# Python marker
# Python marker
if
self
.
python_versions
!=
'*'
:
if
self
.
python_versions
!=
'*'
:
python_constraint
=
self
.
python_constraint
python_constraint
=
self
.
python_constraint
marker
=
'python_version'
if
isinstance
(
python_constraint
,
MultiConstraint
):
marker
+=
','
.
join
(
[
str
(
c
)
.
replace
(
' '
,
''
)
for
c
in
python_constraint
.
constraints
]
)
else
:
marker
+=
str
(
python_constraint
)
.
replace
(
' '
,
''
)
markers
.
append
(
marker
)
markers
.
append
(
self
.
_create_nested_marker
(
'python_version'
,
python_constraint
)
)
if
markers
:
if
markers
:
requirement
+=
f
'; {" and ".join(markers)}'
requirement
+=
f
'; {" and ".join(markers)}'
return
requirement
return
requirement
def
_create_nested_marker
(
self
,
name
,
constraint
):
if
isinstance
(
constraint
,
MultiConstraint
):
parts
=
[]
for
c
in
constraint
.
constraints
:
parts
.
append
(
self
.
_create_nested_marker
(
name
,
c
))
glue
=
' and '
if
constraint
.
is_disjunctive
():
parts
=
[
f
'({part})'
for
part
in
parts
]
glue
=
' or '
marker
=
glue
.
join
(
parts
)
else
:
marker
=
f
'{name}{constraint.string_operator}"{constraint.version}"'
return
marker
def
activate
(
self
):
def
activate
(
self
):
"""
"""
Set the dependency as mandatory.
Set the dependency as mandatory.
...
...
poetry/semver/constraints/constraint.py
View file @
0adbac0f
...
@@ -42,6 +42,7 @@ class Constraint(BaseConstraint):
...
@@ -42,6 +42,7 @@ class Constraint(BaseConstraint):
)
)
self
.
_operator
=
self
.
_trans_op_str
[
operator
]
self
.
_operator
=
self
.
_trans_op_str
[
operator
]
self
.
_string_operator
=
operator
self
.
_version
=
version
self
.
_version
=
version
@property
@property
...
@@ -53,6 +54,10 @@ class Constraint(BaseConstraint):
...
@@ -53,6 +54,10 @@ class Constraint(BaseConstraint):
return
self
.
_operator
return
self
.
_operator
@property
@property
def
string_operator
(
self
):
return
self
.
_string_operator
@property
def
version
(
self
)
->
str
:
def
version
(
self
)
->
str
:
return
self
.
_version
return
self
.
_version
...
...
tests/masonry/builders/test_sdist.py
View file @
0adbac0f
...
@@ -39,9 +39,9 @@ def test_convert_dependencies():
...
@@ -39,9 +39,9 @@ def test_convert_dependencies():
get_dependency
(
'C'
,
'1.2.3'
),
get_dependency
(
'C'
,
'1.2.3'
),
])
])
main
=
[
main
=
[
'A
>=1.0.0.0,<2.0.0.0
'
,
'A
(>=1.0.0.0,<2.0.0.0)
'
,
'B
>=1.0.0.0,<1.1.0.0
'
,
'B
(>=1.0.0.0,<1.1.0.0)
'
,
'C
==1.2.3.0
'
,
'C
(==1.2.3.0)
'
,
]
]
extras
=
[]
extras
=
[]
...
@@ -56,11 +56,11 @@ def test_convert_dependencies():
...
@@ -56,11 +56,11 @@ def test_convert_dependencies():
get_dependency
(
'C'
,
'1.2.3'
),
get_dependency
(
'C'
,
'1.2.3'
),
])
])
main
=
[
main
=
[
'B
>=1.0.0.0,<1.1.0.0
'
,
'B
(>=1.0.0.0,<1.1.0.0)
'
,
'C
==1.2.3.0
'
,
'C
(==1.2.3.0)
'
,
]
]
extras
=
[
extras
=
[
'A
>=1.0.0.0,<2.0.0.0; python_version>=3.4.0.0,<4.0.0.0
'
,
'A
(>=1.0.0.0,<2.0.0.0); python_version>="3.4.0.0" and python_version<"4.0.0.0"
'
,
]
]
assert
result
==
(
main
,
extras
)
assert
result
==
(
main
,
extras
)
...
@@ -82,7 +82,7 @@ def test_make_setup():
...
@@ -82,7 +82,7 @@ def test_make_setup():
'my_package.sub_pkg2'
'my_package.sub_pkg2'
]
]
assert
ns
[
'install_requires'
]
==
[
assert
ns
[
'install_requires'
]
==
[
'cleo
>=0.6.0.0,<0.7.0.0
'
'cleo
(>=0.6.0.0,<0.7.0.0)
'
]
]
assert
ns
[
'entry_points'
]
==
{
assert
ns
[
'entry_points'
]
==
{
'console_scripts'
:
[
'my-script = my_package:main'
]
'console_scripts'
:
[
'my-script = my_package:main'
]
...
...
tests/packages/test_dependency.py
View file @
0adbac0f
...
@@ -53,3 +53,18 @@ def test_accepts_fails_with_python_versions_mismatch():
...
@@ -53,3 +53,18 @@ def test_accepts_fails_with_python_versions_mismatch():
package
.
python_versions
=
'~3.5'
package
.
python_versions
=
'~3.5'
assert
not
dependency
.
accepts
(
package
)
assert
not
dependency
.
accepts
(
package
)
def
test_to_pep_508
():
dependency
=
Dependency
(
'Django'
,
'^1.23'
)
result
=
dependency
.
to_pep_508
()
assert
result
==
'Django (>=1.23.0.0,<2.0.0.0)'
dependency
=
Dependency
(
'Django'
,
'^1.23'
)
dependency
.
python_versions
=
'~2.7 || ^3.6'
result
=
dependency
.
to_pep_508
()
assert
result
==
'Django (>=1.23.0.0,<2.0.0.0); '
\
'(python_version>="2.7.0.0" and python_version<"2.8.0.0") '
\
'or (python_version>="3.6.0.0" and python_version<"4.0.0.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