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
3da87bfd
Unverified
Commit
3da87bfd
authored
Apr 14, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix add command picking up prereleases by default
parent
c799b4a5
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
16 deletions
+45
-16
CHANGELOG.md
+7
-0
poetry/console/commands/add.py
+27
-9
poetry/json/schemas/poetry-schema.json
+3
-3
poetry/packages/package.py
+1
-1
poetry/version/version_selector.py
+6
-2
tests/fixtures/complete.toml
+1
-1
No files found.
CHANGELOG.md
View file @
3da87bfd
# Change Log
# Change Log
## [Unreleased]
### Fixed
-
Fixed
`add`
command picking up prereleases by default.
## [0.8.1] - 2018-04-13
## [0.8.1] - 2018-04-13
### Fixed
### Fixed
...
...
poetry/console/commands/add.py
View file @
3da87bfd
...
@@ -14,6 +14,7 @@ class AddCommand(VenvCommand):
...
@@ -14,6 +14,7 @@ class AddCommand(VenvCommand):
{ name* : Packages to add. }
{ name* : Packages to add. }
{--D|dev : Add package as development dependency. }
{--D|dev : Add package as development dependency. }
{--optional : Add as an optional dependency. }
{--optional : Add as an optional dependency. }
{ --allow-prereleases : Accept prereleases. }
{--dry-run : Outputs the operations but will not execute anything
{--dry-run : Outputs the operations but will not execute anything
(implicitly enables --verbose). }
(implicitly enables --verbose). }
"""
"""
...
@@ -45,7 +46,10 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
...
@@ -45,7 +46,10 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
'Package {} is already present'
.
format
(
name
)
'Package {} is already present'
.
format
(
name
)
)
)
requirements
=
self
.
_determine_requirements
(
packages
)
requirements
=
self
.
_determine_requirements
(
packages
,
allow_prereleases
=
self
.
option
(
'allow-prereleases'
)
)
requirements
=
self
.
_format_requirements
(
requirements
)
requirements
=
self
.
_format_requirements
(
requirements
)
# validate requirements format
# validate requirements format
...
@@ -54,12 +58,19 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
...
@@ -54,12 +58,19 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
parser
.
parse_constraints
(
constraint
)
parser
.
parse_constraints
(
constraint
)
for
name
,
constraint
in
requirements
.
items
():
for
name
,
constraint
in
requirements
.
items
():
if
self
.
option
(
'optional'
):
if
self
.
option
(
'optional'
)
or
self
.
option
(
'allow-prereleases'
)
:
constraint
=
{
constraint
=
{
'version'
:
constraint
,
'version'
:
constraint
'optional'
:
True
}
}
if
self
.
option
(
'optional'
):
constraint
=
{
'optional'
:
True
}
if
self
.
option
(
'allow-prereleases'
):
constraint
[
'allows-prereleases'
]
=
True
poetry_content
[
section
][
name
]
=
constraint
poetry_content
[
section
][
name
]
=
constraint
# Write new content
# Write new content
...
@@ -104,7 +115,8 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
...
@@ -104,7 +115,8 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
return
status
return
status
def
_determine_requirements
(
self
,
def
_determine_requirements
(
self
,
requires
# type: List[str]
requires
,
# type: List[str]
allow_prereleases
=
False
,
# type: bool
):
# type: (...) -> List[str]
):
# type: (...) -> List[str]
if
not
requires
:
if
not
requires
:
return
[]
return
[]
...
@@ -115,7 +127,8 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
...
@@ -115,7 +127,8 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
if
'version'
not
in
requirement
:
if
'version'
not
in
requirement
:
# determine the best version automatically
# determine the best version automatically
name
,
version
=
self
.
_find_best_version_for_package
(
name
,
version
=
self
.
_find_best_version_for_package
(
requirement
[
'name'
]
requirement
[
'name'
],
allow_prereleases
=
allow_prereleases
)
)
requirement
[
'version'
]
=
version
requirement
[
'version'
]
=
version
requirement
[
'name'
]
=
name
requirement
[
'name'
]
=
name
...
@@ -128,7 +141,8 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
...
@@ -128,7 +141,8 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
# check that the specified version/constraint exists
# check that the specified version/constraint exists
# before we proceed
# before we proceed
name
,
_
=
self
.
_find_best_version_for_package
(
name
,
_
=
self
.
_find_best_version_for_package
(
requirement
[
'name'
],
requirement
[
'version'
]
requirement
[
'name'
],
requirement
[
'version'
],
allow_prereleases
=
allow_prereleases
)
)
requirement
[
'name'
]
=
name
requirement
[
'name'
]
=
name
...
@@ -141,12 +155,16 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
...
@@ -141,12 +155,16 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
def
_find_best_version_for_package
(
self
,
def
_find_best_version_for_package
(
self
,
name
,
name
,
required_version
=
None
required_version
=
None
,
allow_prereleases
=
False
):
# type: (...) -> Tuple[str, str]
):
# type: (...) -> Tuple[str, str]
from
poetry.version.version_selector
import
VersionSelector
from
poetry.version.version_selector
import
VersionSelector
selector
=
VersionSelector
(
self
.
poetry
.
pool
)
selector
=
VersionSelector
(
self
.
poetry
.
pool
)
package
=
selector
.
find_best_candidate
(
name
,
required_version
)
package
=
selector
.
find_best_candidate
(
name
,
required_version
,
allow_prereleases
=
allow_prereleases
)
if
not
package
:
if
not
package
:
# TODO: find similar
# TODO: find similar
...
...
poetry/json/schemas/poetry-schema.json
View file @
3da87bfd
...
@@ -179,7 +179,7 @@
...
@@ -179,7 +179,7 @@
"type"
:
"string"
,
"type"
:
"string"
,
"description"
:
"The python versions for which the dependency should be installed."
"description"
:
"The python versions for which the dependency should be installed."
},
},
"allows
_
prereleases"
:
{
"allows
-
prereleases"
:
{
"type"
:
"boolean"
,
"type"
:
"boolean"
,
"description"
:
"Whether the dependency allows prereleases or not."
"description"
:
"Whether the dependency allows prereleases or not."
},
},
...
@@ -222,7 +222,7 @@
...
@@ -222,7 +222,7 @@
"type"
:
"string"
,
"type"
:
"string"
,
"description"
:
"The python versions for which the dependency should be installed."
"description"
:
"The python versions for which the dependency should be installed."
},
},
"allows
_
prereleases"
:
{
"allows
-
prereleases"
:
{
"type"
:
"boolean"
,
"type"
:
"boolean"
,
"description"
:
"Whether the dependency allows prereleases or not."
"description"
:
"Whether the dependency allows prereleases or not."
},
},
...
@@ -252,7 +252,7 @@
...
@@ -252,7 +252,7 @@
"type"
:
"string"
,
"type"
:
"string"
,
"description"
:
"The python versions for which the dependency should be installed."
"description"
:
"The python versions for which the dependency should be installed."
},
},
"allows
_
prereleases"
:
{
"allows
-
prereleases"
:
{
"type"
:
"boolean"
,
"type"
:
"boolean"
,
"description"
:
"Whether the dependency allows prereleases or not."
"description"
:
"Whether the dependency allows prereleases or not."
},
},
...
...
poetry/packages/package.py
View file @
3da87bfd
...
@@ -260,7 +260,7 @@ class Package(object):
...
@@ -260,7 +260,7 @@ class Package(object):
optional
=
constraint
.
get
(
'optional'
,
False
)
optional
=
constraint
.
get
(
'optional'
,
False
)
python_versions
=
constraint
.
get
(
'python'
)
python_versions
=
constraint
.
get
(
'python'
)
platform
=
constraint
.
get
(
'platform'
)
platform
=
constraint
.
get
(
'platform'
)
allows_prereleases
=
constraint
.
get
(
'allows
_
prereleases'
,
False
)
allows_prereleases
=
constraint
.
get
(
'allows
-
prereleases'
,
False
)
if
'git'
in
constraint
:
if
'git'
in
constraint
:
# VCS dependency
# VCS dependency
...
...
poetry/version/version_selector.py
View file @
3da87bfd
...
@@ -14,8 +14,9 @@ class VersionSelector(object):
...
@@ -14,8 +14,9 @@ class VersionSelector(object):
self
.
_parser
=
parser
self
.
_parser
=
parser
def
find_best_candidate
(
self
,
def
find_best_candidate
(
self
,
package_name
,
# type: str
package_name
,
# type: str
target_package_version
=
None
# type: Union[str, None]
target_package_version
=
None
,
# type: Union[str, None]
allow_prereleases
=
False
# type: bool
):
# type: (...) -> Union[Package, bool]
):
# type: (...) -> Union[Package, bool]
"""
"""
Given a package name and optional version,
Given a package name and optional version,
...
@@ -34,6 +35,9 @@ class VersionSelector(object):
...
@@ -34,6 +35,9 @@ class VersionSelector(object):
# Select highest version if we have many
# Select highest version if we have many
package
=
candidates
[
0
]
package
=
candidates
[
0
]
for
candidate
in
candidates
:
for
candidate
in
candidates
:
if
candidate
.
is_prerelease
()
and
not
allow_prereleases
:
continue
# Select highest version of the two
# Select highest version of the two
if
less_than
(
package
.
version
,
candidate
.
version
):
if
less_than
(
package
.
version
,
candidate
.
version
):
package
=
candidate
package
=
candidate
...
...
tests/fixtures/complete.toml
View file @
3da87bfd
...
@@ -22,7 +22,7 @@ toml = "^0.9"
...
@@ -22,7 +22,7 @@ toml = "^0.9"
# Dependencies with extras
# Dependencies with extras
requests
=
{
version
=
"^2.13"
,
extras
=
[
"security"
]
}
requests
=
{
version
=
"^2.13"
,
extras
=
[
"security"
]
}
# Python specific dependencies with prereleases allowed
# Python specific dependencies with prereleases allowed
pathlib2
=
{
version
=
"^2.2"
,
python
=
"~2.7"
,
allows
_
prereleases
=
true
}
pathlib2
=
{
version
=
"^2.2"
,
python
=
"~2.7"
,
allows
-
prereleases
=
true
}
# Git dependencies
# Git dependencies
cleo
=
{
git
=
"https://github.com/sdispater/cleo.git"
,
branch
=
"master"
}
cleo
=
{
git
=
"https://github.com/sdispater/cleo.git"
,
branch
=
"master"
}
...
...
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