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
ddfb35d0
You need to sign in or sign up before continuing.
Unverified
Commit
ddfb35d0
authored
Jun 23, 2021
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix locked information for path, url and VCS dependencies
parent
925429fd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
96 additions
and
8 deletions
+96
-8
poetry/packages/locker.py
+23
-2
tests/installation/fixtures/with-directory-dependency-poetry-transitive.test
+4
-4
tests/installation/fixtures/with-file-dependency-transitive.test
+2
-2
tests/packages/test_locker.py
+67
-0
No files found.
poetry/packages/locker.py
View file @
ddfb35d0
...
@@ -513,7 +513,25 @@ class Locker:
...
@@ -513,7 +513,25 @@ class Locker:
dependencies
[
dependency
.
pretty_name
]
=
[]
dependencies
[
dependency
.
pretty_name
]
=
[]
constraint
=
inline_table
()
constraint
=
inline_table
()
constraint
[
"version"
]
=
str
(
dependency
.
pretty_constraint
)
if
dependency
.
is_directory
()
or
dependency
.
is_file
():
constraint
[
"path"
]
=
dependency
.
path
.
as_posix
()
if
dependency
.
is_directory
()
and
dependency
.
develop
:
constraint
[
"develop"
]
=
True
elif
dependency
.
is_url
():
constraint
[
"url"
]
=
dependency
.
url
elif
dependency
.
is_vcs
():
constraint
[
dependency
.
vcs
]
=
dependency
.
source
if
dependency
.
branch
:
constraint
[
"branch"
]
=
dependency
.
branch
elif
dependency
.
tag
:
constraint
[
"tag"
]
=
dependency
.
tag
elif
dependency
.
rev
:
constraint
[
"rev"
]
=
dependency
.
rev
else
:
constraint
[
"version"
]
=
str
(
dependency
.
pretty_constraint
)
if
dependency
.
extras
:
if
dependency
.
extras
:
constraint
[
"extras"
]
=
sorted
(
dependency
.
extras
)
constraint
[
"extras"
]
=
sorted
(
dependency
.
extras
)
...
@@ -529,7 +547,10 @@ class Locker:
...
@@ -529,7 +547,10 @@ class Locker:
# All the constraints should have the same type,
# All the constraints should have the same type,
# but we want to simplify them if it's possible
# but we want to simplify them if it's possible
for
dependency
,
constraints
in
tuple
(
dependencies
.
items
()):
for
dependency
,
constraints
in
tuple
(
dependencies
.
items
()):
if
all
(
len
(
constraint
)
==
1
for
constraint
in
constraints
):
if
all
(
len
(
constraint
)
==
1
and
"version"
in
constraint
for
constraint
in
constraints
):
dependencies
[
dependency
]
=
[
dependencies
[
dependency
]
=
[
constraint
[
"version"
]
for
constraint
in
constraints
constraint
[
"version"
]
for
constraint
in
constraints
]
]
...
...
tests/installation/fixtures/with-directory-dependency-poetry-transitive.test
View file @
ddfb35d0
...
@@ -65,8 +65,8 @@ python-versions = "*"
...
@@ -65,8 +65,8 @@ python-versions = "*"
version
=
"1.2.3"
version
=
"1.2.3"
[
package
.
dependencies
]
[
package
.
dependencies
]
project
-
with
-
extras
=
"1.2.3"
project
-
with
-
extras
=
{
"path"
=
"../../project_with_extras"
}
project
-
with
-
transitive
-
file
-
dependencies
=
"1.2.3"
project
-
with
-
transitive
-
file
-
dependencies
=
{
"path"
=
"../project_with_transitive_file_dependencies"
}
[
package
.
source
]
[
package
.
source
]
type
=
"directory"
type
=
"directory"
...
@@ -82,8 +82,8 @@ python-versions = "*"
...
@@ -82,8 +82,8 @@ python-versions = "*"
version
=
"1.2.3"
version
=
"1.2.3"
[
package
.
dependencies
]
[
package
.
dependencies
]
demo
=
"0.1.0"
demo
=
{
"path"
=
"../../distributions/demo-0.1.0-py2.py3-none-any.whl"
}
inner
-
directory
-
project
=
"1.2.4"
inner
-
directory
-
project
=
{
"path"
=
"inner-directory-project"
}
[
package
.
source
]
[
package
.
source
]
type
=
"directory"
type
=
"directory"
...
...
tests/installation/fixtures/with-file-dependency-transitive.test
View file @
ddfb35d0
...
@@ -48,8 +48,8 @@ python-versions = "*"
...
@@ -48,8 +48,8 @@ python-versions = "*"
version
=
"1.2.3"
version
=
"1.2.3"
[
package
.
dependencies
]
[
package
.
dependencies
]
demo
=
"0.1.0"
demo
=
{
"path"
=
"../../distributions/demo-0.1.0-py2.py3-none-any.whl"
}
inner
-
directory
-
project
=
"1.2.4"
inner
-
directory
-
project
=
{
"path"
=
"inner-directory-project"
}
[
package
.
source
]
[
package
.
source
]
type
=
"directory"
type
=
"directory"
...
...
tests/packages/test_locker.py
View file @
ddfb35d0
import
logging
import
logging
import
tempfile
import
tempfile
from
pathlib
import
Path
import
pytest
import
pytest
import
tomlkit
import
tomlkit
...
@@ -531,3 +533,68 @@ content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77
...
@@ -531,3 +533,68 @@ content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77
_
=
locker
.
lock_data
_
=
locker
.
lock_data
assert
0
==
len
(
caplog
.
records
)
assert
0
==
len
(
caplog
.
records
)
def
test_locker_dumps_dependency_information_correctly
(
locker
,
root
):
root_dir
=
Path
(
__file__
)
.
parent
.
parent
.
joinpath
(
"fixtures"
)
package_a
=
get_package
(
"A"
,
"1.0.0"
)
package_a
.
add_dependency
(
Factory
.
create_dependency
(
"B"
,
{
"path"
:
"project_with_extras"
,
"develop"
:
True
},
root_dir
=
root_dir
)
)
package_a
.
add_dependency
(
Factory
.
create_dependency
(
"C"
,
{
"path"
:
"directory/project_with_transitive_directory_dependencies"
},
root_dir
=
root_dir
,
)
)
package_a
.
add_dependency
(
Factory
.
create_dependency
(
"D"
,
{
"path"
:
"distributions/demo-0.1.0.tar.gz"
},
root_dir
=
root_dir
)
)
package_a
.
add_dependency
(
Factory
.
create_dependency
(
"E"
,
{
"url"
:
"https://python-poetry.org/poetry-1.2.0.tar.gz"
}
)
)
package_a
.
add_dependency
(
Factory
.
create_dependency
(
"F"
,
{
"git"
:
"https://github.com/python-poetry/poetry.git"
,
"branch"
:
"foo"
}
)
)
packages
=
[
package_a
]
locker
.
set_lock_data
(
root
,
packages
)
with
locker
.
lock
.
open
(
encoding
=
"utf-8"
)
as
f
:
content
=
f
.
read
()
expected
=
"""[[package]]
name = "A"
version = "1.0.0"
description = ""
category = "main"
optional = false
python-versions = "*"
[package.dependencies]
B = {path = "project_with_extras", develop = true}
C = {path = "directory/project_with_transitive_directory_dependencies"}
D = {path = "distributions/demo-0.1.0.tar.gz"}
E = {url = "https://python-poetry.org/poetry-1.2.0.tar.gz"}
F = {git = "https://github.com/python-poetry/poetry.git", branch = "foo"}
[metadata]
lock-version = "1.1"
python-versions = "*"
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
[metadata.files]
A = []
"""
assert
expected
==
content
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