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 pkgresources import iso6 #7869

Closed
wants to merge 15 commits into from
7 changes: 7 additions & 0 deletions changelogs/unreleased/fix-pkgresources-import.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
description: Fixed dropped import from pkg_resources
change-type: patch
sections:
bugfix: "Addressed breaking change in setuptools (core Python library)"
upgrade-note: "If you had previously constrained `setuptools<71` in your project's `requirements.txt`, you may now drop the constraint"
destination-branches:
- iso6
14 changes: 5 additions & 9 deletions src/inmanta/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,9 @@
from inmanta.server.bootloader import InmantaBootloader
from inmanta.stable_api import stable_api
from inmanta.util import strtobool
from packaging.requirements import InvalidRequirement
from packaging import version

try:
from typing import TYPE_CHECKING
except ImportError:
TYPE_CHECKING = False

if TYPE_CHECKING:
from packaging.requirements import InvalidRequirement
else:
from pkg_resources.extern.packaging.requirements import InvalidRequirement

LOGGER = logging.getLogger(__name__)
LOGGER_PIP = logging.getLogger("inmanta.pip") # Use this logger to log pip commands or data related to pip commands.
Expand Down Expand Up @@ -930,6 +922,8 @@ def is_owned_by(self, owners: abc.Set[str]) -> bool:
installed_constraints: abc.Set[OwnedRequirement] = frozenset(
OwnedRequirement(requirement, dist_info.key)
for dist_info in pkg_resources.working_set
# pypa/setuptools#4482. May be removed when we migrate away from pkg_resources
if not dist_info.location.endswith("setuptools/_vendor")
for requirement in dist_info.requires()
)
inmanta_constraints: abc.Set[OwnedRequirement] = frozenset(
Expand Down Expand Up @@ -1025,6 +1019,8 @@ def check_legacy(cls, in_scope: Pattern[str], constraints: Optional[list[Require
requirement
for dist_info in working_set
if in_scope.fullmatch(dist_info.key)
# pypa/setuptools#4482. May be removed when we migrate away from pkg_resources
if not dist_info.location.endswith("setuptools/_vendor")
for requirement in dist_info.requires()
)

Expand Down
7 changes: 2 additions & 5 deletions src/inmanta/moduletool.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from configparser import ConfigParser
from functools import total_ordering
from re import Pattern
from typing import TYPE_CHECKING, Any, Dict, List, Optional
from typing import Any, Dict, List, Optional

import click
import more_itertools
Expand Down Expand Up @@ -74,12 +74,9 @@
gitprovider,
)
from inmanta.stable_api import stable_api
from packaging.requirements import InvalidRequirement
from packaging.version import Version

if TYPE_CHECKING:
from packaging.requirements import InvalidRequirement
else:
from pkg_resources.extern.packaging.requirements import InvalidRequirement

LOGGER = logging.getLogger(__name__)

Expand Down