File tree 2 files changed +52
-6
lines changed
2 files changed +52
-6
lines changed Original file line number Diff line number Diff line change @@ -174,20 +174,22 @@ def locked_repository(
174
174
package .marker = parse_marker (split_dep [1 ].strip ())
175
175
176
176
for dep_name , constraint in info .get ("dependencies" , {}).items ():
177
+
178
+ root_dir = self ._lock .path .parent
179
+ if package .source_type == "directory" :
180
+ # root dir should be the source of the package relative to the lock path
181
+ root_dir = Path (package .source_url )
182
+
177
183
if isinstance (constraint , list ):
178
184
for c in constraint :
179
185
package .add_dependency (
180
- Factory .create_dependency (
181
- dep_name , c , root_dir = self ._lock .path .parent
182
- )
186
+ Factory .create_dependency (dep_name , c , root_dir = root_dir )
183
187
)
184
188
185
189
continue
186
190
187
191
package .add_dependency (
188
- Factory .create_dependency (
189
- dep_name , constraint , root_dir = self ._lock .path .parent
190
- )
192
+ Factory .create_dependency (dep_name , constraint , root_dir = root_dir )
191
193
)
192
194
193
195
if "develop" in info :
Original file line number Diff line number Diff line change 1
1
import logging
2
+ import sys
2
3
import tempfile
3
4
4
5
import pytest
@@ -595,3 +596,46 @@ def test_locker_dumps_dependency_information_correctly(locker, root):
595
596
"""
596
597
597
598
assert expected == content
599
+
600
+
601
+ @pytest .mark .skipif (sys .version_info [:2 ] == (3 , 5 ), reason = "Skip for Python 3.5" )
602
+ def test_locked_repository_uses_root_dir_of_package (locker , mocker ):
603
+ content = """\
604
+ [[package]]
605
+ name = "lib-a"
606
+ version = "0.1.0"
607
+ description = ""
608
+ category = "main"
609
+ optional = false
610
+ python-versions = "^2.7.9"
611
+ develop = true
612
+
613
+ [package.dependencies]
614
+ lib-b = {path = "../libB", develop = true}
615
+
616
+ [package.source]
617
+ type = "directory"
618
+ url = "lib/libA"
619
+
620
+ [metadata]
621
+ lock-version = "1.1"
622
+ python-versions = "*"
623
+ content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
624
+
625
+ [metadata.files]
626
+ lib-a = []
627
+ lib-b = []
628
+ """
629
+
630
+ locker .lock .write (tomlkit .parse (content ))
631
+ create_dependency_patch = mocker .patch ("poetry.factory.Factory.create_dependency" )
632
+ locker .locked_repository ()
633
+
634
+ create_dependency_patch .assert_called_once_with (
635
+ "lib-b" , {"develop" : True , "path" : "../libB" }, root_dir = mocker .ANY
636
+ )
637
+ call_kwargs = create_dependency_patch .call_args [1 ]
638
+ root_dir = call_kwargs ["root_dir" ]
639
+ assert root_dir .match ("*/lib/libA" )
640
+ # relative_to raises an exception if not relative - is_relative_to comes in py3.9
641
+ assert root_dir .relative_to (locker .lock .path .parent .resolve ()) is not None
You can’t perform that action at this time.
0 commit comments