exonware-xwlazy 0.1.0.1__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.
- exonware/__init__.py +42 -0
- exonware/xwlazy/__init__.py +379 -0
- exonware/xwlazy/common/__init__.py +55 -0
- exonware/xwlazy/common/base.py +65 -0
- exonware/xwlazy/common/cache.py +504 -0
- exonware/xwlazy/common/logger.py +257 -0
- exonware/xwlazy/common/services/__init__.py +72 -0
- exonware/xwlazy/common/services/dependency_mapper.py +250 -0
- exonware/xwlazy/common/services/install_async_utils.py +170 -0
- exonware/xwlazy/common/services/install_cache_utils.py +245 -0
- exonware/xwlazy/common/services/keyword_detection.py +283 -0
- exonware/xwlazy/common/services/spec_cache.py +165 -0
- exonware/xwlazy/common/services/state_manager.py +84 -0
- exonware/xwlazy/common/strategies/__init__.py +28 -0
- exonware/xwlazy/common/strategies/caching_dict.py +44 -0
- exonware/xwlazy/common/strategies/caching_installation.py +88 -0
- exonware/xwlazy/common/strategies/caching_lfu.py +66 -0
- exonware/xwlazy/common/strategies/caching_lru.py +63 -0
- exonware/xwlazy/common/strategies/caching_multitier.py +59 -0
- exonware/xwlazy/common/strategies/caching_ttl.py +59 -0
- exonware/xwlazy/common/utils.py +142 -0
- exonware/xwlazy/config.py +193 -0
- exonware/xwlazy/contracts.py +1533 -0
- exonware/xwlazy/defs.py +378 -0
- exonware/xwlazy/errors.py +276 -0
- exonware/xwlazy/facade.py +1137 -0
- exonware/xwlazy/host/__init__.py +8 -0
- exonware/xwlazy/host/conf.py +16 -0
- exonware/xwlazy/module/__init__.py +18 -0
- exonware/xwlazy/module/base.py +643 -0
- exonware/xwlazy/module/data.py +17 -0
- exonware/xwlazy/module/facade.py +246 -0
- exonware/xwlazy/module/importer_engine.py +2964 -0
- exonware/xwlazy/module/partial_module_detector.py +275 -0
- exonware/xwlazy/module/strategies/__init__.py +22 -0
- exonware/xwlazy/module/strategies/module_helper_lazy.py +93 -0
- exonware/xwlazy/module/strategies/module_helper_simple.py +65 -0
- exonware/xwlazy/module/strategies/module_manager_advanced.py +111 -0
- exonware/xwlazy/module/strategies/module_manager_simple.py +95 -0
- exonware/xwlazy/package/__init__.py +18 -0
- exonware/xwlazy/package/base.py +877 -0
- exonware/xwlazy/package/conf.py +324 -0
- exonware/xwlazy/package/data.py +17 -0
- exonware/xwlazy/package/facade.py +480 -0
- exonware/xwlazy/package/services/__init__.py +84 -0
- exonware/xwlazy/package/services/async_install_handle.py +87 -0
- exonware/xwlazy/package/services/config_manager.py +249 -0
- exonware/xwlazy/package/services/discovery.py +435 -0
- exonware/xwlazy/package/services/host_packages.py +180 -0
- exonware/xwlazy/package/services/install_async.py +291 -0
- exonware/xwlazy/package/services/install_cache.py +145 -0
- exonware/xwlazy/package/services/install_interactive.py +59 -0
- exonware/xwlazy/package/services/install_policy.py +156 -0
- exonware/xwlazy/package/services/install_registry.py +54 -0
- exonware/xwlazy/package/services/install_result.py +17 -0
- exonware/xwlazy/package/services/install_sbom.py +153 -0
- exonware/xwlazy/package/services/install_utils.py +79 -0
- exonware/xwlazy/package/services/installer_engine.py +406 -0
- exonware/xwlazy/package/services/lazy_installer.py +803 -0
- exonware/xwlazy/package/services/manifest.py +503 -0
- exonware/xwlazy/package/services/strategy_registry.py +324 -0
- exonware/xwlazy/package/strategies/__init__.py +57 -0
- exonware/xwlazy/package/strategies/package_discovery_file.py +129 -0
- exonware/xwlazy/package/strategies/package_discovery_hybrid.py +84 -0
- exonware/xwlazy/package/strategies/package_discovery_manifest.py +101 -0
- exonware/xwlazy/package/strategies/package_execution_async.py +113 -0
- exonware/xwlazy/package/strategies/package_execution_cached.py +90 -0
- exonware/xwlazy/package/strategies/package_execution_pip.py +99 -0
- exonware/xwlazy/package/strategies/package_execution_wheel.py +106 -0
- exonware/xwlazy/package/strategies/package_mapping_discovery_first.py +100 -0
- exonware/xwlazy/package/strategies/package_mapping_hybrid.py +105 -0
- exonware/xwlazy/package/strategies/package_mapping_manifest_first.py +100 -0
- exonware/xwlazy/package/strategies/package_policy_allow_list.py +57 -0
- exonware/xwlazy/package/strategies/package_policy_deny_list.py +57 -0
- exonware/xwlazy/package/strategies/package_policy_permissive.py +46 -0
- exonware/xwlazy/package/strategies/package_timing_clean.py +67 -0
- exonware/xwlazy/package/strategies/package_timing_full.py +66 -0
- exonware/xwlazy/package/strategies/package_timing_smart.py +68 -0
- exonware/xwlazy/package/strategies/package_timing_temporary.py +66 -0
- exonware/xwlazy/runtime/__init__.py +18 -0
- exonware/xwlazy/runtime/adaptive_learner.py +129 -0
- exonware/xwlazy/runtime/base.py +274 -0
- exonware/xwlazy/runtime/facade.py +94 -0
- exonware/xwlazy/runtime/intelligent_selector.py +170 -0
- exonware/xwlazy/runtime/metrics.py +60 -0
- exonware/xwlazy/runtime/performance.py +37 -0
- exonware/xwlazy/version.py +77 -0
- exonware_xwlazy-0.1.0.1.dist-info/METADATA +454 -0
- exonware_xwlazy-0.1.0.1.dist-info/RECORD +93 -0
- exonware_xwlazy-0.1.0.1.dist-info/WHEEL +4 -0
- exonware_xwlazy-0.1.0.1.dist-info/licenses/LICENSE +21 -0
- xwlazy/__init__.py +14 -0
- xwlazy/lazy.py +30 -0
exonware/__init__.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""
|
|
2
|
+
exonware package - Enterprise-grade Python framework ecosystem
|
|
3
|
+
|
|
4
|
+
Company: eXonware.com
|
|
5
|
+
Author: Eng. Muhammad AlShehri
|
|
6
|
+
Email: connect@exonware.com
|
|
7
|
+
Generation Date: 2025-01-03
|
|
8
|
+
|
|
9
|
+
This is a namespace package allowing multiple exonware subpackages
|
|
10
|
+
to coexist (xwsystem, xwnode, xwdata, xwlazy, etc.)
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
# Make this a namespace package FIRST
|
|
14
|
+
# This allows both exonware.xwsystem and exonware.xwlazy to coexist
|
|
15
|
+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
|
|
16
|
+
|
|
17
|
+
# Import version from xwlazy - required, no fallback
|
|
18
|
+
from exonware.xwlazy.version import __version__
|
|
19
|
+
|
|
20
|
+
__author__ = 'Eng. Muhammad AlShehri'
|
|
21
|
+
__email__ = 'connect@exonware.com'
|
|
22
|
+
__company__ = 'eXonware.com'
|
|
23
|
+
|
|
24
|
+
# NOW enable lazy mode (after namespace package is set up)
|
|
25
|
+
import sys
|
|
26
|
+
import importlib
|
|
27
|
+
try:
|
|
28
|
+
# Use importlib to import after namespace is ready
|
|
29
|
+
if 'exonware.xwlazy' not in sys.modules:
|
|
30
|
+
xwlazy_module = importlib.import_module('exonware.xwlazy')
|
|
31
|
+
auto_enable_lazy = getattr(xwlazy_module, 'auto_enable_lazy', None)
|
|
32
|
+
if auto_enable_lazy:
|
|
33
|
+
auto_enable_lazy("xwsystem", mode="smart")
|
|
34
|
+
print("✅ Lazy mode enabled for xwsystem")
|
|
35
|
+
else:
|
|
36
|
+
# Module already loaded, use it directly
|
|
37
|
+
from exonware.xwlazy import auto_enable_lazy
|
|
38
|
+
auto_enable_lazy("xwsystem", mode="smart")
|
|
39
|
+
print("✅ Lazy mode enabled for xwsystem")
|
|
40
|
+
except (ImportError, AttributeError):
|
|
41
|
+
print("❌ Lazy mode not enabled for xwsystem (xwlazy not installed)")
|
|
42
|
+
pass # xwlazy not installed - silently continue
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
"""
|
|
2
|
+
#exonware/xwlazy/src/exonware/xwlazy/__init__.py
|
|
3
|
+
|
|
4
|
+
xwlazy: Lazy loading and on-demand package installation for Python.
|
|
5
|
+
|
|
6
|
+
The xwlazy library provides automatic dependency installation and lazy loading
|
|
7
|
+
capabilities, allowing packages to declare optional dependencies that are
|
|
8
|
+
installed only when needed.
|
|
9
|
+
|
|
10
|
+
Company: eXonware.com
|
|
11
|
+
Author: Eng. Muhammad AlShehri
|
|
12
|
+
Email: connect@exonware.com
|
|
13
|
+
Generation Date: 10-Oct-2025
|
|
14
|
+
|
|
15
|
+
Main Features:
|
|
16
|
+
- Automatic dependency discovery from pyproject.toml and requirements.txt
|
|
17
|
+
- On-demand package installation via import hooks
|
|
18
|
+
- Two-stage lazy loading for optimal performance
|
|
19
|
+
- Per-package lazy mode configuration
|
|
20
|
+
- Security policies and allow/deny lists
|
|
21
|
+
- SBOM generation and lockfile management
|
|
22
|
+
|
|
23
|
+
Example:
|
|
24
|
+
>>> from exonware.xwlazy import enable_lazy_mode, xwimport
|
|
25
|
+
>>>
|
|
26
|
+
>>> # Enable lazy mode for your package
|
|
27
|
+
>>> enable_lazy_mode(package_name="my_package", lazy_install_mode="smart")
|
|
28
|
+
>>>
|
|
29
|
+
>>> # Import with automatic installation
|
|
30
|
+
>>> pandas = xwimport("pandas") # Installs pandas if not available
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
# =============================================================================
|
|
34
|
+
# VERSION
|
|
35
|
+
# =============================================================================
|
|
36
|
+
|
|
37
|
+
from .version import (
|
|
38
|
+
__version__,
|
|
39
|
+
VERSION_MAJOR,
|
|
40
|
+
VERSION_MINOR,
|
|
41
|
+
VERSION_PATCH,
|
|
42
|
+
VERSION_BUILD,
|
|
43
|
+
VERSION_SUFFIX,
|
|
44
|
+
VERSION_STRING,
|
|
45
|
+
get_version,
|
|
46
|
+
get_version_info,
|
|
47
|
+
get_version_dict,
|
|
48
|
+
is_dev_version,
|
|
49
|
+
is_release_version,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
# =============================================================================
|
|
53
|
+
# IMPORTS - Standard Python Imports (No Defensive Code!)
|
|
54
|
+
# =============================================================================
|
|
55
|
+
|
|
56
|
+
# Import from facade - provides unified public API
|
|
57
|
+
from .facade import (
|
|
58
|
+
# Facade functions
|
|
59
|
+
enable_lazy_mode,
|
|
60
|
+
disable_lazy_mode,
|
|
61
|
+
is_lazy_mode_enabled,
|
|
62
|
+
get_lazy_mode_stats,
|
|
63
|
+
configure_lazy_mode,
|
|
64
|
+
preload_modules,
|
|
65
|
+
optimize_lazy_mode,
|
|
66
|
+
# One-line activation API
|
|
67
|
+
auto_enable_lazy,
|
|
68
|
+
# Lazy-loader compatible API
|
|
69
|
+
attach,
|
|
70
|
+
# Public API functions
|
|
71
|
+
enable_lazy_install,
|
|
72
|
+
disable_lazy_install,
|
|
73
|
+
is_lazy_install_enabled,
|
|
74
|
+
set_lazy_install_mode,
|
|
75
|
+
get_lazy_install_mode,
|
|
76
|
+
install_missing_package,
|
|
77
|
+
install_and_import,
|
|
78
|
+
get_lazy_install_stats,
|
|
79
|
+
get_all_lazy_install_stats,
|
|
80
|
+
lazy_import_with_install,
|
|
81
|
+
xwimport,
|
|
82
|
+
# Hook functions
|
|
83
|
+
install_import_hook,
|
|
84
|
+
uninstall_import_hook,
|
|
85
|
+
is_import_hook_installed,
|
|
86
|
+
# Lazy loading functions
|
|
87
|
+
enable_lazy_imports,
|
|
88
|
+
disable_lazy_imports,
|
|
89
|
+
is_lazy_import_enabled,
|
|
90
|
+
lazy_import,
|
|
91
|
+
register_lazy_module,
|
|
92
|
+
preload_module,
|
|
93
|
+
get_lazy_module,
|
|
94
|
+
get_loading_stats,
|
|
95
|
+
preload_frequently_used,
|
|
96
|
+
get_lazy_import_stats,
|
|
97
|
+
# Configuration
|
|
98
|
+
config_package_lazy_install_enabled,
|
|
99
|
+
config_module_lazy_load_enabled,
|
|
100
|
+
sync_manifest_configuration,
|
|
101
|
+
refresh_lazy_manifests,
|
|
102
|
+
# Security & Policy
|
|
103
|
+
set_package_allow_list,
|
|
104
|
+
set_package_deny_list,
|
|
105
|
+
add_to_package_allow_list,
|
|
106
|
+
add_to_package_deny_list,
|
|
107
|
+
set_package_index_url,
|
|
108
|
+
set_package_extra_index_urls,
|
|
109
|
+
add_package_trusted_host,
|
|
110
|
+
set_package_lockfile,
|
|
111
|
+
generate_package_sbom,
|
|
112
|
+
check_externally_managed_environment,
|
|
113
|
+
register_lazy_module_prefix,
|
|
114
|
+
register_lazy_module_methods,
|
|
115
|
+
# Keyword-based detection
|
|
116
|
+
enable_keyword_detection,
|
|
117
|
+
is_keyword_detection_enabled,
|
|
118
|
+
get_keyword_detection_keyword,
|
|
119
|
+
check_package_keywords,
|
|
120
|
+
# Discovery functions
|
|
121
|
+
get_lazy_discovery,
|
|
122
|
+
discover_dependencies,
|
|
123
|
+
export_dependency_mappings,
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
# Import contracts and base for advanced usage
|
|
127
|
+
from .defs import PRESET_MODES, get_preset_mode
|
|
128
|
+
from .defs import (
|
|
129
|
+
LazyLoadMode,
|
|
130
|
+
LazyInstallMode,
|
|
131
|
+
PathType,
|
|
132
|
+
DependencyInfo,
|
|
133
|
+
LazyModeConfig,
|
|
134
|
+
)
|
|
135
|
+
from .contracts import (
|
|
136
|
+
IPackageHelper,
|
|
137
|
+
IModuleHelper,
|
|
138
|
+
IRuntime,
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
# Import errors
|
|
142
|
+
from .errors import (
|
|
143
|
+
LazySystemError,
|
|
144
|
+
LazyInstallError,
|
|
145
|
+
LazyDiscoveryError,
|
|
146
|
+
LazyHookError,
|
|
147
|
+
LazySecurityError,
|
|
148
|
+
ExternallyManagedError,
|
|
149
|
+
DeferredImportError,
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
# Import config
|
|
153
|
+
from .config import LazyConfig, DEFAULT_LAZY_CONFIG
|
|
154
|
+
|
|
155
|
+
# Import abstract base classes directly from submodules
|
|
156
|
+
from .package.base import APackageHelper
|
|
157
|
+
from .module.base import AModuleHelper
|
|
158
|
+
from .runtime.base import ARuntimeHelper
|
|
159
|
+
|
|
160
|
+
# Import concrete implementations (lazy to prevent circular imports)
|
|
161
|
+
from typing import Any
|
|
162
|
+
|
|
163
|
+
def __getattr__(name: str) -> Any:
|
|
164
|
+
"""Lazy import for concrete facades to prevent circular dependencies."""
|
|
165
|
+
if name == "XWPackageHelper":
|
|
166
|
+
from .package import XWPackageHelper
|
|
167
|
+
return XWPackageHelper
|
|
168
|
+
elif name == "XWModuleHelper":
|
|
169
|
+
from .module import XWModuleHelper
|
|
170
|
+
return XWModuleHelper
|
|
171
|
+
elif name == "XWRuntimeHelper":
|
|
172
|
+
from .runtime import XWRuntimeHelper
|
|
173
|
+
return XWRuntimeHelper
|
|
174
|
+
elif name == "manifest":
|
|
175
|
+
# Import manifest module for lazy access
|
|
176
|
+
from .package.services import manifest
|
|
177
|
+
return manifest
|
|
178
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
179
|
+
|
|
180
|
+
# Import core classes for advanced usage
|
|
181
|
+
from .package.services.config_manager import LazyInstallConfig
|
|
182
|
+
from .package.services import LazyInstallerRegistry, AsyncInstallHandle, LazyInstaller
|
|
183
|
+
from .common.services.dependency_mapper import DependencyMapper
|
|
184
|
+
from .module.importer_engine import (
|
|
185
|
+
LazyMetaPathFinder,
|
|
186
|
+
WatchedPrefixRegistry,
|
|
187
|
+
LazyLoader,
|
|
188
|
+
)
|
|
189
|
+
from .package.services.manifest import LazyManifestLoader, PackageManifest
|
|
190
|
+
from .facade import _lazy_importer
|
|
191
|
+
|
|
192
|
+
# Import internal utilities (for advanced usage)
|
|
193
|
+
from .common.services import (
|
|
194
|
+
check_package_keywords,
|
|
195
|
+
_detect_lazy_installation,
|
|
196
|
+
_detect_meta_info_mode,
|
|
197
|
+
)
|
|
198
|
+
from .module.importer_engine import (
|
|
199
|
+
_set_package_class_hints,
|
|
200
|
+
_get_package_class_hints,
|
|
201
|
+
_clear_all_package_class_hints,
|
|
202
|
+
_spec_for_existing_module,
|
|
203
|
+
)
|
|
204
|
+
from .common.services.spec_cache import (
|
|
205
|
+
_cached_stdlib_check,
|
|
206
|
+
_spec_cache_get,
|
|
207
|
+
_spec_cache_put,
|
|
208
|
+
_spec_cache_clear,
|
|
209
|
+
_cache_spec_if_missing,
|
|
210
|
+
_spec_cache_prune_locked,
|
|
211
|
+
)
|
|
212
|
+
from .package.services import (
|
|
213
|
+
is_externally_managed as _is_externally_managed,
|
|
214
|
+
check_pip_audit_available as _check_pip_audit_available,
|
|
215
|
+
)
|
|
216
|
+
from .module.importer_engine import (
|
|
217
|
+
_is_import_in_progress,
|
|
218
|
+
_mark_import_started,
|
|
219
|
+
_mark_import_finished,
|
|
220
|
+
_lazy_aware_import_module,
|
|
221
|
+
# _patch_import_module removed - deprecated, use sys.meta_path hooks instead
|
|
222
|
+
_unpatch_import_module,
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
# Version info
|
|
226
|
+
__author__ = 'Eng. Muhammad AlShehri'
|
|
227
|
+
__email__ = 'connect@exonware.com'
|
|
228
|
+
__company__ = 'eXonware.com'
|
|
229
|
+
|
|
230
|
+
# =============================================================================
|
|
231
|
+
# PUBLIC API
|
|
232
|
+
# =============================================================================
|
|
233
|
+
|
|
234
|
+
__all__ = [
|
|
235
|
+
# Version
|
|
236
|
+
"__version__",
|
|
237
|
+
"VERSION_MAJOR",
|
|
238
|
+
"VERSION_MINOR",
|
|
239
|
+
"VERSION_PATCH",
|
|
240
|
+
"VERSION_BUILD",
|
|
241
|
+
"VERSION_SUFFIX",
|
|
242
|
+
"VERSION_STRING",
|
|
243
|
+
"get_version",
|
|
244
|
+
"get_version_info",
|
|
245
|
+
"get_version_dict",
|
|
246
|
+
"is_dev_version",
|
|
247
|
+
"is_release_version",
|
|
248
|
+
# Facade functions
|
|
249
|
+
"enable_lazy_mode",
|
|
250
|
+
"disable_lazy_mode",
|
|
251
|
+
"is_lazy_mode_enabled",
|
|
252
|
+
"get_lazy_mode_stats",
|
|
253
|
+
"configure_lazy_mode",
|
|
254
|
+
"preload_modules",
|
|
255
|
+
"optimize_lazy_mode",
|
|
256
|
+
# One-line activation API
|
|
257
|
+
"auto_enable_lazy",
|
|
258
|
+
# Lazy-loader compatible API
|
|
259
|
+
"attach",
|
|
260
|
+
# Public API functions
|
|
261
|
+
"enable_lazy_install",
|
|
262
|
+
"disable_lazy_install",
|
|
263
|
+
"is_lazy_install_enabled",
|
|
264
|
+
"set_lazy_install_mode",
|
|
265
|
+
"get_lazy_install_mode",
|
|
266
|
+
"install_missing_package",
|
|
267
|
+
"install_and_import",
|
|
268
|
+
"get_lazy_install_stats",
|
|
269
|
+
"get_all_lazy_install_stats",
|
|
270
|
+
"lazy_import_with_install",
|
|
271
|
+
"xwimport",
|
|
272
|
+
# Hook functions
|
|
273
|
+
"install_import_hook",
|
|
274
|
+
"uninstall_import_hook",
|
|
275
|
+
"is_import_hook_installed",
|
|
276
|
+
# Lazy loading functions
|
|
277
|
+
"enable_lazy_imports",
|
|
278
|
+
"disable_lazy_imports",
|
|
279
|
+
"is_lazy_import_enabled",
|
|
280
|
+
"lazy_import",
|
|
281
|
+
"register_lazy_module",
|
|
282
|
+
"preload_module",
|
|
283
|
+
"get_lazy_module",
|
|
284
|
+
"get_loading_stats",
|
|
285
|
+
"preload_frequently_used",
|
|
286
|
+
"get_lazy_import_stats",
|
|
287
|
+
# Configuration
|
|
288
|
+
"config_package_lazy_install_enabled",
|
|
289
|
+
"sync_manifest_configuration",
|
|
290
|
+
"refresh_lazy_manifests",
|
|
291
|
+
# Security & Policy
|
|
292
|
+
"set_package_allow_list",
|
|
293
|
+
"set_package_deny_list",
|
|
294
|
+
"add_to_package_allow_list",
|
|
295
|
+
"add_to_package_deny_list",
|
|
296
|
+
"set_package_index_url",
|
|
297
|
+
"set_package_extra_index_urls",
|
|
298
|
+
"add_package_trusted_host",
|
|
299
|
+
"set_package_lockfile",
|
|
300
|
+
"generate_package_sbom",
|
|
301
|
+
"check_externally_managed_environment",
|
|
302
|
+
"register_lazy_module_prefix",
|
|
303
|
+
"register_lazy_module_methods",
|
|
304
|
+
# Keyword-based detection
|
|
305
|
+
"enable_keyword_detection",
|
|
306
|
+
"is_keyword_detection_enabled",
|
|
307
|
+
"get_keyword_detection_keyword",
|
|
308
|
+
"check_package_keywords",
|
|
309
|
+
# Discovery functions
|
|
310
|
+
"get_lazy_discovery",
|
|
311
|
+
"discover_dependencies",
|
|
312
|
+
"export_dependency_mappings",
|
|
313
|
+
# Contracts
|
|
314
|
+
"LazyLoadMode",
|
|
315
|
+
"LazyInstallMode",
|
|
316
|
+
"PathType",
|
|
317
|
+
"DependencyInfo",
|
|
318
|
+
"LazyModeConfig",
|
|
319
|
+
"PRESET_MODES",
|
|
320
|
+
"get_preset_mode",
|
|
321
|
+
"IPackageHelper",
|
|
322
|
+
"IModuleHelper",
|
|
323
|
+
"IRuntime",
|
|
324
|
+
# Abstract base classes
|
|
325
|
+
"APackageHelper",
|
|
326
|
+
"AModuleHelper",
|
|
327
|
+
"ARuntimeHelper",
|
|
328
|
+
# Concrete implementations
|
|
329
|
+
"XWPackageHelper",
|
|
330
|
+
"XWModuleHelper",
|
|
331
|
+
"XWRuntimeHelper",
|
|
332
|
+
# Errors
|
|
333
|
+
"LazySystemError",
|
|
334
|
+
"LazyInstallError",
|
|
335
|
+
"LazyDiscoveryError",
|
|
336
|
+
"LazyHookError",
|
|
337
|
+
"LazySecurityError",
|
|
338
|
+
"ExternallyManagedError",
|
|
339
|
+
"DeferredImportError",
|
|
340
|
+
# Config
|
|
341
|
+
"LazyConfig",
|
|
342
|
+
"DEFAULT_LAZY_CONFIG",
|
|
343
|
+
# Core classes (for advanced usage)
|
|
344
|
+
"LazyInstallConfig",
|
|
345
|
+
"LazyInstallerRegistry",
|
|
346
|
+
"AsyncInstallHandle",
|
|
347
|
+
"LazyInstaller",
|
|
348
|
+
"DependencyMapper",
|
|
349
|
+
"LazyMetaPathFinder",
|
|
350
|
+
"WatchedPrefixRegistry",
|
|
351
|
+
"LazyLoader",
|
|
352
|
+
"LazyManifestLoader",
|
|
353
|
+
"PackageManifest",
|
|
354
|
+
"manifest",
|
|
355
|
+
"_lazy_importer",
|
|
356
|
+
# Internal utilities (for advanced usage)
|
|
357
|
+
"check_package_keywords",
|
|
358
|
+
"_detect_lazy_installation",
|
|
359
|
+
"_detect_meta_info_mode",
|
|
360
|
+
"_set_package_class_hints",
|
|
361
|
+
"_get_package_class_hints",
|
|
362
|
+
"_clear_all_package_class_hints",
|
|
363
|
+
"_spec_for_existing_module",
|
|
364
|
+
"_cached_stdlib_check",
|
|
365
|
+
"_spec_cache_get",
|
|
366
|
+
"_spec_cache_put",
|
|
367
|
+
"_spec_cache_clear",
|
|
368
|
+
"_cache_spec_if_missing",
|
|
369
|
+
"_spec_cache_prune_locked",
|
|
370
|
+
"_is_externally_managed",
|
|
371
|
+
"_check_pip_audit_available",
|
|
372
|
+
"_is_import_in_progress",
|
|
373
|
+
"_mark_import_started",
|
|
374
|
+
"_mark_import_finished",
|
|
375
|
+
"_lazy_aware_import_module",
|
|
376
|
+
# "_patch_import_module", # Removed - deprecated, use sys.meta_path hooks instead
|
|
377
|
+
"_unpatch_import_module",
|
|
378
|
+
]
|
|
379
|
+
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""
|
|
2
|
+
#exonware/xwlazy/src/exonware/xwlazy/common/__init__.py
|
|
3
|
+
|
|
4
|
+
Common utilities shared across package, module, and runtime.
|
|
5
|
+
|
|
6
|
+
Company: eXonware.com
|
|
7
|
+
Author: Eng. Muhammad AlShehri
|
|
8
|
+
Email: connect@exonware.com
|
|
9
|
+
|
|
10
|
+
Generation Date: 15-Nov-2025
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from .logger import (
|
|
14
|
+
get_logger,
|
|
15
|
+
log_event,
|
|
16
|
+
print_formatted,
|
|
17
|
+
format_message,
|
|
18
|
+
is_log_category_enabled,
|
|
19
|
+
set_log_category,
|
|
20
|
+
set_log_categories,
|
|
21
|
+
get_log_categories,
|
|
22
|
+
XWLazyFormatter,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
from .cache import (
|
|
26
|
+
MultiTierCache,
|
|
27
|
+
BytecodeCache,
|
|
28
|
+
InstallationCache,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
from .utils import (
|
|
32
|
+
find_project_root,
|
|
33
|
+
find_config_file,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
__all__ = [
|
|
37
|
+
# Logger
|
|
38
|
+
'get_logger',
|
|
39
|
+
'log_event',
|
|
40
|
+
'print_formatted',
|
|
41
|
+
'format_message',
|
|
42
|
+
'is_log_category_enabled',
|
|
43
|
+
'set_log_category',
|
|
44
|
+
'set_log_categories',
|
|
45
|
+
'get_log_categories',
|
|
46
|
+
'XWLazyFormatter',
|
|
47
|
+
# Cache
|
|
48
|
+
'MultiTierCache',
|
|
49
|
+
'BytecodeCache',
|
|
50
|
+
'InstallationCache',
|
|
51
|
+
# Utils
|
|
52
|
+
'find_project_root',
|
|
53
|
+
'find_config_file',
|
|
54
|
+
]
|
|
55
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Common Abstract Base Classes
|
|
3
|
+
|
|
4
|
+
Company: eXonware.com
|
|
5
|
+
Author: Eng. Muhammad AlShehri
|
|
6
|
+
Email: connect@exonware.com
|
|
7
|
+
|
|
8
|
+
Generation Date: 15-Nov-2025
|
|
9
|
+
|
|
10
|
+
Abstract base classes for shared/common strategies.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from abc import ABC, abstractmethod
|
|
14
|
+
from typing import Optional, Any
|
|
15
|
+
from ..contracts import ICachingStrategy, ICacheStrategy
|
|
16
|
+
|
|
17
|
+
# =============================================================================
|
|
18
|
+
# ABSTRACT CACHING STRATEGY
|
|
19
|
+
# =============================================================================
|
|
20
|
+
|
|
21
|
+
class ACachingStrategy(ICachingStrategy, ABC):
|
|
22
|
+
"""
|
|
23
|
+
Abstract base class for caching strategies (legacy name).
|
|
24
|
+
|
|
25
|
+
Note: Use ACacheStrategy for new code (ICacheStrategy interface).
|
|
26
|
+
"""
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
class ACacheStrategy(ICacheStrategy, ABC):
|
|
30
|
+
"""
|
|
31
|
+
Abstract base class for caching strategies.
|
|
32
|
+
|
|
33
|
+
Works with ANY data type (modules, packages, etc.).
|
|
34
|
+
All caching strategies must extend this class.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
@abstractmethod
|
|
38
|
+
def get(self, key: str) -> Optional[Any]:
|
|
39
|
+
"""Get value from cache."""
|
|
40
|
+
...
|
|
41
|
+
|
|
42
|
+
@abstractmethod
|
|
43
|
+
def set(self, key: str, value: Any) -> None:
|
|
44
|
+
"""Set value in cache."""
|
|
45
|
+
...
|
|
46
|
+
|
|
47
|
+
@abstractmethod
|
|
48
|
+
def invalidate(self, key: str) -> None:
|
|
49
|
+
"""Invalidate cached value."""
|
|
50
|
+
...
|
|
51
|
+
|
|
52
|
+
@abstractmethod
|
|
53
|
+
def clear(self) -> None:
|
|
54
|
+
"""Clear all cached values."""
|
|
55
|
+
...
|
|
56
|
+
|
|
57
|
+
# =============================================================================
|
|
58
|
+
# EXPORT ALL
|
|
59
|
+
# =============================================================================
|
|
60
|
+
|
|
61
|
+
__all__ = [
|
|
62
|
+
'ACachingStrategy', # Legacy name
|
|
63
|
+
'ACacheStrategy', # New name for ICacheStrategy interface
|
|
64
|
+
]
|
|
65
|
+
|