Skip to content

Commit

Permalink
Use file:// urls for path and directory dependencies (#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby authored Nov 5, 2022
1 parent 432ba1a commit b0b1823
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/poetry/core/packages/directory_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ def base_pep_508_name(self) -> str:
extras = ",".join(sorted(self.extras))
requirement += f"[{extras}]"

path = (
path_to_url(self.path) if self.path.is_absolute() else self.path.as_posix()
)
path = path_to_url(self.full_path)
requirement += f" @ {path}"

return requirement
4 changes: 1 addition & 3 deletions src/poetry/core/packages/file_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ def base_pep_508_name(self) -> str:
extras = ",".join(sorted(self.extras))
requirement += f"[{extras}]"

path = (
path_to_url(self.path) if self.path.is_absolute() else self.path.as_posix()
)
path = path_to_url(self.full_path)
requirement += f" @ {path}"

return requirement
3 changes: 2 additions & 1 deletion tests/packages/test_directory_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def test_directory_dependency_pep_508_local_relative() -> None:
_test_directory_dependency_pep_508("demo", path, requirement)

requirement = f"demo @ {path}"
expected = f"demo @ {path.as_posix()}"
base = Path(__file__).parent
expected = f"demo @ {(base / path).resolve().as_uri()}"
_test_directory_dependency_pep_508("demo", path, requirement, expected)


Expand Down
15 changes: 13 additions & 2 deletions tests/packages/test_file_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ def test_file_dependency_pep_508_local_file_relative_path(
_test_file_dependency_pep_508(mocker, "demo", path, requirement)

requirement = f"demo @ {path}"
expected = f"demo @ {path.as_posix()}"
base = Path(__file__).parent
expected = f"demo @ {(base / path).resolve().as_uri()}"
_test_file_dependency_pep_508(mocker, "demo", path, requirement, expected)


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

rel_path = Path("..") / "fixtures" / "distributions" / wheel
requirement = f'demo @ {rel_path.as_posix()} ; sys_platform == "linux"'
base = Path(__file__).parent
expected = (
f'demo @ {(base / rel_path).resolve().as_uri()} ; sys_platform == "linux"'
)
_test_file_dependency_pep_508(
mocker,
"demo",
rel_path,
requirement,
expected,
marker=SingleMarker("sys.platform", "linux"),
)

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

rel_path = Path("..") / "fixtures" / "distributions" / wheel
requirement = f'demo[foo,bar] @ {rel_path.as_posix()} ; sys_platform == "linux"'
base = Path(__file__).parent
expected = (
f"demo[bar,foo] @ {(base / rel_path).resolve().as_uri()} ;"
' sys_platform == "linux"'
)
_test_file_dependency_pep_508(
mocker,
"demo",
rel_path,
requirement,
f'demo[bar,foo] @ {rel_path.as_posix()} ; sys_platform == "linux"',
expected,
)


Expand Down

0 comments on commit b0b1823

Please sign in to comment.