ruyi 0.42.0a20251013__py3-none-any.whl → 0.42.0b20251014__py3-none-any.whl

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.
ruyi/ruyipkg/profile.py CHANGED
@@ -1,7 +1,21 @@
1
1
  from os import PathLike
2
- from typing import Any, Iterable, TypeGuard, cast
2
+ from typing import (
3
+ Any,
4
+ Iterable,
5
+ Mapping,
6
+ Protocol,
7
+ Sequence,
8
+ TypedDict,
9
+ TypeGuard,
10
+ TYPE_CHECKING,
11
+ cast,
12
+ )
13
+
14
+ if TYPE_CHECKING:
15
+ from typing_extensions import NotRequired
3
16
 
4
17
  from ..pluginhost.ctx import PluginHostContext, SupportsEvalFunction
18
+ from .entity_provider import BaseEntityProvider
5
19
  from .pkg_manifest import EmulatorFlavor
6
20
 
7
21
 
@@ -206,3 +220,136 @@ class ProfileProxy:
206
220
  sysroot: PathLike[Any] | None,
207
221
  ) -> dict[str, str] | None:
208
222
  return self._provider.get_env_config_for_emu_flavor(self._id, flavor, sysroot)
223
+
224
+
225
+ #
226
+ # Protocols
227
+ #
228
+
229
+
230
+ # MetadataRepo is defined in repo.py, but we don't want to import repo.py here
231
+ # to avoid circular import. Instead, we just describe the methods and properties
232
+ # that we need from MetadataRepo with a Protocol.
233
+ class ProvidesProfiles(Protocol):
234
+ def get_supported_arches(self) -> list[str]: ...
235
+ def get_profile_for_arch(self, arch: str, name: str) -> ProfileProxy | None: ...
236
+ def iter_profiles_for_arch(self, arch: str) -> Iterable[ProfileProxy]: ...
237
+
238
+
239
+ #
240
+ # Entity type and schema for profile entities
241
+ #
242
+
243
+ PROFILE_V1_ENTITY_TYPE = "profile-v1"
244
+ PROFILE_V1_ENTITY_TYPE_SCHEMA = {
245
+ "$schema": "http://json-schema.org/draft-07/schema#",
246
+ "required": ["profile-v1"],
247
+ "properties": {
248
+ "profile-v1": {
249
+ "type": "object",
250
+ "properties": {
251
+ "id": {"type": "string"},
252
+ "display_name": {"type": "string"},
253
+ "name": {"type": "string"},
254
+ "arch": {"type": "string"},
255
+ "needed_toolchain_quirks": {
256
+ "type": "array",
257
+ "items": {"type": "string"},
258
+ },
259
+ "toolchain_common_flags_str": {"type": "string"},
260
+ },
261
+ "required": [
262
+ "id",
263
+ "display_name",
264
+ "name",
265
+ "arch",
266
+ "needed_toolchain_quirks",
267
+ "toolchain_common_flags_str",
268
+ ],
269
+ },
270
+ "related": {
271
+ "type": "array",
272
+ "description": "List of related entity references",
273
+ "items": {"type": "string", "pattern": "^.+:.+"},
274
+ },
275
+ "unique_among_type_during_traversal": {
276
+ "type": "boolean",
277
+ "description": "Whether this entity should be unique among all entities of the same type during traversal",
278
+ },
279
+ },
280
+ }
281
+
282
+
283
+ class ProfileV1EntityData(TypedDict):
284
+ id: str
285
+ display_name: str
286
+ name: str
287
+ arch: str
288
+ needed_toolchain_quirks: list[str]
289
+ toolchain_common_flags_str: str
290
+
291
+
292
+ ProfileV1Entity = TypedDict(
293
+ "ProfileV1Entity",
294
+ {
295
+ "profile-v1": ProfileV1EntityData,
296
+ "related": "NotRequired[list[str]]",
297
+ "unique_among_type_during_traversal": "NotRequired[bool]",
298
+ },
299
+ total=False,
300
+ )
301
+
302
+
303
+ class ProfileEntityProvider(BaseEntityProvider):
304
+ def __init__(self, provider: ProvidesProfiles) -> None:
305
+ super().__init__()
306
+ self._provider = provider
307
+
308
+ def discover_schemas(self) -> dict[str, object]:
309
+ return {
310
+ PROFILE_V1_ENTITY_TYPE: PROFILE_V1_ENTITY_TYPE_SCHEMA,
311
+ }
312
+
313
+ def load_entities(
314
+ self,
315
+ entity_types: Sequence[str],
316
+ ) -> Mapping[str, Mapping[str, Mapping[str, Any]]]:
317
+ result: dict[str, Mapping[str, Mapping[str, Any]]] = {}
318
+ for ty in entity_types:
319
+ if ty == PROFILE_V1_ENTITY_TYPE:
320
+ result[ty] = _load_profile_v1_entities(self._provider)
321
+ return result
322
+
323
+
324
+ def _load_profile_v1_entities(provider: ProvidesProfiles) -> dict[str, ProfileV1Entity]:
325
+ result: dict[str, ProfileV1Entity] = {}
326
+ for arch in provider.get_supported_arches():
327
+ result.update(_load_profile_v1_entities_for_arch(provider, arch))
328
+ return result
329
+
330
+
331
+ def _load_profile_v1_entities_for_arch(
332
+ provider: ProvidesProfiles,
333
+ arch: str,
334
+ ) -> dict[str, ProfileV1Entity]:
335
+ result: dict[str, ProfileV1Entity] = {}
336
+ for profile in provider.iter_profiles_for_arch(arch):
337
+ full_name = profile.id
338
+ relations = [f"arch:{arch}"]
339
+
340
+ needed_toolchain_quirks = sorted(profile.need_quirks)
341
+
342
+ result[profile.id] = {
343
+ "profile-v1": {
344
+ "id": profile.id,
345
+ "display_name": full_name,
346
+ "name": profile.id,
347
+ "arch": profile.arch,
348
+ "needed_toolchain_quirks": needed_toolchain_quirks,
349
+ "toolchain_common_flags_str": profile.get_common_flags(
350
+ needed_toolchain_quirks,
351
+ ),
352
+ },
353
+ "related": relations,
354
+ }
355
+ return result
ruyi/ruyipkg/repo.py CHANGED
@@ -34,7 +34,7 @@ from .pkg_manifest import (
34
34
  InputPackageManifestType,
35
35
  is_prerelease,
36
36
  )
