From d3555d2a645d4d2d8f938c071702a1681d454908 Mon Sep 17 00:00:00 2001 From: wouter Date: Wed, 27 Nov 2024 11:40:50 +0100 Subject: [PATCH 1/2] Added changelog and fixes --- .../unreleased/8405_env_requirements_check.yml | 6 ++++++ src/inmanta/env.py | 14 +++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 changelogs/unreleased/8405_env_requirements_check.yml diff --git a/changelogs/unreleased/8405_env_requirements_check.yml b/changelogs/unreleased/8405_env_requirements_check.yml new file mode 100644 index 0000000000..1de085c704 --- /dev/null +++ b/changelogs/unreleased/8405_env_requirements_check.yml @@ -0,0 +1,6 @@ +description: Fix handling of extras in legacy dependency check +issue-nr: 8405 +change-type: patch +destination-branches: [master, iso7] +sections: + bugfix: "{{description}}" diff --git a/src/inmanta/env.py b/src/inmanta/env.py index 37e88b2d4b..d0f7e5b22e 100644 --- a/src/inmanta/env.py +++ b/src/inmanta/env.py @@ -1164,6 +1164,8 @@ def get_constraint_violations_for_check( """ Return the constraint violations that exist in this venv. Returns a tuple of non-strict and strict violations, in that order. + + Extra's are ignored entirely """ inmanta_core_canonical = packaging.utils.canonicalize_name("inmanta-core") @@ -1218,9 +1220,10 @@ def is_owned_by(self, owners: abc.Set[NormalizedName]) -> bool: for c in all_constraints: requirement = c.requirement req_name = NormalizedName(requirement.name) # requirement is already canonical + if requirement.marker and not requirement.marker.evaluate(): + continue if req_name not in installed_versions or ( not requirement.specifier.contains(installed_versions[req_name], prereleases=True) - and (not requirement.marker or (requirement.marker and requirement.marker.evaluate())) ): version_conflict = VersionConflict( requirement=requirement, @@ -1270,6 +1273,8 @@ def check_legacy( in the sense that it has been replaced with a more correct check defined in self.check(). This method is invoked when the `--no-strict-deps-check` commandline option is provided. + Extra's are ignored + :param in_scope: A full pattern representing the package names that are considered in scope for the installed packages' compatibility check. Only in scope packages' dependencies will be considered for conflicts. The pattern is matched against an all-lowercase package name. @@ -1294,8 +1299,11 @@ def check_legacy( constraint_violations: set[VersionConflict] = { VersionConflict(constraint, installed_versions.get(constraint.name, None)) for constraint in all_constraints - if constraint.name not in installed_versions - or not constraint.specifier.contains(installed_versions[constraint.name], prereleases=True) + if (not constraint.marker or constraint.marker.evaluate()) + and ( + constraint.name not in installed_versions + or not constraint.specifier.contains(installed_versions[constraint.name], prereleases=True) + ) } all_violations = constraint_violations_non_strict | constraint_violations_strict | constraint_violations From bb3ee41f581b78097d63c441a978549ce1728328 Mon Sep 17 00:00:00 2001 From: wouter Date: Wed, 27 Nov 2024 11:54:18 +0100 Subject: [PATCH 2/2] use double if --- src/inmanta/env.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/inmanta/env.py b/src/inmanta/env.py index d0f7e5b22e..0cd5be438d 100644 --- a/src/inmanta/env.py +++ b/src/inmanta/env.py @@ -1299,8 +1299,8 @@ def check_legacy( constraint_violations: set[VersionConflict] = { VersionConflict(constraint, installed_versions.get(constraint.name, None)) for constraint in all_constraints - if (not constraint.marker or constraint.marker.evaluate()) - and ( + if not constraint.marker or constraint.marker.evaluate() + if ( constraint.name not in installed_versions or not constraint.specifier.contains(installed_versions[constraint.name], prereleases=True) )