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

Enable Resolving PathDependencies #289

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/poetry_plugin_export/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class ExportCommand(GroupCommand):
),
option("all-extras", None, "Include all sets of extra dependencies."),
option("with-credentials", None, "Include credentials for extra indices."),
option(
"resolve-path-dependencies",
"P",
"Resolve path dependencies to package versions.",
),
]

@property
Expand Down Expand Up @@ -122,6 +127,7 @@ def handle(self) -> int:
exporter.with_hashes(not self.option("without-hashes"))
exporter.with_credentials(self.option("with-credentials"))
exporter.with_urls(not self.option("without-urls"))
exporter.resolve_path_dependencies(self.option("resolve-path-dependencies"))
exporter.export(fmt, Path.cwd(), output or self.io)

return 0
18 changes: 15 additions & 3 deletions src/poetry_plugin_export/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__(self, poetry: Poetry, io: IO) -> None:
self._with_hashes = True
self._with_credentials = False
self._with_urls = True
self._resolve_path_dependencies = False
self._extras: Collection[NormalizedName] = ()
self._groups: Iterable[str] = [MAIN_GROUP]

Expand Down Expand Up @@ -74,14 +75,25 @@ def with_credentials(self, with_credentials: bool = True) -> Exporter:

return self

def resolve_path_dependencies(
self, resolve_path_dependencies: bool = False
) -> Exporter:
self._resolve_path_dependencies = resolve_path_dependencies

return self

def export(self, fmt: str, cwd: Path, output: IO | str) -> None:
if not self.is_format_supported(fmt):
raise ValueError(f"Invalid export format: {fmt}")

getattr(self, self.EXPORT_METHODS[fmt])(cwd, output)

def _export_generic_txt(
self, cwd: Path, output: IO | str, with_extras: bool, allow_editable: bool
self,
cwd: Path,
output: IO | str,
with_extras: bool,
allow_editable: bool,
Comment on lines +92 to +96
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated change?

) -> None:
from poetry.core.packages.utils.utils import path_to_url

Expand Down Expand Up @@ -117,8 +129,8 @@ def _export_generic_txt(
continue

requirement = dependency.to_pep_508(with_extras=False, resolved=True)
is_direct_local_reference = (
dependency.is_file() or dependency.is_directory()
is_direct_local_reference = dependency.is_file() or (
dependency.is_directory() and not self._resolve_path_dependencies
)
is_direct_remote_reference = dependency.is_vcs() or dependency.is_url()

Expand Down
Loading