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
d3491fe7
Unverified
Commit
d3491fe7
authored
Mar 14, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing modules
parent
ea9726dc
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
35 deletions
+61
-35
poetry/masonry/builder.py
+0
-14
poetry/masonry/builders/sdist.py
+2
-8
poetry/masonry/builders/wheel.py
+2
-7
poetry/semver/constraints/multi_constraint.py
+1
-1
poetry/semver/version_parser.py
+12
-5
poetry/version/helpers.py
+44
-0
No files found.
poetry/masonry/builder.py
View file @
d3491fe7
...
...
@@ -21,20 +21,6 @@ class Builder:
if
fmt
not
in
self
.
_FORMATS
:
raise
ValueError
(
f
'Invalid format: {fmt}'
)
self
.
check
()
builder
=
self
.
_FORMATS
[
fmt
](
self
.
_poetry
,
self
.
_io
)
return
builder
.
build
()
def
check
(
self
)
->
None
:
package
=
self
.
_poetry
.
package
# Checking for disjunctive python versions
if
isinstance
(
package
.
python_constraint
,
MultiConstraint
):
if
package
.
python_constraint
.
is_disjunctive
():
raise
RuntimeError
(
'Disjunctive python versions are not yet supported '
'when building packages. Rewrite your python requirements '
'in a conjunctive way.'
)
poetry/masonry/builders/sdist.py
View file @
d3491fe7
...
...
@@ -11,7 +11,7 @@ from pprint import pformat
from
typing
import
List
from
poetry.packages
import
Dependency
from
poetry.
semver.constraints
import
MultiC
onstraint
from
poetry.
version.helpers
import
format_python_c
onstraint
from
..utils.helpers
import
normalize_file_permissions
...
...
@@ -149,13 +149,7 @@ class SdistBuilder(Builder):
extra
.
append
(
"'entry_points': entry_points,"
)
if
self
.
_package
.
python_versions
!=
'*'
:
constraint
=
self
.
_package
.
python_constraint
if
isinstance
(
constraint
,
MultiConstraint
):
python_requires
=
','
.
join
(
[
str
(
c
)
.
replace
(
' '
,
''
)
for
c
in
constraint
.
constraints
]
)
else
:
python_requires
=
str
(
constraint
)
.
replace
(
' '
,
''
)
python_requires
=
format_python_constraint
(
self
.
_package
.
python_constraint
)
extra
.
append
(
"'python_requires': {!r},"
.
format
(
python_requires
))
...
...
poetry/masonry/builders/wheel.py
View file @
d3491fe7
...
...
@@ -16,6 +16,7 @@ from poetry.__version__ import __version__
from
poetry.semver.constraints
import
Constraint
from
poetry.semver.constraints
import
MultiConstraint
from
poetry.vcs
import
get_vcs
from
poetry.version.helpers
import
format_python_constraint
from
..utils.helpers
import
normalize_file_permissions
from
..utils.tags
import
get_abbr_impl
...
...
@@ -311,13 +312,7 @@ class WheelBuilder(Builder):
fp
.
write
(
f
'Author-email: {author["email"]}
\n
'
)
if
self
.
_package
.
python_versions
!=
'*'
:
constraint
=
self
.
_package
.
python_constraint
if
isinstance
(
constraint
,
MultiConstraint
):
python_requires
=
','
.
join
(
[
str
(
c
)
.
replace
(
' '
,
''
)
for
c
in
constraint
.
constraints
]
)
else
:
python_requires
=
str
(
constraint
)
.
replace
(
' '
,
''
)
python_requires
=
format_python_constraint
(
self
.
_package
.
python_constraint
)
fp
.
write
(
f
'Requires-Python: {python_requires}
\n
'
)
...
...
poetry/semver/constraints/multi_constraint.py
View file @
d3491fe7
...
...
@@ -37,5 +37,5 @@ class MultiConstraint(BaseConstraint):
constraints
.
append
(
str
(
constraint
))
return
'{}'
.
format
(
(
' '
if
self
.
_conjunctive
else
' || '
)
.
join
(
constraints
)
(
'
,
'
if
self
.
_conjunctive
else
' || '
)
.
join
(
constraints
)
)
poetry/semver/version_parser.py
View file @
d3491fe7
...
...
@@ -176,24 +176,31 @@ class VersionParser:
# A partial version range is treated as an X-Range,
# so the special character is in fact optional.
m
=
re
.
match
(
'^v?(
\
d+)(?:
\
.(
\
d+))?(?:
\
.(
\
d+))?(?:
\
.[xX*])+$'
,
'^
(!=)?
v?(
\
d+)(?:
\
.(
\
d+))?(?:
\
.(
\
d+))?(?:
\
.[xX*])+$'
,
constraint
)
if
m
:
if
m
.
group
(
3
):
if
m
.
group
(
4
):
position
=
2
elif
m
.
group
(
2
):
elif
m
.
group
(
3
):
position
=
1
else
:
position
=
0
groups
=
m
.
groups
()[
1
:]
low_version
=
self
.
_manipulate_version_string
(
m
.
groups
()
,
position
groups
,
position
)
high_version
=
self
.
_manipulate_version_string
(
m
.
groups
()
,
position
,
1
groups
,
position
,
1
)
if
m
.
group
(
1
):
if
low_version
==
'0.0.0.0'
:
return
Constraint
(
'>='
,
high_version
),
return
self
.
parse_constraints
(
f
'<{low_version} || >={high_version}'
),
if
low_version
==
'0.0.0.0'
:
return
Constraint
(
'<'
,
high_version
),
...
...
poetry/version/helpers.py
0 → 100644
View file @
d3491fe7
from
poetry.semver.constraints
import
MultiConstraint
from
poetry.semver.version_parser
import
VersionParser
PYTHON_VERSION
=
[
'2.7.*'
,
'3.0.*'
,
'3.1.*'
,
'3.2.*'
,
'3.3.*'
,
'3.4.*'
,
'3.5.*'
,
'3.6.*'
,
'3.7.*'
,
'3.8.*'
,
]
def
format_python_constraint
(
constraint
):
"""
This helper will help in transforming
disjunctive constraint into proper constraint.
"""
if
not
isinstance
(
constraint
,
MultiConstraint
):
return
str
(
constraint
)
has_disjunctive
=
False
for
c
in
constraint
.
constraints
:
if
isinstance
(
c
,
MultiConstraint
)
and
c
.
is_disjunctive
():
has_disjunctive
=
True
break
parser
=
VersionParser
()
formatted
=
[]
accepted
=
[]
if
not
constraint
.
is_disjunctive
()
and
not
has_disjunctive
:
return
str
(
constraint
)
for
version
in
PYTHON_VERSION
:
matches
=
constraint
.
matches
(
parser
.
parse_constraints
(
version
))
if
not
matches
:
formatted
.
append
(
'!='
+
version
)
else
:
accepted
.
append
(
version
)
# Checking lower bound
low
=
accepted
[
0
]
formatted
.
insert
(
0
,
'>='
+
'.'
.
join
(
low
.
split
(
'.'
)[:
2
]))
return
', '
.
join
(
formatted
)
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