tgzr.package_management 0.0.4__tar.gz → 0.100__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tgzr.package_management
3
- Version: 0.0.4
3
+ Version: 0.100
4
4
  Summary: tgzr package_management engine
5
5
  Project-URL: Documentation, https://github.com/open-tgzr/tgzr.package_management#readme
6
6
  Project-URL: Issues, https://github.com/open-tgzr/tgzr.package_management/issues
@@ -17,7 +17,9 @@ Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Programming Language :: Python :: Implementation :: CPython
19
19
  Classifier: Programming Language :: Python :: Implementation :: PyPy
20
+ Requires-Python: >=3.9
20
21
  Requires-Dist: hatch
22
+ Requires-Dist: importlib-metadata
21
23
  Requires-Dist: uv
22
24
  Description-Content-Type: text/markdown
23
25
 
@@ -7,6 +7,7 @@ name = "tgzr.package_management"
7
7
  dynamic = ["version"]
8
8
  description = 'tgzr package_management engine'
9
9
  readme = "README.md"
10
+ requires-python = ">=3.9"
10
11
  license = "GPL-3.0-or-later"
11
12
  keywords = []
12
13
  authors = [
@@ -27,6 +28,7 @@ classifiers = [
27
28
  dependencies = [
28
29
  "uv",
29
30
  "hatch",
31
+ "importlib-metadata", # needed to support modern Distribution api with py3.9
30
32
  ]
31
33
 
32
34
 
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.0.4'
32
- __version_tuple__ = version_tuple = (0, 0, 4)
31
+ __version__ = version = '0.100'
32
+ __version_tuple__ = version_tuple = (0, 100)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  import os
2
4
  import platform
3
5
  from pathlib import Path
@@ -11,10 +11,12 @@ from typing import (
11
11
  )
12
12
 
13
13
  import sys
14
- import importlib.metadata
14
+ import importlib_metadata
15
15
  import inspect
16
16
  import logging
17
17
 
18
+ import rich
19
+
18
20
  T = TypeVar("T", bound="Plugin")
19
21
 
20
22
  logger = logging.getLogger(__name__)
@@ -41,7 +43,7 @@ class Plugin:
41
43
  def plugin_id(cls) -> str:
42
44
  return f"{cls.plugin_type_name()}@{cls.plugin_name()}"
43
45
 
44
- def __init__(self, ep: importlib.metadata.EntryPoint):
46
+ def __init__(self, ep: importlib_metadata.EntryPoint):
45
47
  super().__init__()
46
48
  self._entry_point = ep
47
49
 
@@ -65,12 +67,12 @@ class PluginManager(Generic[PluginType]):
65
67
  return get_args(cls.__orig_bases__[0])[0] # type: ignore __orig_bases__ trust me bro.
66
68
 
67
69
  def __init__(self):
68
- self._broken: list[tuple[importlib.metadata.EntryPoint, Exception]] = []
70
+ self._broken: list[tuple[importlib_metadata.EntryPoint, Exception]] = []
69
71
  self._loaded: list[PluginType] = []
70
72
  self._needs_loading: bool = True
71
73
 
72
74
  def _instantiate_plugin_type(
73
- self, PluginType: Type[PluginType], entry_point: importlib.metadata.EntryPoint
75
+ self, PluginType: Type[PluginType], entry_point: importlib_metadata.EntryPoint
74
76
  ) -> PluginType:
75
77
  """
76
78
  Subclasses will want to override this if the managed plugin type needs
@@ -86,7 +88,7 @@ class PluginManager(Generic[PluginType]):
86
88
  | Callable[[], PluginType | list[PluginType]]
87
89
  | Iterable[PluginType]
88
90
  ),
89
- entry_point: importlib.metadata.EntryPoint,
91
+ entry_point: importlib_metadata.EntryPoint,
90
92
  ) -> list[PluginType]:
91
93
  # print("Resolving shell app plugins:", loaded)
92
94
  ManagedPluginType = self.__class__.managed_plugin_type()
@@ -104,7 +106,7 @@ class PluginManager(Generic[PluginType]):
104
106
  try:
105
107
  plugin_or_list_of_plugins = loaded() # type: ignore
106
108
  except Exception as err:
107
- ValueError(
109
+ raise ValueError(
108
110
  f"Error while executing callable entry point value (ep={entry_point}): {err}"
109
111
  )
110
112
  return self._resolve_plugins(
@@ -122,10 +124,7 @@ class PluginManager(Generic[PluginType]):
122
124
  )
123
125
 
124
126
  def _load_plugins(self):
125
- if sys.version_info[:2] == (3, 9):
126
- all_entry_points = importlib.metadata.entry_points().get(self.EP_GROUP, [])
127
- else:
128
- all_entry_points = importlib.metadata.entry_points(group=self.EP_GROUP)
127
+ all_entry_points = importlib_metadata.entry_points(group=self.EP_GROUP)
129
128
 
130
129
  self._broken.clear()
131
130
  self._loaded.clear()
@@ -135,11 +134,13 @@ class PluginManager(Generic[PluginType]):
135
134
  try:
136
135
  loaded = ep.load()
137
136
  except Exception as err:
137
+ raise # TMP DEE
138
138
  self._broken.append((ep, err))
139
139
  else:
140
140
  try:
141
141
  plugins = self._resolve_plugins(loaded, ep)
142
142
  except Exception as err:
143
+ raise # TMP DEE
143
144
  self._broken.append((ep, err))
144
145
  else:
145
146
  for plugin in plugins:
@@ -149,7 +150,7 @@ class PluginManager(Generic[PluginType]):
149
150
 
150
151
  def get_broken_plugins(
151
152
  self, force_reload: bool = False
152
- ) -> list[tuple[importlib.metadata.EntryPoint, Exception]]:
153
+ ) -> list[tuple[importlib_metadata.EntryPoint, Exception]]:
153
154
  if force_reload or self._needs_loading:
154
155
  self._load_plugins()
155
156
  return self._broken
@@ -1,5 +1,7 @@
1
+ from __future__ import annotations
2
+
1
3
  from pathlib import Path
2
- import importlib.metadata
4
+ import importlib_metadata
3
5
  import platform
4
6
  import json
5
7
  import os
@@ -156,11 +158,11 @@ class Venv:
156
158
  def get_cmd_names(self) -> list[str]:
157
159
  raise NotImplementedError()
158
160
 
159
- def get_package(self, package_name: str) -> importlib.metadata.Distribution | None:
161
+ def get_package(self, package_name: str) -> importlib_metadata.Distribution | None:
160
162
  if self.site_packages_path is None:
161
163
  return None
162
164
  distributions = list(
163
- importlib.metadata.distributions(
165
+ importlib_metadata.distributions(
164
166
  name=package_name, path=[str(self.site_packages_path)]
165
167
  )
166
168
  )
@@ -173,10 +175,10 @@ class Venv:
173
175
 
174
176
  def get_packages(
175
177
  self, name_filters: list[str] | None = None
176
- ) -> list[importlib.metadata.Distribution]:
178
+ ) -> list[importlib_metadata.Distribution]:
177
179
  if self.site_packages_path is None:
178
180
  return []
179
- distributions = importlib.metadata.distributions(
181
+ distributions = importlib_metadata.distributions(
180
182
  path=[str(self.site_packages_path)]
181
183
  )
182
184
  ret = []
@@ -215,10 +217,10 @@ class Venv:
215
217
 
216
218
  def get_plugins(
217
219
  self, group_filter: str | None
218
- ) -> list[tuple[importlib.metadata.EntryPoint, importlib.metadata.Distribution]]:
220
+ ) -> list[tuple[importlib_metadata.EntryPoint, importlib_metadata.Distribution]]:
219
221
  if self.site_packages_path is None:
220
222
  return []
221
- distributions = importlib.metadata.distributions(
223
+ distributions = importlib_metadata.distributions(
222
224
  path=[str(self.site_packages_path)]
223
225
  )
224
226
  plugins = []
@@ -230,7 +232,7 @@ class Venv:
230
232
 
231
233
  def get_plugins_slow(
232
234
  self, group_filter: str | None
233
- ) -> list[importlib.metadata.EntryPoint]:
235
+ ) -> list[importlib_metadata.EntryPoint]:
234
236
  cmd_args = ["studio", "plugins-here", "--format", "json"]
235
237
  if group_filter:
236
238
  cmd_args.extend(["--group-filter", group_filter])
@@ -243,7 +245,7 @@ class Venv:
243
245
  ret = []
244
246
  for entry in data:
245
247
  # print(entry)
246
- ep = importlib.metadata.EntryPoint(
248
+ ep = importlib_metadata.EntryPoint(
247
249
  entry["name"], entry["value"], entry["group"]
248
250
  )
249
251
  ret.append(ep)