From 47f7ecedb54d5e939457b8fca63a59698c9e4214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Sun, 10 Mar 2024 14:12:27 +0100 Subject: [PATCH] add support for PEP 621: use `all_requires_for_locking` instead of `all_requires` --- src/poetry/console/commands/debug/resolve.py | 2 +- src/poetry/console/commands/show.py | 6 +++--- src/poetry/factory.py | 2 +- src/poetry/puzzle/provider.py | 4 ++-- src/poetry/puzzle/solver.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/poetry/console/commands/debug/resolve.py b/src/poetry/console/commands/debug/resolve.py index 8bf36668697..1210ff12d99 100644 --- a/src/poetry/console/commands/debug/resolve.py +++ b/src/poetry/console/commands/debug/resolve.py @@ -104,7 +104,7 @@ def handle(self) -> int: packages = [op.package for op in ops] - requires = package.all_requires + requires = package.all_requires_for_locking for pkg in packages: for require in requires: if pkg.name == require.name: diff --git a/src/poetry/console/commands/show.py b/src/poetry/console/commands/show.py index 6bcd7eca7fb..d990b087a9a 100644 --- a/src/poetry/console/commands/show.py +++ b/src/poetry/console/commands/show.py @@ -315,7 +315,7 @@ def _display_packages_information( write_why = self.option("why") and (why_end_column + 3) <= width write_description = (why_end_column + 24) <= width - requires = root.all_requires + requires = root.all_requires_for_locking for locked in locked_packages: color = "cyan" @@ -406,7 +406,7 @@ def _display_packages_tree_information( packages = locked_repository.packages for p in packages: - for require in root.all_requires: + for require in root.all_requires_for_locking: if p.name == require.name: self.display_package_tree(self.io, p, packages) break @@ -544,7 +544,7 @@ def find_latest_package( from poetry.version.version_selector import VersionSelector # find the latest version allowed in this pool - requires = root.all_requires + requires = root.all_requires_for_locking if package.is_direct_origin(): for dep in requires: if dep.name == package.name and dep.source_type == package.source_type: diff --git a/src/poetry/factory.py b/src/poetry/factory.py index 781f8c01000..b4ede83ce16 100644 --- a/src/poetry/factory.py +++ b/src/poetry/factory.py @@ -307,7 +307,7 @@ def create_pyproject_from_package(cls, package: Package) -> TOMLDocument: dependency_section = content["dependencies"] = tomlkit.table() dependency_section["python"] = package.python_versions - for dep in package.all_requires: + for dep in package.all_requires_for_locking: constraint: DependencySpec | str = dependency_to_specification( dep, tomlkit.inline_table() ) diff --git a/src/poetry/puzzle/provider.py b/src/poetry/puzzle/provider.py index 754795b845c..94ab972a193 100644 --- a/src/poetry/puzzle/provider.py +++ b/src/poetry/puzzle/provider.py @@ -419,7 +419,7 @@ def incompatibilities_for( """ package = dependency_package.package if package.is_root(): - dependencies = package.all_requires + dependencies = package.all_requires_for_locking else: dependencies = package.requires @@ -479,7 +479,7 @@ def complete_package( dependency_package = dependency_package.clone() package = dependency_package.package dependency = dependency_package.dependency - requires = package.all_requires + requires = package.all_requires_for_locking elif package.is_direct_origin(): requires = package.requires else: diff --git a/src/poetry/puzzle/solver.py b/src/poetry/puzzle/solver.py index af107646876..32368cbbdd1 100644 --- a/src/poetry/puzzle/solver.py +++ b/src/poetry/puzzle/solver.py @@ -287,7 +287,7 @@ def __init__( def reachable(self) -> list[PackageNode]: children: list[PackageNode] = [] - for dependency in self.package.all_requires: + for dependency in self.package.all_requires_for_locking: for pkg in self.packages: if pkg.complete_name == dependency.complete_name and ( dependency.constraint.allows(pkg.version)