Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use file:// urls for path and directory dependencies #512

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/poetry/core/packages/directory_dependency.py
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
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
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
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