From 2d83c1a124fb9197b9d8d29e86c92a581a5a3b9c Mon Sep 17 00:00:00 2001 From: Sander Van Balen Date: Thu, 18 Jul 2024 10:46:09 +0200 Subject: [PATCH 1/7] fixed broken pkg_resources import --- changelogs/unreleased/fix-pkgresources-import.yml | 4 ++++ src/inmanta/moduletool.py | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 changelogs/unreleased/fix-pkgresources-import.yml diff --git a/changelogs/unreleased/fix-pkgresources-import.yml b/changelogs/unreleased/fix-pkgresources-import.yml new file mode 100644 index 0000000000..cf33b70c21 --- /dev/null +++ b/changelogs/unreleased/fix-pkgresources-import.yml @@ -0,0 +1,4 @@ +description: Fixed dropped import from pkg_resources +sections: + bugfix: "Addressed breaking change in setuptools (core Python library)" + upgrade-note: "If you had previously constrained `setuptools<71` in your `pyproject.yml`, you may now drop the constraint" diff --git a/src/inmanta/moduletool.py b/src/inmanta/moduletool.py index 403191db99..7d576bd96c 100644 --- a/src/inmanta/moduletool.py +++ b/src/inmanta/moduletool.py @@ -76,12 +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__) From bcef38920539491fbc8e7e6f80b610d85d2c189f Mon Sep 17 00:00:00 2001 From: Sander Van Balen Date: Thu, 18 Jul 2024 11:14:20 +0200 Subject: [PATCH 2/7] added destination branches --- changelogs/unreleased/fix-pkgresources-import.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelogs/unreleased/fix-pkgresources-import.yml b/changelogs/unreleased/fix-pkgresources-import.yml index cf33b70c21..14db681a6b 100644 --- a/changelogs/unreleased/fix-pkgresources-import.yml +++ b/changelogs/unreleased/fix-pkgresources-import.yml @@ -2,3 +2,6 @@ description: Fixed dropped import from pkg_resources sections: bugfix: "Addressed breaking change in setuptools (core Python library)" upgrade-note: "If you had previously constrained `setuptools<71` in your `pyproject.yml`, you may now drop the constraint" +destination-branches: + - master + - iso7 From 3680eaf545b47e9a88e475aac02f5cf284a54b19 Mon Sep 17 00:00:00 2001 From: Sander Van Balen Date: Thu, 18 Jul 2024 11:20:40 +0200 Subject: [PATCH 3/7] pep8 --- src/inmanta/moduletool.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/inmanta/moduletool.py b/src/inmanta/moduletool.py index 7d576bd96c..fd97ada02b 100644 --- a/src/inmanta/moduletool.py +++ b/src/inmanta/moduletool.py @@ -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 @@ -79,7 +79,6 @@ from packaging.requirements import InvalidRequirement from packaging.version import Version - LOGGER = logging.getLogger(__name__) From 5c09002e3d608bfe6bbeeb2174b7be3ac1b949e6 Mon Sep 17 00:00:00 2001 From: Sander Van Balen Date: Thu, 18 Jul 2024 11:30:09 +0200 Subject: [PATCH 4/7] changelog typo --- changelogs/unreleased/fix-pkgresources-import.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/unreleased/fix-pkgresources-import.yml b/changelogs/unreleased/fix-pkgresources-import.yml index 14db681a6b..1f76aeea39 100644 --- a/changelogs/unreleased/fix-pkgresources-import.yml +++ b/changelogs/unreleased/fix-pkgresources-import.yml @@ -1,7 +1,7 @@ description: Fixed dropped import from pkg_resources sections: bugfix: "Addressed breaking change in setuptools (core Python library)" - upgrade-note: "If you had previously constrained `setuptools<71` in your `pyproject.yml`, you may now drop the constraint" + upgrade-note: "If you had previously constrained `setuptools<71` in your `project.yml`, you may now drop the constraint" destination-branches: - master - iso7 From 34503332ddd8fead2278d7234e02e5fed4958318 Mon Sep 17 00:00:00 2001 From: Sander Van Balen Date: Thu, 18 Jul 2024 11:44:39 +0200 Subject: [PATCH 5/7] added change type --- changelogs/unreleased/fix-pkgresources-import.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/changelogs/unreleased/fix-pkgresources-import.yml b/changelogs/unreleased/fix-pkgresources-import.yml index 1f76aeea39..a33648334d 100644 --- a/changelogs/unreleased/fix-pkgresources-import.yml +++ b/changelogs/unreleased/fix-pkgresources-import.yml @@ -1,4 +1,5 @@ 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.yml`, you may now drop the constraint" From 8d11787887859afe5279346aab9c753df8810763 Mon Sep 17 00:00:00 2001 From: Sander Van Balen Date: Thu, 18 Jul 2024 11:47:28 +0200 Subject: [PATCH 6/7] typo --- changelogs/unreleased/fix-pkgresources-import.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/unreleased/fix-pkgresources-import.yml b/changelogs/unreleased/fix-pkgresources-import.yml index a33648334d..be4b9e3f03 100644 --- a/changelogs/unreleased/fix-pkgresources-import.yml +++ b/changelogs/unreleased/fix-pkgresources-import.yml @@ -2,7 +2,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.yml`, you may now drop the constraint" + 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 From e2688fda67330bc08e48a7c33033d5943a3786fe Mon Sep 17 00:00:00 2001 From: Sander Van Balen Date: Thu, 18 Jul 2024 13:49:15 +0200 Subject: [PATCH 7/7] applied additional fix --- src/inmanta/env.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/inmanta/env.py b/src/inmanta/env.py index 6f07cf3a96..ccf05261b5 100644 --- a/src/inmanta/env.py +++ b/src/inmanta/env.py @@ -999,6 +999,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( @@ -1094,6 +1096,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() )