Skip to content

Commit

Permalink
Fixed dropped import from pkg_resources (PR #7866)
Browse files Browse the repository at this point in the history
# Description

Fixed import of `pkg_resources.extern`, which was dropped in the latest `setuptools` release (v71).

# Self Check:

Strike through any lines that are not applicable (`~~line~~`) then check the box

- [x] ~~Attached issue to pull request~~
- [x] Changelog entry
- [x] ~~Type annotations are present~~
- [x] ~~Code is clear and sufficiently documented~~
- [x] No (preventable) type errors (check using make mypy or make mypy-diff)
- [x] ~~Sufficient test cases (reproduces the bug/tests the requested feature)~~
- [x] Correct, in line with design
- [x] End user documentation is included or an issue is created for end-user documentation (add ref to issue here: )
- [x] ~~If this PR fixes a race condition in the test suite, also push the fix to the relevant stable branche(s) (see [test-fixes](https://internal.inmanta.com/development/core/tasks/build-master.html#test-fixes) for more info)~~
  • Loading branch information
sanderr authored and inmantaci committed Jul 18, 2024
1 parent 4a20ed8 commit 18b2aec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 8 additions & 0 deletions changelogs/unreleased/fix-pkgresources-import.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
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:
- master
- iso7
4 changes: 4 additions & 0 deletions src/inmanta/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,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 @@ -973,6 +975,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
8 changes: 2 additions & 6 deletions src/inmanta/moduletool.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from configparser import ConfigParser
from functools import total_ordering
from re import Pattern
from typing import IO, TYPE_CHECKING, Any, Optional
from typing import IO, Any, Optional

import click
import more_itertools
Expand Down Expand Up @@ -76,13 +76,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

0 comments on commit 18b2aec

Please sign in to comment.