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
728fb6f4
Unverified
Commit
728fb6f4
authored
Nov 17, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix prereleases being selected with the add command
parent
58dbca46
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
103 additions
and
16 deletions
+103
-16
CHANGELOG.md
+1
-0
poetry/repositories/legacy_repository.py
+19
-3
poetry/repositories/pypi_repository.py
+11
-7
poetry/repositories/repository.py
+12
-6
tests/console/commands/test_add.py
+33
-0
tests/repositories/fixtures/legacy/pyyaml.html
+12
-0
tests/repositories/fixtures/pypi.org/json/pyyaml.json
+0
-0
tests/repositories/test_legacy_repository.py
+8
-0
tests/repositories/test_pypi_repository.py
+7
-0
No files found.
CHANGELOG.md
View file @
728fb6f4
...
...
@@ -8,6 +8,7 @@
-
Fixed a possible error when building distributions with the
`exclude`
option.
-
Fixed the
`run`
command for namespaced packages.
-
Fixed errors for virtualenvs with spaces in their path.
-
Fixed prerelease versions being selected with the
`add`
command.
## [0.12.8] - 2018-11-13
...
...
poetry/repositories/legacy_repository.py
View file @
728fb6f4
...
...
@@ -37,6 +37,7 @@ from poetry.packages.utils.link import Link
from
poetry.semver
import
parse_constraint
from
poetry.semver
import
Version
from
poetry.semver
import
VersionConstraint
from
poetry.semver
import
VersionRange
from
poetry.utils._compat
import
Path
from
poetry.utils.helpers
import
canonicalize_name
,
get_http_basic_auth
from
poetry.version.markers
import
InvalidMarker
...
...
@@ -187,11 +188,23 @@ class LegacyRepository(PyPiRepository):
):
packages
=
[]
if
constraint
is
not
None
and
not
isinstance
(
constraint
,
VersionConstraint
):
if
constraint
is
None
:
constraint
=
"*"
if
not
isinstance
(
constraint
,
VersionConstraint
):
constraint
=
parse_constraint
(
constraint
)
if
isinstance
(
constraint
,
VersionRange
):
if
(
constraint
.
max
is
not
None
and
constraint
.
max
.
is_prerelease
()
or
constraint
.
min
is
not
None
and
constraint
.
min
.
is_prerelease
()
):
allow_prereleases
=
True
key
=
name
if
constraint
:
if
not
constraint
.
is_any
()
:
key
=
"{}:{}"
.
format
(
key
,
str
(
constraint
))
if
self
.
_cache
.
store
(
"matches"
)
.
has
(
key
):
...
...
@@ -203,7 +216,10 @@ class LegacyRepository(PyPiRepository):
versions
=
[]
for
version
in
page
.
versions
:
if
not
constraint
or
(
constraint
and
constraint
.
allows
(
version
)):
if
version
.
is_prerelease
()
and
not
allow_prereleases
:
continue
if
constraint
.
allows
(
version
):
versions
.
append
(
version
)
self
.
_cache
.
store
(
"matches"
)
.
put
(
key
,
versions
,
5
)
...
...
poetry/repositories/pypi_repository.py
View file @
728fb6f4
...
...
@@ -28,17 +28,16 @@ from cachy import CacheManager
from
requests
import
get
from
requests
import
session
from
poetry.io
import
NullIO
from
poetry.locations
import
CACHE_DIR
from
poetry.packages
import
dependency_from_pep_508
from
poetry.packages
import
Package
from
poetry.semver
import
parse_constraint
from
poetry.semver
import
VersionConstraint
from
poetry.semver
import
VersionRange
from
poetry.utils._compat
import
Path
from
poetry.utils._compat
import
to_str
from
poetry.utils.helpers
import
parse_requires
from
poetry.utils.helpers
import
temporary_directory
from
poetry.utils.env
import
Env
from
poetry.utils.setup_reader
import
SetupReader
from
poetry.version.markers
import
InvalidMarker
...
...
@@ -93,6 +92,15 @@ class PyPiRepository(Repository):
if
not
isinstance
(
constraint
,
VersionConstraint
):
constraint
=
parse_constraint
(
constraint
)
if
isinstance
(
constraint
,
VersionRange
):
if
(
constraint
.
max
is
not
None
and
constraint
.
max
.
is_prerelease
()
or
constraint
.
min
is
not
None
and
constraint
.
min
.
is_prerelease
()
):
allow_prereleases
=
True
info
=
self
.
get_package_info
(
name
)
packages
=
[]
...
...
@@ -110,11 +118,7 @@ class PyPiRepository(Repository):
package
=
Package
(
name
,
version
)
if
(
package
.
is_prerelease
()
and
not
allow_prereleases
and
not
constraint
.
allows
(
package
.
version
)
):
if
package
.
is_prerelease
()
and
not
allow_prereleases
:
continue
if
not
constraint
or
(
constraint
and
constraint
.
allows
(
package
.
version
)):
...
...
poetry/repositories/repository.py
View file @
728fb6f4
from
poetry.semver
import
parse_constraint
from
poetry.semver
import
VersionConstraint
from
poetry.semver
import
VersionRange
from
.base_repository
import
BaseRepository
...
...
@@ -46,16 +47,21 @@ class Repository(BaseRepository):
if
not
isinstance
(
constraint
,
VersionConstraint
):
constraint
=
parse_constraint
(
constraint
)
for
package
in
self
.
packages
:
if
name
==
package
.
name
:
if
isinstance
(
constraint
,
VersionRange
):
if
(
package
.
is_prerelease
()
and
not
allow_prereleases
and
not
constraint
.
allows
(
package
.
version
)
constraint
.
max
is
not
None
and
constraint
.
max
.
is_prerelease
()
or
constraint
.
min
is
not
None
and
constraint
.
min
.
is_prerelease
()
):
allow_prereleases
=
True
for
package
in
self
.
packages
:
if
name
==
package
.
name
:
if
package
.
is_prerelease
()
and
not
allow_prereleases
:
continue
if
constraint
is
None
or
constraint
.
allows
(
package
.
version
):
if
constraint
.
allows
(
package
.
version
):
for
dep
in
package
.
requires
:
for
extra
in
extras
:
if
extra
not
in
package
.
extras
:
...
...
tests/console/commands/test_add.py
View file @
728fb6f4
...
...
@@ -418,3 +418,36 @@ Writing lock file
assert
"cachy"
in
content
[
"dev-dependencies"
]
assert
content
[
"dev-dependencies"
][
"cachy"
]
==
"^0.2.0"
def
test_add_should_not_select_prereleases
(
app
,
repo
,
installer
):
command
=
app
.
find
(
"add"
)
tester
=
CommandTester
(
command
)
repo
.
add_package
(
get_package
(
"pyyaml"
,
"3.13"
))
repo
.
add_package
(
get_package
(
"pyyaml"
,
"4.2b2"
))
tester
.
execute
([(
"command"
,
command
.
get_name
()),
(
"name"
,
[
"pyyaml"
])])
expected
=
"""
\
Using version ^3.13 for pyyaml
Updating dependencies
Resolving dependencies...
Package operations: 1 install, 0 updates, 0 removals
Writing lock file
- Installing pyyaml (3.13)
"""
assert
tester
.
get_display
(
True
)
==
expected
assert
len
(
installer
.
installs
)
==
1
content
=
app
.
poetry
.
file
.
read
()[
"tool"
][
"poetry"
]
assert
"pyyaml"
in
content
[
"dependencies"
]
assert
content
[
"dependencies"
][
"pyyaml"
]
==
"^3.13"
tests/repositories/fixtures/legacy/pyyaml.html
0 → 100644
View file @
728fb6f4
<!DOCTYPE html>
<html>
<head>
<title>
Links for python-language-server
</title>
</head>
<body>
<h1>
Links for python-language-server
</h1>
<a
href=
"https://files.pythonhosted.org/packages/9e/a3/1d13970c3f36777c583f136c136f804d70f500168edc1edea6daa7200769/PyYAML-3.13.tar.gz#sha256=3ef3092145e9b70e3ddd2c7ad59bdd0252a94dfe3949721633e41344de00a6bf"
>
PyYAML-3.13.tar.gz
</a><br/>
<a
href=
"https://files.pythonhosted.org/packages/0f/9d/f98ed0a460dc540f720bbe5c6e076f025595cdfa3e318fad27165db13cf9/PyYAML-4.2b2.tar.gz#sha256=406b717f739e2d00c49873068b71f5454c2420157db51b082d4d2beb17ffffb6"
>
PyYAML-4.2b2.tar.gz
</a><br/>
</body>
</html>
<!--SERIAL 4245719-->
tests/repositories/fixtures/pypi.org/json/pyyaml.json
0 → 100644
View file @
728fb6f4
This diff is collapsed.
Click to expand it.
tests/repositories/test_legacy_repository.py
View file @
728fb6f4
...
...
@@ -128,3 +128,11 @@ def test_get_package_information_skips_dependencies_with_invalid_constraints():
Dependency
(
"pyflakes"
,
">=1.6.0"
),
Dependency
(
"yapf"
,
"*"
),
]
def
test_find_packages_no_prereleases
():
repo
=
MockRepository
()
packages
=
repo
.
find_packages
(
"pyyaml"
)
assert
len
(
packages
)
==
1
tests/repositories/test_pypi_repository.py
View file @
728fb6f4
...
...
@@ -58,6 +58,13 @@ def test_find_packages_with_prereleases():
assert
len
(
packages
)
==
7
def
test_find_packages_does_not_select_prereleases_if_not_allowed
():
repo
=
MockRepository
()
packages
=
repo
.
find_packages
(
"pyyaml"
)
assert
len
(
packages
)
==
1
def
test_package
():
repo
=
MockRepository
()
...
...
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