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

Fix bug in legacy depdency check #8418

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 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 @@ -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")

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