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

Issue/drop pkg resources - first part #7990

Closed
wants to merge 89 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
37ee4b1
first commit
hlloreda Jul 31, 2024
7d333fe
Merge branch 'refs/heads/master' into issue/drop_pkg_resources
hlloreda Jul 31, 2024
021e009
wip
hlloreda Jul 31, 2024
1779105
mypy
hlloreda Jul 31, 2024
25893db
Merge branch 'refs/heads/master' into issue/drop_pkg_resources
hlloreda Aug 1, 2024
871e18d
refactor
hlloreda Aug 2, 2024
3a5743a
lower name
hlloreda Aug 8, 2024
a6a6dde
test
hlloreda Aug 9, 2024
c49b37e
Merge branch 'refs/heads/master' into issue/drop_pkg_resources
hlloreda Aug 9, 2024
a32e383
refactor
hlloreda Aug 9, 2024
3ea487c
Merge branch 'master' into issue/drop_pkg_resources
hlloreda Aug 19, 2024
3377996
rollback changes
hlloreda Aug 20, 2024
880d9da
rollback changes
hlloreda Aug 20, 2024
c5187f8
refactor
hlloreda Aug 21, 2024
a239a06
refactor
hlloreda Aug 21, 2024
06ea0cf
refactor
hlloreda Aug 21, 2024
aeb68cb
fix broken test
hlloreda Aug 21, 2024
c5d3246
Merge branch 'master' into issue/drop_pkg_resources_2
hlloreda Aug 29, 2024
87e381a
refactor
hlloreda Aug 29, 2024
ae4915b
refactor
hlloreda Aug 29, 2024
4b8e2ad
Merge branch 'master' into issue/drop_pkg_resources_2
hlloreda Aug 29, 2024
0768b2b
refactor
hlloreda Aug 29, 2024
8d71c66
add test safe requirement
hlloreda Aug 29, 2024
f884732
Remove SafeRequirement
hlloreda Aug 29, 2024
e523023
Remove SafeRequirement
hlloreda Aug 29, 2024
b0f0d8b
renaming
hlloreda Aug 29, 2024
b797205
Remove SafeRequirement
hlloreda Aug 29, 2024
259626f
fix parsing
hlloreda Aug 29, 2024
26420b2
fix name parameter
hlloreda Aug 30, 2024
b443555
refactor
hlloreda Aug 30, 2024
9a44a24
Merge branch 'master' into issue/drop_pkg_resources_2
hlloreda Aug 30, 2024
fca2bfc
format mypy
hlloreda Aug 30, 2024
db0591c
fix comparing versions
hlloreda Sep 2, 2024
10b41bd
refactor + fix broken calls
hlloreda Sep 2, 2024
0c8d292
rollback + fix broken tests
hlloreda Sep 2, 2024
7962876
refactor
hlloreda Sep 2, 2024
f902c99
fix broken tests
hlloreda Sep 2, 2024
00c5506
refactor
hlloreda Sep 6, 2024
d65b1c0
Merge branch 'refs/heads/master' into issue/drop_pkg_resources_2
hlloreda Sep 16, 2024
e6975c5
merge master + introduce new type
hlloreda Sep 16, 2024
c8ec877
fix broken tests
hlloreda Sep 16, 2024
43a64c0
fix broken tests
hlloreda Sep 16, 2024
917f9ef
add warnings + use new name property
hlloreda Sep 16, 2024
1c43dc7
fix + mypy
hlloreda Sep 16, 2024
1dce986
refactor
hlloreda Sep 16, 2024
d241433
retake with plugins
hlloreda Sep 16, 2024
3a64bed
Merge branch 'master' into issue/drop_pkg_resources_2
hlloreda Sep 17, 2024
8a88093
rollback old changes
hlloreda Sep 17, 2024
a046cf8
add missing test
hlloreda Sep 17, 2024
1896d2e
missing <
hlloreda Sep 17, 2024
22e4d1d
wrong number
hlloreda Sep 17, 2024
0c3ab6e
resolve mypy problems
hlloreda Sep 17, 2024
4f13c5d
refactor
hlloreda Sep 17, 2024
8e15960
more cases
hlloreda Sep 17, 2024
d8d03ac
refactor
hlloreda Sep 18, 2024
cc46563
refactor wrong type
hlloreda Sep 18, 2024
5fd461a
mypy-sync
hlloreda Sep 18, 2024
9037100
refactor
hlloreda Sep 18, 2024
d34ba90
Merge branch 'master' into issue/drop_pkg_resources_2
hlloreda Sep 18, 2024
84270ae
fix broken tests
hlloreda Sep 18, 2024
6134daa
refactor
hlloreda Sep 18, 2024
45ef63f
refactor
hlloreda Sep 18, 2024
ab6f098
refactor
hlloreda Sep 18, 2024
4fb8902
regex broke tests
hlloreda Sep 18, 2024
784e533
remove old regex
hlloreda Sep 18, 2024
c750b49
incomplete refactor
hlloreda Sep 18, 2024
0993635
refactor
hlloreda Sep 18, 2024
cd11875
refactor
hlloreda Sep 18, 2024
c40fe2b
fix
hlloreda Sep 19, 2024
63f0a5f
refactor
hlloreda Sep 19, 2024
8facdcf
docstring
hlloreda Sep 19, 2024
bc43a12
refactor
hlloreda Sep 19, 2024
ccab505
add changelog
hlloreda Sep 20, 2024
254c14e
Merge branch 'master' into issue/drop_pkg_resources_2
hlloreda Sep 20, 2024
d86a63f
Merge branch 'master' into issue/drop_pkg_resources_2
hlloreda Sep 23, 2024
ae80eb8
refactor
hlloreda Sep 23, 2024
2d7bda9
Merge branch 'master' into issue/drop_pkg_resources_2
hlloreda Sep 24, 2024
ba749a6
fix broken tests
hlloreda Sep 24, 2024
6aae7ae
revert change
hlloreda Sep 25, 2024
ba01c4d
rollback
hlloreda Sep 30, 2024
b12c5d2
Merge branch 'master' into issue/drop_pkg_resources_2
hlloreda Sep 30, 2024
24692f8
refactor
hlloreda Sep 30, 2024
dc95c99
refactor
hlloreda Sep 30, 2024
3e71ebf
refactor to make sure to not share this instance
hlloreda Sep 30, 2024
2d79e9e
Merge branch 'master' into issue/drop_pkg_resources_2
hlloreda Oct 1, 2024
d77a95d
refactor
hlloreda Oct 2, 2024
af785c4
remove constraint on setuptools
hlloreda Oct 2, 2024
8e4ae57
missing revert changes
hlloreda Oct 2, 2024
73d9cf3
missing revert changes
hlloreda Oct 2, 2024
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
3 changes: 0 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ updates:
# Allow both direct and indirect updates for all packages
- dependency-type: "all"
ignore:
# #6668
- dependency-name: "setuptools"
update-types: ["version-update:semver-major"]
- dependency-name: "pytest-inmanta-extensions"
versions: [">=0.0.1"]
- dependency-name: "pydantic"
Expand Down
4 changes: 4 additions & 0 deletions changelogs/unreleased/drop-pkg-resources-first-part.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
description: First part of `pkg_resources` library deprecation.
change-type: patch
destination-branches: [master, iso7]
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# serve to show the default.
import importlib.metadata
import shutil
import sys, os, pkg_resources, datetime
import sys, os, datetime
from importlib.metadata import PackageNotFoundError
from sphinx.errors import ConfigError

