exonware-xwlazy 0.1.0.11__py3-none-any.whl → 0.1.0.19__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.
Files changed (96) hide show
  1. exonware/__init__.py +22 -0
  2. exonware/xwlazy/__init__.py +0 -0
  3. exonware/xwlazy/common/__init__.py +47 -0
  4. exonware/xwlazy/common/base.py +58 -0
  5. exonware/xwlazy/common/cache.py +506 -0
  6. exonware/xwlazy/common/logger.py +268 -0
  7. exonware/xwlazy/common/services/__init__.py +72 -0
  8. exonware/xwlazy/common/services/dependency_mapper.py +234 -0
  9. exonware/xwlazy/common/services/install_async_utils.py +169 -0
  10. exonware/xwlazy/common/services/install_cache_utils.py +257 -0
  11. exonware/xwlazy/common/services/keyword_detection.py +292 -0
  12. exonware/xwlazy/common/services/spec_cache.py +173 -0
  13. exonware/xwlazy/common/strategies/__init__.py +28 -0
  14. exonware/xwlazy/common/strategies/caching_dict.py +45 -0
  15. exonware/xwlazy/common/strategies/caching_installation.py +89 -0
  16. exonware/xwlazy/common/strategies/caching_lfu.py +67 -0
  17. exonware/xwlazy/common/strategies/caching_lru.py +64 -0
  18. exonware/xwlazy/common/strategies/caching_multitier.py +60 -0
  19. exonware/xwlazy/common/strategies/caching_ttl.py +60 -0
  20. {xwlazy/lazy → exonware/xwlazy}/config.py +52 -20
  21. exonware/xwlazy/contracts.py +1410 -0
  22. exonware/xwlazy/defs.py +397 -0
  23. xwlazy/lazy/lazy_errors.py → exonware/xwlazy/errors.py +21 -8
  24. exonware/xwlazy/facade.py +1049 -0
  25. exonware/xwlazy/module/__init__.py +18 -0
  26. exonware/xwlazy/module/base.py +569 -0
  27. exonware/xwlazy/module/data.py +17 -0
  28. exonware/xwlazy/module/facade.py +247 -0
  29. exonware/xwlazy/module/importer_engine.py +2161 -0
  30. exonware/xwlazy/module/strategies/__init__.py +22 -0
  31. exonware/xwlazy/module/strategies/module_helper_lazy.py +94 -0
  32. exonware/xwlazy/module/strategies/module_helper_simple.py +66 -0
  33. exonware/xwlazy/module/strategies/module_manager_advanced.py +112 -0
  34. exonware/xwlazy/module/strategies/module_manager_simple.py +96 -0
  35. exonware/xwlazy/package/__init__.py +18 -0
  36. exonware/xwlazy/package/base.py +807 -0
  37. xwlazy/lazy/host_conf.py → exonware/xwlazy/package/conf.py +62 -10
  38. exonware/xwlazy/package/data.py +17 -0
  39. exonware/xwlazy/package/facade.py +481 -0
  40. exonware/xwlazy/package/services/__init__.py +84 -0
  41. exonware/xwlazy/package/services/async_install_handle.py +89 -0
  42. exonware/xwlazy/package/services/config_manager.py +246 -0
  43. exonware/xwlazy/package/services/discovery.py +374 -0
  44. {xwlazy/lazy → exonware/xwlazy/package/services}/host_packages.py +43 -16
  45. exonware/xwlazy/package/services/install_async.py +278 -0
  46. exonware/xwlazy/package/services/install_cache.py +146 -0
  47. exonware/xwlazy/package/services/install_interactive.py +60 -0
  48. exonware/xwlazy/package/services/install_policy.py +158 -0
  49. exonware/xwlazy/package/services/install_registry.py +56 -0
  50. exonware/xwlazy/package/services/install_result.py +17 -0
  51. exonware/xwlazy/package/services/install_sbom.py +154 -0
  52. exonware/xwlazy/package/services/install_utils.py +83 -0
  53. exonware/xwlazy/package/services/installer_engine.py +408 -0
  54. exonware/xwlazy/package/services/lazy_installer.py +720 -0
  55. {xwlazy/lazy → exonware/xwlazy/package/services}/manifest.py +42 -25
  56. exonware/xwlazy/package/services/strategy_registry.py +188 -0
  57. exonware/xwlazy/package/strategies/__init__.py +57 -0
  58. exonware/xwlazy/package/strategies/package_discovery_file.py +130 -0
  59. exonware/xwlazy/package/strategies/package_discovery_hybrid.py +85 -0
  60. exonware/xwlazy/package/strategies/package_discovery_manifest.py +102 -0
  61. exonware/xwlazy/package/strategies/package_execution_async.py +114 -0
  62. exonware/xwlazy/package/strategies/package_execution_cached.py +91 -0
  63. exonware/xwlazy/package/strategies/package_execution_pip.py +100 -0
  64. exonware/xwlazy/package/strategies/package_execution_wheel.py +107 -0
  65. exonware/xwlazy/package/strategies/package_mapping_discovery_first.py +101 -0
  66. exonware/xwlazy/package/strategies/package_mapping_hybrid.py +106 -0
  67. exonware/xwlazy/package/strategies/package_mapping_manifest_first.py +101 -0
  68. exonware/xwlazy/package/strategies/package_policy_allow_list.py +58 -0
  69. exonware/xwlazy/package/strategies/package_policy_deny_list.py +58 -0
  70. exonware/xwlazy/package/strategies/package_policy_permissive.py +47 -0
  71. exonware/xwlazy/package/strategies/package_timing_clean.py +68 -0
  72. exonware/xwlazy/package/strategies/package_timing_full.py +67 -0
  73. exonware/xwlazy/package/strategies/package_timing_smart.py +69 -0
  74. exonware/xwlazy/package/strategies/package_timing_temporary.py +67 -0
  75. exonware/xwlazy/runtime/__init__.py +18 -0
  76. exonware/xwlazy/runtime/adaptive_learner.py +131 -0
  77. exonware/xwlazy/runtime/base.py +276 -0
  78. exonware/xwlazy/runtime/facade.py +95 -0
  79. exonware/xwlazy/runtime/intelligent_selector.py +173 -0
  80. exonware/xwlazy/runtime/metrics.py +64 -0
  81. exonware/xwlazy/runtime/performance.py +39 -0
  82. exonware/xwlazy/version.py +2 -2
  83. {exonware_xwlazy-0.1.0.11.dist-info → exonware_xwlazy-0.1.0.19.dist-info}/METADATA +86 -10
  84. exonware_xwlazy-0.1.0.19.dist-info/RECORD +87 -0
  85. exonware_xwlazy-0.1.0.11.dist-info/RECORD +0 -20
  86. xwlazy/__init__.py +0 -34
  87. xwlazy/lazy/__init__.py +0 -301
  88. xwlazy/lazy/bootstrap.py +0 -106
  89. xwlazy/lazy/lazy_base.py +0 -465
  90. xwlazy/lazy/lazy_contracts.py +0 -290
  91. xwlazy/lazy/lazy_core.py +0 -3727
  92. xwlazy/lazy/logging_utils.py +0 -194
  93. xwlazy/version.py +0 -77
  94. /xwlazy/lazy/lazy_state.py → /exonware/xwlazy/common/services/state_manager.py +0 -0
  95. {exonware_xwlazy-0.1.0.11.dist-info → exonware_xwlazy-0.1.0.19.dist-info}/WHEEL +0 -0
  96. {exonware_xwlazy-0.1.0.11.dist-info → exonware_xwlazy-0.1.0.19.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,22 @@
1
+ """
2
+ Module Strategies - Helper and Manager implementations.
3
+
4
+ Company: eXonware.com
5
+ Author: Eng. Muhammad AlShehri
6
+ Email: connect@exonware.com
7
+ Version: 0.1.0.19
8
+ Generation Date: 15-Nov-2025
9
+ """
10
+
11
+ from .module_helper_simple import SimpleHelper
12
+ from .module_helper_lazy import LazyHelper
13
+ from .module_manager_simple import SimpleManager
14
+ from .module_manager_advanced import AdvancedManager
15
+
16
+ __all__ = [
17
+ 'SimpleHelper',
18
+ 'LazyHelper',
19
+ 'SimpleManager',
20
+ 'AdvancedManager',
21
+ ]
22
+
@@ -0,0 +1,94 @@
1
+ """
2
+ Lazy Module Helper Strategy - Deferred loading.
3
+
4
+ Company: eXonware.com
5
+ Author: Eng. Muhammad AlShehri
6
+ Email: connect@exonware.com
7
+ Version: 0.1.0.19
8
+ Generation Date: 15-Nov-2025
9
+
10
+ Lazy loading - loads module on first access with caching.
11
+ """
12
+
13
+ import importlib
14
+ import importlib.util
15
+ import threading
16
+ from types import ModuleType
17
+ from typing import Any, Optional, Dict
18
+ from ...module.base import AModuleHelperStrategy
19
+ from ..data import ModuleData
20
+
21
+
22
+ class LazyHelper(AModuleHelperStrategy):
23
+ """
24
+ Lazy helper - deferred loading with caching.
25
+
26
+ Loads module on first access and caches it.
27
+ Thread-safe with circular import detection.
28
+ """
29
+
30
+ def __init__(self):
31
+ """Initialize lazy helper."""
32
+ self._cache: Dict[str, ModuleType] = {}
33
+ self._loading: Dict[str, bool] = {}
34
+ self._lock = threading.RLock()
35
+
36
+ def load(self, module_path: str, package_helper: Any) -> ModuleType:
37
+ """
38
+ Load the module lazily (with caching).
39
+
40
+ Args:
41
+ module_path: Module path to load
42
+ package_helper: Package helper (unused)
43
+
44
+ Returns:
45
+ Loaded module
46
+ """
47
+ # Check cache first
48
+ if module_path in self._cache:
49
+ return self._cache[module_path]
50
+
51
+ with self._lock:
52
+ # Double-check after acquiring lock
53
+ if module_path in self._cache:
54
+ return self._cache[module_path]
55
+
56
+ # Check for circular import
57
+ if self._loading.get(module_path, False):
58
+ raise ImportError(f"Circular import detected for {module_path}")
59
+
60
+ try:
61
+ self._loading[module_path] = True
62
+ module = importlib.import_module(module_path)
63
+ self._cache[module_path] = module
64
+ return module
65
+ finally:
66
+ self._loading[module_path] = False
67
+
68
+ def unload(self, module_path: str) -> None:
69
+ """
70
+ Unload the module from cache.
71
+
72
+ Args:
73
+ module_path: Module path to unload
74
+ """
75
+ with self._lock:
76
+ self._cache.pop(module_path, None)
77
+ self._loading.pop(module_path, None)
78
+
79
+ def check_importability(self, path: str) -> bool:
80
+ """
81
+ Check if module is importable.
82
+
83
+ Args:
84
+ path: Module path to check
85
+
86
+ Returns:
87
+ True if importable, False otherwise
88
+ """
89
+ try:
90
+ spec = importlib.util.find_spec(path)
91
+ return spec is not None
92
+ except (ValueError, AttributeError, ImportError):
93
+ return False
94
+
@@ -0,0 +1,66 @@
1
+ """
2
+ Simple Module Helper Strategy - Basic synchronous loading.
3
+
4
+ Company: eXonware.com
5
+ Author: Eng. Muhammad AlShehri
6
+ Email: connect@exonware.com
7
+ Version: 0.1.0.19
8
+ Generation Date: 15-Nov-2025
9
+
10
+ Simple synchronous module loading - no lazy loading.
11
+ """
12
+
13
+ import importlib
14
+ from types import ModuleType
15
+ from typing import Any
16
+ from ...module.base import AModuleHelperStrategy
17
+
18
+
19
+ class SimpleHelper(AModuleHelperStrategy):
20
+ """
21
+ Simple helper - standard synchronous import.
22
+
23
+ No lazy loading, no caching, just direct importlib.import_module.
24
+ """
25
+
26
+ def load(self, module_path: str, package_helper: Any) -> ModuleType:
27
+ """
28
+ Load the module synchronously.
29
+
30
+ Args:
31
+ module_path: Module path to load
32
+ package_helper: Package helper (unused in simple mode)
33
+
34
+ Returns:
35
+ Loaded module
36
+ """
37
+ return importlib.import_module(module_path)
38
+
39
+ def unload(self, module_path: str) -> None:
40
+ """
41
+ Unload the module.
42
+
43
+ Args:
44
+ module_path: Module path to unload
45
+ """
46
+ # Simple mode doesn't track loaded modules
47
+ # Could remove from sys.modules if needed
48
+ pass
49
+
50
+ def check_importability(self, path: str) -> bool:
51
+ """
52
+ Check if module is importable.
53
+
54
+ Args:
55
+ path: Module path to check
56
+
57
+ Returns:
58
+ True if importable, False otherwise
59
+ """
60
+ import importlib.util
61
+ try:
62
+ spec = importlib.util.find_spec(path)
63
+ return spec is not None
64
+ except (ValueError, AttributeError, ImportError):
65
+ return False
66
+
@@ -0,0 +1,112 @@
1
+ """
2
+ Advanced Module Manager Strategy - Full features.
3
+
4
+ Company: eXonware.com
5
+ Author: Eng. Muhammad AlShehri
6
+ Email: connect@exonware.com
7
+ Version: 0.1.0.19
8
+ Generation Date: 15-Nov-2025
9
+
10
+ Advanced manager - with hooks, error handling, and full features.
11
+ """
12
+
13
+ import sys
14
+ from types import ModuleType
15
+ from typing import Optional
16
+ from ...module.base import AModuleManagerStrategy
17
+ from ...contracts import ICachingStrategy, IModuleHelperStrategy
18
+ from ...package.base import APackageHelper
19
+ from ...module import importer_engine
20
+
21
+
22
+ class AdvancedManager(AModuleManagerStrategy):
23
+ """
24
+ Advanced manager - full features with hooks and error handling.
25
+
26
+ Supports import hooks, error recovery, and all advanced features.
27
+ """
28
+
29
+ def __init__(
30
+ self,
31
+ package_name: str,
32
+ package_helper: APackageHelper,
33
+ caching: ICachingStrategy,
34
+ helper: IModuleHelperStrategy
35
+ ):
36
+ """
37
+ Initialize advanced manager.
38
+
39
+ Args:
40
+ package_name: Package name for isolation
41
+ package_helper: Package helper instance
42
+ caching: Caching strategy
43
+ helper: Helper strategy
44
+ """
45
+ self._package_name = package_name
46
+ self._package_helper = package_helper
47
+ self._caching = caching
48
+ self._helper = helper
49
+ self._import_hook: Optional[importer_engine.LazyImportHook] = None
50
+
51
+ def load_module(self, module_path: str) -> ModuleType:
52
+ """
53
+ Load a module.
54
+
55
+ Args:
56
+ module_path: Module path to load
57
+
58
+ Returns:
59
+ Loaded module
60
+ """
61
+ # Check cache first
62
+ cached = self._caching.get(module_path)
63
+ if cached is not None:
64
+ return cached
65
+
66
+ # Load using helper
67
+ module = self._helper.load(module_path, self._package_helper)
68
+
69
+ # Cache it
70
+ self._caching.set(module_path, module)
71
+
72
+ return module
73
+
74
+ def unload_module(self, module_path: str) -> None:
75
+ """
76
+ Unload a module.
77
+
78
+ Args:
79
+ module_path: Module path to unload
80
+ """
81
+ self._helper.unload(module_path)
82
+ self._caching.invalidate(module_path)
83
+
84
+ # Also remove from sys.modules if present
85
+ if module_path in sys.modules:
86
+ del sys.modules[module_path]
87
+
88
+ def install_hook(self) -> None:
89
+ """Install import hook into sys.meta_path."""
90
+ importer_engine.install_import_hook(self._package_name)
91
+
92
+ def uninstall_hook(self) -> None:
93
+ """Uninstall import hook from sys.meta_path."""
94
+ importer_engine.uninstall_import_hook(self._package_name)
95
+
96
+ def handle_import_error(self, module_name: str) -> Optional[ModuleType]:
97
+ """
98
+ Handle ImportError by attempting to install and re-import.
99
+
100
+ Args:
101
+ module_name: Name of module that failed to import
102
+
103
+ Returns:
104
+ Imported module if successful, None otherwise
105
+ """
106
+ if self._import_hook is None:
107
+ self._import_hook = importer_engine.LazyImportHook(
108
+ self._package_name,
109
+ self._package_helper
110
+ )
111
+ return self._import_hook.handle_import_error(module_name)
112
+
@@ -0,0 +1,96 @@
1
+ """
2
+ Simple Module Manager Strategy - Basic operations.
3
+
4
+ Company: eXonware.com
5
+ Author: Eng. Muhammad AlShehri
6
+ Email: connect@exonware.com
7
+ Version: 0.1.0.19
8
+ Generation Date: 15-Nov-2025
9
+
10
+ Simple manager - basic module loading/unloading only.
11
+ """
12
+
13
+ from types import ModuleType
14
+ from typing import Optional
15
+ from ...module.base import AModuleManagerStrategy
16
+ from ...contracts import ICachingStrategy, IModuleHelperStrategy
17
+
18
+
19
+ class SimpleManager(AModuleManagerStrategy):
20
+ """
21
+ Simple manager - basic module operations only.
22
+
23
+ No hooks, no error handling, just load/unload.
24
+ """
25
+
26
+ def __init__(
27
+ self,
28
+ package_name: str,
29
+ caching: ICachingStrategy,
30
+ helper: IModuleHelperStrategy
31
+ ):
32
+ """
33
+ Initialize simple manager.
34
+
35
+ Args:
36
+ package_name: Package name for isolation
37
+ caching: Caching strategy
38
+ helper: Helper strategy
39
+ """
40
+ self._package_name = package_name
41
+ self._caching = caching
42
+ self._helper = helper
43
+
44
+ def load_module(self, module_path: str) -> ModuleType:
45
+ """
46
+ Load a module.
47
+
48
+ Args:
49
+ module_path: Module path to load
50
+
51
+ Returns:
52
+ Loaded module
53
+ """
54
+ # Check cache first
55
+ cached = self._caching.get(module_path)
56
+ if cached is not None:
57
+ return cached
58
+
59
+ # Load using helper
60
+ module = self._helper.load(module_path, None)
61
+
62
+ # Cache it
63
+ self._caching.set(module_path, module)
64
+
65
+ return module
66
+
67
+ def unload_module(self, module_path: str) -> None:
68
+ """
69
+ Unload a module.
70
+
71
+ Args:
72
+ module_path: Module path to unload
73
+ """
74
+ self._helper.unload(module_path)
75
+ self._caching.invalidate(module_path)
76
+
77
+ def install_hook(self) -> None:
78
+ """Install import hook (not supported in simple mode)."""
79
+ pass
80
+
81
+ def uninstall_hook(self) -> None:
82
+ """Uninstall import hook (not supported in simple mode)."""
83
+ pass
84
+
85
+ def handle_import_error(self, module_name: str) -> Optional[ModuleType]:
86
+ """
87
+ Handle import error (not supported in simple mode).
88
+
89
+ Args:
90
+ module_name: Module name that failed
91
+
92
+ Returns:
93
+ None (simple mode doesn't handle errors)
94
+ """
95
+ return None
96
+
@@ -0,0 +1,18 @@
1
+ """
2
+ Package Operations Module
3
+
4
+ This module provides concrete implementations for package operations.
5
+ Main facade: XWPackageHelper extends APackageHelper
6
+ """
7
+
8
+ # Lazy imports to avoid circular dependencies
9
+ def __getattr__(name: str):
10
+ if name == 'XWPackageHelper':
11
+ from .facade import XWPackageHelper
12
+ return XWPackageHelper
13
+ if name == 'XWPackage': # Backward compatibility alias
14
+ from .facade import XWPackageHelper
15
+ return XWPackageHelper
16
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
17
+
18
+ __all__ = ['XWPackageHelper', 'XWPackage'] # XWPackage is backward compatibility alias