37
- from .profile import PluginProfileProvider, ProfileProxy
37
+ from .profile import PluginProfileProvider, ProfileEntityProvider, ProfileProxy
38
38
  from .protocols import ProvidesPackageManifests
39
39
 
40
40
  if sys.version_info >= (3, 11):
@@ -234,6 +234,7 @@ class MetadataRepo(ProvidesPackageManifests):
234
234
  gc.logger,
235
235
  FSEntityProvider(gc.logger, pathlib.Path(self.root) / "entities"),
236
236
  MetadataRepoEntityProvider(self),
237
+ ProfileEntityProvider(self),
237
238
  )
238
239
  self._plugin_host_ctx = PluginHostContext.new(gc.logger, self.plugin_root)
239
240
  self._plugin_fn_evaluator = self._plugin_host_ctx.make_evaluator()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ruyi
3
- Version: 0.42.0a20251013
3
+ Version: 0.42.0b20251014
4
4
  Summary: Package manager for RuyiSDK
5
5
  License: Apache License
6
6
  Version 2.0, January 2004
@@ -61,10 +61,10 @@ ruyi/ruyipkg/news.py,sha256=5uN4UYqvEW5MU_10W9MzwFo3lH25oZCvMMjfAjLed7U,3857
61
61
  ruyi/ruyipkg/news_cli.py,sha256=s5mirEBmO2lZITfjcpzDakP7rNYPqopdM9odbwmAPpg,2378
