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 bcaeaf4bba..4e2d8947db 100644 --- a/src/inmanta/env.py +++ b/src/inmanta/env.py @@ -993,6 +993,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") @@ -1047,9 +1049,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, @@ -1099,6 +1102,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. @@ -1123,8 +1128,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() + if ( + 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