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
4275a551
Commit
4275a551
authored
Jul 02, 2021
by
Matthieu Devlin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: create path dependencies relative to package rather than lockfile (#4245)
parent
22c3aadd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
7 deletions
+55
-7
poetry/packages/locker.py
+12
-6
tests/packages/test_locker.py
+43
-1
No files found.
poetry/packages/locker.py
View file @
4275a551
...
@@ -176,20 +176,26 @@ class Locker:
...
@@ -176,20 +176,26 @@ class Locker:
package
.
marker
=
parse_marker
(
split_dep
[
1
]
.
strip
())
package
.
marker
=
parse_marker
(
split_dep
[
1
]
.
strip
())
for
dep_name
,
constraint
in
info
.
get
(
"dependencies"
,
{})
.
items
():
for
dep_name
,
constraint
in
info
.
get
(
"dependencies"
,
{})
.
items
():
root_dir
=
self
.
_lock
.
path
.
parent
if
package
.
source_type
==
"directory"
:
# root dir should be the source of the package relative to the lock path
root_dir
=
Path
(
os
.
path
.
relpath
(
Path
(
package
.
source_url
),
self
.
_lock
.
path
.
parent
)
)
.
resolve
()
if
isinstance
(
constraint
,
list
):
if
isinstance
(
constraint
,
list
):
for
c
in
constraint
:
for
c
in
constraint
:
package
.
add_dependency
(
package
.
add_dependency
(
Factory
.
create_dependency
(
Factory
.
create_dependency
(
dep_name
,
c
,
root_dir
=
root_dir
)
dep_name
,
c
,
root_dir
=
self
.
_lock
.
path
.
parent
)
)
)
continue
continue
package
.
add_dependency
(
package
.
add_dependency
(
Factory
.
create_dependency
(
Factory
.
create_dependency
(
dep_name
,
constraint
,
root_dir
=
root_dir
)
dep_name
,
constraint
,
root_dir
=
self
.
_lock
.
path
.
parent
)
)
)
if
"develop"
in
info
:
if
"develop"
in
info
:
...
...
tests/packages/test_locker.py
View file @
4275a551
...
@@ -348,7 +348,7 @@ A = []
...
@@ -348,7 +348,7 @@ A = []
def
test_reading_lock_file_should_raise_an_error_on_invalid_data
(
locker
):
def
test_reading_lock_file_should_raise_an_error_on_invalid_data
(
locker
):
content
=
u
"""[[package]]
content
=
"""[[package]]
name = "A"
name = "A"
version = "1.0.0"
version = "1.0.0"
description = ""
description = ""
...
@@ -598,3 +598,45 @@ A = []
...
@@ -598,3 +598,45 @@ A = []
"""
"""
assert
expected
==
content
assert
expected
==
content
def
test_locked_repository_uses_root_dir_of_package
(
locker
,
mocker
):
content
=
"""
\
[[package]]
name = "lib-a"
version = "0.1.0"
description = ""
category = "main"
optional = false
python-versions = "^2.7.9"
develop = true
[package.dependencies]
lib-b = {path = "../libB", develop = true}
[package.source]
type = "directory"
url = "lib/libA"
[metadata]
lock-version = "1.1"
python-versions = "*"
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
[metadata.files]
lib-a = []
lib-b = []
"""
locker
.
lock
.
write
(
tomlkit
.
parse
(
content
))
create_dependency_patch
=
mocker
.
patch
(
"poetry.factory.Factory.create_dependency"
,
autospec
=
True
)
locker
.
locked_repository
()
create_dependency_patch
.
assert_called_once_with
(
"lib-b"
,
{
"develop"
:
True
,
"path"
:
"../libB"
},
root_dir
=
mocker
.
ANY
)
root_dir
=
create_dependency_patch
.
call_args
.
kwargs
[
"root_dir"
]
assert
root_dir
.
match
(
"*/lib/libA"
)
assert
root_dir
.
is_relative_to
(
locker
.
lock
.
path
.
parent
.
resolve
())
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