Expand Down
14 changes: 1 addition & 13 deletions mypy-baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -893,13 +893,8 @@ src/inmanta/execute/scheduler.py:0: error: Missing type parameters for generic t
src/inmanta/execute/scheduler.py:0: error: "<subclass of "DelayedResultVariable" and "RelationAttributeVariable">" has no attribute "attribute" [attr-defined]
src/inmanta/execute/scheduler.py:0: error: "<subclass of "DelayedResultVariable" and "RelationAttributeVariable">" has no attribute "attribute" [attr-defined]
src/inmanta/execute/scheduler.py:0: error: "<subclass of "DelayedResultVariable" and "RelationAttributeVariable">" has no attribute "attribute" [attr-defined]
src/inmanta/env.py:0: error: Argument 1 to "parse_requirements" has incompatible type "Sequence[CanonicalRequirement]"; expected "Sequence[str]" [arg-type]
sanderr marked this conversation as resolved.
Show resolved Hide resolved
src/inmanta/env.py:0: error: "type[WorkingSet]" has no attribute "_build_master" [attr-defined]
src/inmanta/env.py:0: error: Incompatible types in assignment (expression has type "WorkingSet", variable has type "Iterable[DistInfoDistribution]") [assignment]
src/inmanta/env.py:0: note: Following member(s) of "WorkingSet" have conflicts:
src/inmanta/env.py:0: note: Expected:
src/inmanta/env.py:0: note: def __iter__(self) -> Iterator[DistInfoDistribution]
src/inmanta/env.py:0: note: Got:
src/inmanta/env.py:0: note: def __iter__(self) -> Iterator[Distribution]
src/inmanta/env.py:0: error: Incompatible return value type (got "tuple[str | None, Loader | None] | None", expected "tuple[str | None, Loader] | None") [return-value]
src/inmanta/env.py:0: error: Item "None" of "ModuleSpec | None" has no attribute "submodule_search_locations" [union-attr]
src/inmanta/env.py:0: error: Item "None" of "ModuleSpec | None" has no attribute "submodule_search_locations" [union-attr]
Expand All @@ -910,7 +905,6 @@ src/inmanta/compiler/__init__.py:0: error: Incompatible types in assignment (exp
src/inmanta/compiler/__init__.py:0: error: Incompatible types in assignment (expression has type "Namespace | None", variable has type "Namespace") [assignment]
src/inmanta/compiler/__init__.py:0: error: Missing type parameters for generic type "ResultVariable" [type-arg]
src/inmanta/module.py:0: error: Missing type parameters for generic type Module [type-arg]
src/inmanta/module.py:0: error: Incompatible return value type (got "SpecifierSet", expected "str") [return-value]
src/inmanta/module.py:0: error: Returning Any from function declared to return "Mapping[str, object]" [no-any-return]
src/inmanta/module.py:0: error: Argument 1 to "Metadata" has incompatible type "**Mapping[str, object]"; expected "str" [arg-type]
src/inmanta/module.py:0: error: Argument 1 to "Metadata" has incompatible type "**Mapping[str, object]"; expected "str | None" [arg-type]
Expand All @@ -927,18 +921,12 @@ src/inmanta/module.py:0: error: Missing type parameters for generic type Module
src/inmanta/module.py:0: error: Missing type parameters for generic type Module [type-arg]
src/inmanta/module.py:0: error: Missing type parameters for generic type Module [type-arg]
src/inmanta/module.py:0: error: Missing type parameters for generic type Module [type-arg]
src/inmanta/module.py:0: error: Unsupported operand types for in ("Version" and "InmantaModuleRequirement") [operator]
src/inmanta/module.py:0: error: Missing type parameters for generic type Module [type-arg]
src/inmanta/module.py:0: error: Missing type parameters for generic type Module [type-arg]
src/inmanta/module.py:0: error: Missing type parameters for generic type Module [type-arg]
src/inmanta/module.py:0: error: Missing type parameters for generic type Module [type-arg]
src/inmanta/module.py:0: error: Missing type parameters for generic type Module [type-arg]
src/inmanta/module.py:0: error: Missing type parameters for generic type Module [type-arg]
src/inmanta/module.py:0: error: Incompatible return value type (got "pkg_resources._vendored_packaging.version.Version", expected "packaging.version.Version | None") [return-value]
src/inmanta/module.py:0: error: "str" has no attribute "filter" [attr-defined]
src/inmanta/module.py:0: error: Argument 4 to "__best_for_compiler_version" of "ModuleV1" has incompatible type "pkg_resources._vendored_packaging.version.Version"; expected "packaging.version.Version" [arg-type]
src/inmanta/module.py:0: error: Incompatible return value type (got "pkg_resources._vendored_packaging.version.Version", expected "packaging.version.Version | None") [return-value]
src/inmanta/module.py:0: error: Incompatible return value type (got "pkg_resources._vendored_packaging.version.Version", expected "packaging.version.Version | None") [return-value]
src/inmanta/moduletool.py:0: error: Skipping analyzing "cookiecutter.main": module is installed, but missing library stubs or py.typed marker [import-untyped]
src/inmanta/moduletool.py:0: error: Missing type parameters for generic type "ModuleLike" [type-arg]
src/inmanta/moduletool.py:0: error: Missing type parameters for generic type Module [type-arg]
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"logfire~=0.46",
"more-itertools>=8,<11",
"opentelemetry-instrumentation-asyncpg~=0.46b0",
# leave upper bound floating for fast-moving and extremely stable packaging
"packaging>=21.3",
# upper bound on packaging because we use a non-public API that might change in any (non-SemVer) version
"packaging>=21.3,<24.2",
# pip>=21.3 required for editable pyproject.toml + setup.cfg based install support
"pip>=21.3",
"ply~=3.0",
Expand All @@ -29,7 +29,7 @@
"pynacl~=1.5",
"python-dateutil~=2.0",
"pyyaml~=6.0",
"setuptools<71",
"setuptools",
"texttable~=1.0",
"tornado~=6.0",
# lower bound because of ilevkivskyi/typing_inspect#100
Expand Down
5 changes: 2 additions & 3 deletions src/inmanta/agent/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@
from dataclasses import dataclass
from typing import Any, Dict, Optional, Sequence, cast

import pkg_resources

import inmanta.types
import inmanta.util
import packaging.requirements
from inmanta import const
from inmanta.agent import config as cfg
from inmanta.agent import resourcepool
Expand Down Expand Up @@ -300,7 +299,7 @@ async def create_and_install_environment(self, blueprint: EnvBlueprint) -> None:
await asyncio.get_running_loop().run_in_executor(self.io_threadpool, self.init_env)
if len(req): # install_for_config expects at least 1 requirement or a path to install
await self.async_install_for_config(
requirements=list(pkg_resources.parse_requirements(req)),
requirements=[packaging.requirements.Requirement(requirement_string=e) for e in req],
config=blueprint.pip_config,
)

Expand Down
4 changes: 1 addition & 3 deletions src/inmanta/agent/in_process_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
from concurrent.futures.thread import ThreadPoolExecutor
from typing import Any, Optional

import pkg_resources

import inmanta.agent.cache
import inmanta.protocol
import inmanta.util
Expand Down Expand Up @@ -603,7 +601,7 @@ async def _install(self, blueprint: executor.ExecutorBlueprint) -> None:
await loop.run_in_executor(
self.thread_pool,
self._env.install_for_config,
list(pkg_resources.parse_requirements(blueprint.requirements)),
inmanta.util.parse_requirements(blueprint.requirements),
blueprint.pip_config,
)
await loop.run_in_executor(self.thread_pool, self._loader.deploy_version, blueprint.sources)
Loading