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
## [Unreleased]
### Fixed
-
Fixed
`add`
command picking up prereleases by default.
## [0.8.1] - 2018-04-13
### Fixed
...
...
poetry/console/commands/add.py
View file @
3da87bfd
...
...
@@ -14,6 +14,7 @@ class AddCommand(VenvCommand):
{ name* : Packages to add. }
{--D|dev : Add package as development dependency. }
{--optional : Add as an optional dependency. }
{ --allow-prereleases : Accept prereleases. }
{--dry-run : Outputs the operations but will not execute anything
(implicitly enables --verbose). }
"""
...
...
@@ -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
)
)
requirements
=
self
.
_determine_requirements
(
packages
)
requirements
=
self
.
_determine_requirements
(
packages
,
allow_prereleases
=
self
.
option
(
'allow-prereleases'
)
)
requirements
=
self
.
_format_requirements
(
requirements
)
# validate requirements format
...
...
@@ -54,12 +58,19 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
parser
.
parse_constraints
(
constraint
)
for
name
,
constraint
in
requirements
.
items
():
if
self
.
option
(
'optional'
):
if
self
.
option
(
'optional'
)
or
self
.
option
(
'allow-prereleases'
)
:
constraint
=
{
'version'
:
constraint
,
'optional'
:
True
'version'
:
constraint
}
if
self
.
option
(
'optional'
):
constraint
=
{
'optional'
:
True
}
if
self
.
option
(
'allow-prereleases'
):
constraint
[
'allows-prereleases'
]
=
True
poetry_content
[
section
][
name
]
=
constraint
# Write new content
...
...
@@ -104,7 +115,8 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
return
status
def
_determine_requirements
(
self
,
requires
# type: List[str]
requires
,
# type: List[str]
allow_prereleases
=
False
,
# type: bool
):
# type: (...) -> List[str]
if
not
requires
:
return
[]
...
...
@@ -115,7 +127,8 @@ If you do not specify a version constraint, poetry will choose a suitable one ba
if
'version'
not
in
requirement
:
# determine the best version automatically
name
,
version
=
self
.
_find_best_version_for_package
(
requirement
[
'name'
]
requirement
[
'name'
],
allow_prereleases
=
allow_prereleases
)
requirement
[
'version'
]
=
version
requirement
[
'name'
]
=
name
...
...
@@ -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
# before we proceed
name
,
_
=
self
.
_find_best_version_for_package
(
requirement
[
'name'
],
requirement
[
'version'
]
requirement
[
'name'
],
requirement
[
'version'
],
allow_prereleases
=
allow_prereleases
)
requirement
[
'name'
]
=
name
...
...
@@ -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
,
name
,
required_version
=
None
required_version
=
None
,
allow_prereleases
=
False
):
# type: (...) -> Tuple[str, str]
from
poetry.version.version_selector
import
VersionSelector
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
:
# TODO: find similar
...
...
poetry/json/schemas/poetry-schema.json
View file @
3da87bfd
...
...
@@ -179,7 +179,7 @@
"type"
:
"string"
,
"description"
:
"The python versions for which the dependency should be installed."
},
"allows
_
prereleases"
:
{
"allows
-
prereleases"
:
{
"type"
:
"boolean"
,
"description"
:
"Whether the dependency allows prereleases or not."
},
...
...
@@ -222,7 +222,7 @@
"type"
:
"string"
,
"description"
:
"The python versions for which the dependency should be installed."
},
"allows
_
prereleases"
:
{
"allows
-
prereleases"
:
{
"type"
:
"boolean"
,
"description"
:
"Whether the dependency allows prereleases or not."
},
...
...
@@ -252,7 +252,7 @@
"type"
:
"string"
,
"description"
:
"The python versions for which the dependency should be installed."
},
"allows
_
prereleases"
:
{
"allows
-
prereleases"
:
{
"type"
:
"boolean"
,
"description"
:
"Whether the dependency allows prereleases or not."
},
...
...
poetry/packages/package.py
View file @
3da87bfd
...
...
@@ -260,7 +260,7 @@ class Package(object):
optional
=
constraint
.
get
(
'optional'
,
False
)
python_versions
=
constraint
.
get
(
'python'
)
platform
=
constraint
.
get
(
'platform'
)
allows_prereleases
=
constraint
.
get
(
'allows
_
prereleases'
,
False
)
allows_prereleases
=
constraint
.
get
(
'allows
-
prereleases'
,
False
)
if
'git'
in
constraint
:
# VCS dependency
...
...
poetry/version/version_selector.py
View file @
3da87bfd
...
...
@@ -14,8 +14,9 @@ class VersionSelector(object):
self
.
_parser
=
parser
def
find_best_candidate
(
self
,
package_name
,
# type: str
target_package_version
=
None
# type: Union[str, None]
package_name
,
# type: str
target_package_version
=
None
,
# type: Union[str, None]
allow_prereleases
=
False
# type: bool
):
# type: (...) -> Union[Package, bool]
"""
Given a package name and optional version,
...
...
@@ -34,6 +35,9 @@ class VersionSelector(object):
# Select highest version if we have many
package
=
candidates
[
0
]
for
candidate
in
candidates
:
if
candidate
.
is_prerelease
()
and
not
allow_prereleases
:
continue
# Select highest version of the two
if
less_than
(
package
.
version
,
candidate
.
version
):
package
=
candidate
...
...
tests/fixtures/complete.toml
View file @
3da87bfd
...
...
@@ -22,7 +22,7 @@ toml = "^0.9"
# Dependencies with extras
requests
=
{
version
=
"^2.13"
,
extras
=
[
"security"
]
}
# 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
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