Skip to content

Commit b0b1823

Browse files
authored
Use file:// urls for path and directory dependencies (#512)
fixes python-poetry/poetry#5273
1 parent 432ba1a commit b0b1823

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

src/poetry/core/packages/directory_dependency.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ def base_pep_508_name(self) -> str:
8989
extras = ",".join(sorted(self.extras))
9090
requirement += f"[{extras}]"
9191

92-
path = (
93-
path_to_url(self.path) if self.path.is_absolute() else self.path.as_posix()
94-
)
92+
path = path_to_url(self.full_path)
9593
requirement += f" @ {path}"
9694

9795
return requirement

src/poetry/core/packages/file_dependency.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ def base_pep_508_name(self) -> str:
7878
extras = ",".join(sorted(self.extras))
7979
requirement += f"[{extras}]"
8080

81-
path = (
82-
path_to_url(self.path) if self.path.is_absolute() else self.path.as_posix()
83-
)
81+
path = path_to_url(self.full_path)
8482
requirement += f" @ {path}"
8583

8684
return requirement

tests/packages/test_directory_dependency.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ def test_directory_dependency_pep_508_local_relative() -> None:
6666
_test_directory_dependency_pep_508("demo", path, requirement)
6767

6868
requirement = f"demo @ {path}"
69-
expected = f"demo @ {path.as_posix()}"
69+
base = Path(__file__).parent
70+
expected = f"demo @ {(base / path).resolve().as_uri()}"
7071
_test_directory_dependency_pep_508("demo", path, requirement, expected)
7172

7273

tests/packages/test_file_dependency.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ def test_file_dependency_pep_508_local_file_relative_path(
145145
_test_file_dependency_pep_508(mocker, "demo", path, requirement)
146146

147147
requirement = f"demo @ {path}"
148-
expected = f"demo @ {path.as_posix()}"
148+
base = Path(__file__).parent
149+
expected = f"demo @ {(base / path).resolve().as_uri()}"
149150
_test_file_dependency_pep_508(mocker, "demo", path, requirement, expected)
150151

151152

@@ -168,11 +169,16 @@ def test_relative_file_dependency_to_pep_508_with_marker(mocker: MockerFixture)
168169

169170
rel_path = Path("..") / "fixtures" / "distributions" / wheel
170171
requirement = f'demo @ {rel_path.as_posix()} ; sys_platform == "linux"'
172+
base = Path(__file__).parent
173+
expected = (
174+
f'demo @ {(base / rel_path).resolve().as_uri()} ; sys_platform == "linux"'
175+
)
171176
_test_file_dependency_pep_508(
172177
mocker,
173178
"demo",
174179
rel_path,
175180
requirement,
181+
expected,
176182
marker=SingleMarker("sys.platform", "linux"),
177183
)
178184

@@ -182,12 +188,17 @@ def test_file_dependency_pep_508_extras(mocker: MockerFixture) -> None:
182188

183189
rel_path = Path("..") / "fixtures" / "distributions" / wheel
184190
requirement = f'demo[foo,bar] @ {rel_path.as_posix()} ; sys_platform == "linux"'
191+
base = Path(__file__).parent
192+
expected = (
193+
f"demo[bar,foo] @ {(base / rel_path).resolve().as_uri()} ;"
194+
' sys_platform == "linux"'
195+
)
185196
_test_file_dependency_pep_508(
186197
mocker,
187198
"demo",
188199
rel_path,
189200
requirement,
190-
f'demo[bar,foo] @ {rel_path.as_posix()} ; sys_platform == "linux"',
201+
expected,
191202
)
192203

193204

0 commit comments

Comments
 (0)