62
62
  ruyi/ruyipkg/news_store.py,sha256=ocTO4YDpL_HrKaIRFvJ_Gxvpmr7V7-R8b1B8f5Eue9c,5276
63
63
  ruyi/ruyipkg/pkg_manifest.py,sha256=FmksKjQyBnU4zA3MFXiHdB2EjNmhs-J9km9vE-zBQlk,18836
64
- ruyi/ruyipkg/profile.py,sha256=FVppmA6x12m3JfeAWd3Vl9osk4aBprZL4ff7akO018Q,6467
64
+ ruyi/ruyipkg/profile.py,sha256=6xwL24crALShqD8bazGOIAFTYCpM_91mD8d6YMxM2FU,10762
65
65
  ruyi/ruyipkg/profile_cli.py,sha256=ud9MS9JQLOtec_1tFRu669I-imVfi1DHU3AuBJym9mw,848
66
66
  ruyi/ruyipkg/protocols.py,sha256=lPKRaAcK3DY3wmkyO2tKpFvPQ_4QA4aSNNsNLvi78O8,1833
67
- ruyi/ruyipkg/repo.py,sha256=3D_R9JjztY2IbyeQsfnrwJHNJ_Bcx3o_QZZEOk02YNo,25167
67
+ ruyi/ruyipkg/repo.py,sha256=l5d4XPZS-ofbwlAOk5GZMM7AFGay1n1xDVzge935oA4,25231
68
68
  ruyi/ruyipkg/state.py,sha256=3DRYyHvm_GOvKFVWZUV0iFVnXdK2vn6_RKBXKxFzK64,11235
69
69
  ruyi/ruyipkg/unpack.py,sha256=hPd-lOnDXp1lEb4mdbLUEckT4QXblSFxz-dGAdwaAjc,11207
70
70
  ruyi/ruyipkg/unpack_method.py,sha256=MonFFvcDb7MVsi2w4yitnCeZkmWmS7nRMMY-wSt9AMs,2106
@@ -95,8 +95,8 @@ ruyi/utils/toml.py,sha256=aniIF3SGfR69_s3GWWwlnoKxW4B5IDVY2CM0eUI55_c,3501
95
95
  ruyi/utils/url.py,sha256=Wyct6syS4GmZC6mY7SK-YgBWxKl3cOOBXtp9UtvGkto,186
96
96
  ruyi/utils/xdg_basedir.py,sha256=RwVH199jPcLVsg5ngR62RaNS5hqnMpkdt31LqkCfa1g,2751
97
97
  ruyi/version.py,sha256=KLJkvKexU07mu-GVDbYKsQvReRvwlVFYkRmcvnyfQNY,2142
98
- ruyi-0.42.0a20251013.dist-info/METADATA,sha256=S9n6IZt93cQ9AXUc1vAdp6XAgOAtFTLOkKFjMvnhhog,24282
99
- ruyi-0.42.0a20251013.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
100
- ruyi-0.42.0a20251013.dist-info/entry_points.txt,sha256=GXSNSy7OgFrnlU5xm5dE3l3PGO92Qf6VDIUCdvQNm8E,49
101
- ruyi-0.42.0a20251013.dist-info/licenses/LICENSE-Apache.txt,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
102
- ruyi-0.42.0a20251013.dist-info/RECORD,,
98
+ ruyi-0.42.0b20251014.dist-info/METADATA,sha256=9_H5mlbJ5_7CShfuYRZO37Pl4gTOPcEbNvIMCVLbMWw,24282
99
+ ruyi-0.42.0b20251014.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
100
+ ruyi-0.42.0b20251014.dist-info/entry_points.txt,sha256=GXSNSy7OgFrnlU5xm5dE3l3PGO92Qf6VDIUCdvQNm8E,49
101
+ ruyi-0.42.0b20251014.dist-info/licenses/LICENSE-Apache.txt,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
102
+ ruyi-0.42.0b20251014.dist-info/RECORD,,