Skip to content

Commit 2743e8a

Browse files
author
PyCompiler ARK++
committed
ajout du system de valiation de versionning pour tout les sys du logicel: bcasl Core les sdks
1 parent 1b656fe commit 2743e8a

22 files changed

Lines changed: 2984 additions & 50 deletions

Core/allversion.py

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# Copyright 2025 Ague Samuel Amen
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
"""
17+
All Versions Module - Centralized version tracking for PyCompiler ARK++
18+
19+
This module provides utilities to capture and retrieve version information
20+
for the core application and all SDKs/engines.
21+
"""
22+
23+
from __future__ import annotations
24+
25+
from typing import Dict
26+
27+
28+
class VersionInfo:
29+
"""Container for version information of a component."""
30+
31+
def __init__(self, name: str, version: str, component_type: str = "unknown"):
32+
"""
33+
Initialize version information.
34+
35+
Args:
36+
name: Component name
37+
version: Version string (e.g., "1.0.0")
38+
component_type: Type of component (core, sdk, engine, plugin)
39+
"""
40+
self.name = name
41+
self.version = version
42+
self.component_type = component_type
43+
44+
def __repr__(self) -> str:
45+
return f"VersionInfo(name={self.name!r}, version={self.version!r}, type={self.component_type!r})"
46+
47+
def __str__(self) -> str:
48+
return f"{self.name} v{self.version}"
49+
50+
def to_dict(self) -> Dict[str, str]:
51+
"""Convert to dictionary representation."""
52+
return {
53+
"name": self.name,
54+
"version": self.version,
55+
"type": self.component_type,
56+
}
57+
58+
59+
def get_core_version() -> str:
60+
"""Get the version of the PyCompiler ARK++ Core."""
61+
try:
62+
from . import __version__
63+
64+
return __version__
65+
except (ImportError, AttributeError):
66+
return "unknown"
67+
68+
69+
def get_engine_sdk_version() -> str:
70+
"""Get the version of the Engine SDK."""
71+
try:
72+
import engine_sdk
73+
74+
return engine_sdk.__version__
75+
except (ImportError, AttributeError):
76+
return "unknown"
77+
78+
79+
def get_bcasl_version() -> str:
80+
"""Get the version of the BCASL (Before-Compilation Actions System Loader)."""
81+
try:
82+
import bcasl
83+
84+
return bcasl.__version__
85+
except (ImportError, AttributeError):
86+
return "unknown"
87+
88+
89+
def get_plugins_sdk_version() -> str:
90+
"""Get the version of the Plugins SDK."""
91+
try:
92+
from Plugins_SDK import __version__
93+
94+
return __version__
95+
except (ImportError, AttributeError):
96+
return "unknown"
97+
98+
99+
def get_bc_plugin_context_version() -> str:
100+
"""Get the version of the BcPluginContext."""
101+
try:
102+
from Plugins_SDK.BcPluginContext import __version__
103+
104+
return __version__
105+
except (ImportError, AttributeError):
106+
return "unknown"
107+
108+
109+
def get_general_context_version() -> str:
110+
"""Get the version of the GeneralContext."""
111+
try:
112+
from Plugins_SDK.GeneralContext import __version__
113+
114+
return __version__
115+
except (ImportError, AttributeError):
116+
return "unknown"
117+
118+
119+
def get_system_version() -> str:
120+
"""Get the system information (Python version and platform)."""
121+
import sys
122+
import platform
123+
124+
python_version = f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"
125+
system_info = f"{platform.system()} {platform.release()}"
126+
return f"Python {python_version} on {system_info}"
127+
128+
129+
def get_all_versions() -> Dict[str, VersionInfo]:
130+
"""
131+
Get all version information for the application, SDKs and system.
132+
133+
Returns:
134+
Dictionary mapping component names to VersionInfo objects
135+
"""
136+
versions = {}
137+
138+
# Core
139+
core_version = get_core_version()
140+
versions["core"] = VersionInfo("PyCompiler ARK++ Core", core_version, "core")
141+
142+
# SDKs
143+
engine_sdk_version = get_engine_sdk_version()
144+
versions["engine_sdk"] = VersionInfo("Engine SDK", engine_sdk_version, "sdk")
145+
146+
bcasl_version = get_bcasl_version()
147+
versions["bcasl"] = VersionInfo("BCASL", bcasl_version, "sdk")
148+
149+
plugins_sdk_version = get_plugins_sdk_version()
150+
versions["plugins_sdk"] = VersionInfo("Plugins SDK", plugins_sdk_version, "sdk")
151+
152+
bc_plugin_context_version = get_bc_plugin_context_version()
153+
versions["bc_plugin_context"] = VersionInfo(
154+
"BcPluginContext", bc_plugin_context_version, "sdk"
155+
)
156+
157+
general_context_version = get_general_context_version()
158+
versions["general_context"] = VersionInfo(
159+
"GeneralContext", general_context_version, "sdk"
160+
)
161+
162+
# System
163+
system_version = get_system_version()
164+
versions["system"] = VersionInfo("System", system_version, "system")
165+
166+
return versions
167+
168+
169+
def get_versions_dict() -> Dict[str, str]:
170+
"""
171+
Get all versions as a simple dictionary mapping names to version strings.
172+
173+
Returns:
174+
Dictionary mapping component names to version strings
175+
"""
176+
versions = get_all_versions()
177+
return {name: info.version for name, info in versions.items()}
178+
179+
180+
def print_all_versions() -> None:
181+
"""Print all version information to stdout."""
182+
versions = get_all_versions()
183+
print("=" * 60)
184+
print("PyCompiler ARK++ - Version Information")
185+
print("=" * 60)
186+
187+
# Group by type
188+
by_type = {}
189+
for name, info in versions.items():
190+
if info.component_type not in by_type:
191+
by_type[info.component_type] = []
192+
by_type[info.component_type].append((name, info))
193+
194+
for component_type in ["core", "sdk", "system"]:
195+
if component_type in by_type:
196+
print(f"\n{component_type.upper()}:")
197+
for name, info in by_type[component_type]:
198+
print(f" {info.name:.<40} {info.version}")
199+
200+
print("\n" + "=" * 60)
201+
202+
203+
def get_version_string() -> str:
204+
"""
205+
Get a formatted version string for all components.
206+
207+
Returns:
208+
Formatted string with all version information
209+
"""
210+
versions = get_all_versions()
211+
lines = ["PyCompiler ARK++ Version Information:"]
212+
213+
for name, info in versions.items():
214+
lines.append(f" {info.name}: {info.version}")
215+
216+
return "\n".join(lines)
217+
218+
219+
__all__ = [
220+
"VersionInfo",
221+
"get_core_version",
222+
"get_engine_sdk_version",
223+
"get_bcasl_version",
224+
"get_plugins_sdk_version",
225+
"get_bc_plugin_context_version",
226+
"get_general_context_version",
227+
"get_system_version",
228+
"get_all_versions",
229+
"get_versions_dict",
230+
"print_all_versions",
231+
"get_version_string",
232+
]

0 commit comments

Comments
 (0)