Skip to content

Commit

Permalink
Fix handling of extras in legacy dependency check (Issue #8405, PR #8418
Browse files Browse the repository at this point in the history
)

Pull request opened by the merge tool on behalf of #8418
  • Loading branch information
wouterdb authored and inmantaci committed Nov 27, 2024
1 parent f787cdd commit ad30ffe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 6 additions & 0 deletions changelogs/unreleased/8405_env_requirements_check.yml
Original file line number Diff line number Diff line change
@@ -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}}"
14 changes: 11 additions & 3 deletions src/inmanta/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down

0 comments on commit ad30ffe

Please sign in to comment.