exonware-xwsystem 0.0.1.407__py3-none-any.whl → 0.0.1.409__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 +21 -12
- exonware/conf.py +89 -149
- exonware/xwsystem/__init__.py +18 -159
- exonware/xwsystem/caching/__init__.py +1 -1
- exonware/xwsystem/caching/base.py +1 -1
- exonware/xwsystem/caching/bloom_cache.py +1 -1
- exonware/xwsystem/caching/cache_manager.py +1 -1
- exonware/xwsystem/caching/conditional.py +1 -1
- exonware/xwsystem/caching/contracts.py +1 -1
- exonware/xwsystem/caching/decorators.py +1 -1
- exonware/xwsystem/caching/defs.py +1 -1
- exonware/xwsystem/caching/disk_cache.py +1 -1
- exonware/xwsystem/caching/distributed.py +1 -1
- exonware/xwsystem/caching/errors.py +1 -1
- exonware/xwsystem/caching/events.py +1 -1
- exonware/xwsystem/caching/eviction_strategies.py +1 -1
- exonware/xwsystem/caching/fluent.py +1 -1
- exonware/xwsystem/caching/integrity.py +1 -1
- exonware/xwsystem/caching/lfu_cache.py +1 -1
- exonware/xwsystem/caching/lfu_optimized.py +1 -1
- exonware/xwsystem/caching/lru_cache.py +1 -1
- exonware/xwsystem/caching/memory_bounded.py +1 -1
- exonware/xwsystem/caching/metrics_exporter.py +1 -1
- exonware/xwsystem/caching/observable_cache.py +1 -1
- exonware/xwsystem/caching/pluggable_cache.py +1 -1
- exonware/xwsystem/caching/rate_limiter.py +1 -1
- exonware/xwsystem/caching/read_through.py +1 -1
- exonware/xwsystem/caching/secure_cache.py +1 -1
- exonware/xwsystem/caching/serializable.py +1 -1
- exonware/xwsystem/caching/stats.py +1 -1
- exonware/xwsystem/caching/tagging.py +1 -1
- exonware/xwsystem/caching/ttl_cache.py +1 -1
- exonware/xwsystem/caching/two_tier_cache.py +1 -1
- exonware/xwsystem/caching/utils.py +1 -1
- exonware/xwsystem/caching/validation.py +1 -1
- exonware/xwsystem/caching/warming.py +1 -1
- exonware/xwsystem/caching/write_behind.py +1 -1
- exonware/xwsystem/cli/__init__.py +1 -1
- exonware/xwsystem/cli/args.py +1 -1
- exonware/xwsystem/cli/base.py +1 -1
- exonware/xwsystem/cli/colors.py +1 -1
- exonware/xwsystem/cli/console.py +1 -1
- exonware/xwsystem/cli/contracts.py +1 -1
- exonware/xwsystem/cli/defs.py +1 -1
- exonware/xwsystem/cli/errors.py +1 -1
- exonware/xwsystem/cli/progress.py +1 -1
- exonware/xwsystem/cli/prompts.py +1 -1
- exonware/xwsystem/cli/tables.py +1 -1
- exonware/xwsystem/conf.py +1 -21
- exonware/xwsystem/config/__init__.py +1 -1
- exonware/xwsystem/config/base.py +1 -1
- exonware/xwsystem/config/contracts.py +1 -1
- exonware/xwsystem/config/defaults.py +1 -1
- exonware/xwsystem/config/defs.py +1 -1
- exonware/xwsystem/config/errors.py +1 -1
- exonware/xwsystem/config/logging.py +1 -1
- exonware/xwsystem/config/logging_setup.py +1 -1
- exonware/xwsystem/config/performance.py +1 -1
- exonware/xwsystem/http/__init__.py +1 -1
- exonware/xwsystem/http/advanced_client.py +5 -1
- exonware/xwsystem/http/base.py +1 -1
- exonware/xwsystem/http/client.py +5 -1
- exonware/xwsystem/http/contracts.py +1 -1
- exonware/xwsystem/http/defs.py +1 -1
- exonware/xwsystem/http/errors.py +1 -1
- exonware/xwsystem/io/__init__.py +1 -1
- exonware/xwsystem/io/archive/__init__.py +1 -1
- exonware/xwsystem/io/archive/archive.py +1 -1
- exonware/xwsystem/io/archive/archive_files.py +1 -1
- exonware/xwsystem/io/archive/archivers.py +1 -1
- exonware/xwsystem/io/archive/base.py +1 -1
- exonware/xwsystem/io/archive/codec_integration.py +1 -1
- exonware/xwsystem/io/archive/compression.py +1 -1
- exonware/xwsystem/io/archive/formats/__init__.py +1 -1
- exonware/xwsystem/io/archive/formats/brotli_format.py +1 -1
- exonware/xwsystem/io/archive/formats/lz4_format.py +1 -1
- exonware/xwsystem/io/archive/formats/rar.py +1 -1
- exonware/xwsystem/io/archive/formats/sevenzip.py +1 -1
- exonware/xwsystem/io/archive/formats/squashfs_format.py +1 -1
- exonware/xwsystem/io/archive/formats/tar.py +1 -1
- exonware/xwsystem/io/archive/formats/wim_format.py +1 -1
- exonware/xwsystem/io/archive/formats/zip.py +1 -1
- exonware/xwsystem/io/archive/formats/zpaq_format.py +1 -1
- exonware/xwsystem/io/archive/formats/zstandard.py +1 -1
- exonware/xwsystem/io/base.py +1 -1
- exonware/xwsystem/io/codec/__init__.py +1 -1
- exonware/xwsystem/io/codec/base.py +1 -1
- exonware/xwsystem/io/codec/contracts.py +1 -1
- exonware/xwsystem/io/codec/registry.py +1 -1
- exonware/xwsystem/io/common/__init__.py +1 -1
- exonware/xwsystem/io/common/base.py +1 -1
- exonware/xwsystem/io/common/lock.py +1 -1
- exonware/xwsystem/io/common/watcher.py +1 -1
- exonware/xwsystem/io/contracts.py +1 -1
- exonware/xwsystem/io/defs.py +1 -1
- exonware/xwsystem/io/errors.py +1 -1
- exonware/xwsystem/io/facade.py +1 -1
- exonware/xwsystem/io/file/__init__.py +1 -1
- exonware/xwsystem/io/file/base.py +1 -1
- exonware/xwsystem/io/file/conversion.py +1 -1
- exonware/xwsystem/io/file/file.py +1 -1
- exonware/xwsystem/io/file/paged_source.py +1 -1
- exonware/xwsystem/io/file/paging/__init__.py +1 -1
- exonware/xwsystem/io/file/paging/byte_paging.py +1 -1
- exonware/xwsystem/io/file/paging/line_paging.py +1 -1
- exonware/xwsystem/io/file/paging/record_paging.py +1 -1
- exonware/xwsystem/io/file/paging/registry.py +1 -1
- exonware/xwsystem/io/file/source.py +1 -1
- exonware/xwsystem/io/filesystem/__init__.py +1 -1
- exonware/xwsystem/io/filesystem/base.py +1 -1
- exonware/xwsystem/io/filesystem/local.py +1 -1
- exonware/xwsystem/io/folder/__init__.py +1 -1
- exonware/xwsystem/io/folder/base.py +1 -1
- exonware/xwsystem/io/folder/folder.py +1 -1
- exonware/xwsystem/io/serialization/__init__.py +1 -1
- exonware/xwsystem/io/serialization/auto_serializer.py +1 -1
- exonware/xwsystem/io/serialization/base.py +2 -2
- exonware/xwsystem/io/serialization/contracts.py +1 -1
- exonware/xwsystem/io/serialization/defs.py +1 -1
- exonware/xwsystem/io/serialization/errors.py +1 -1
- exonware/xwsystem/io/serialization/flyweight.py +1 -1
- exonware/xwsystem/io/serialization/format_detector.py +1 -1
- exonware/xwsystem/io/serialization/formats/__init__.py +1 -1
- exonware/xwsystem/io/serialization/formats/binary/bson.py +1 -1
- exonware/xwsystem/io/serialization/formats/binary/cbor.py +1 -1
- exonware/xwsystem/io/serialization/formats/binary/marshal.py +1 -1
- exonware/xwsystem/io/serialization/formats/binary/msgpack.py +1 -1
- exonware/xwsystem/io/serialization/formats/binary/pickle.py +1 -1
- exonware/xwsystem/io/serialization/formats/binary/plistlib.py +1 -1
- exonware/xwsystem/io/serialization/formats/database/dbm.py +1 -1
- exonware/xwsystem/io/serialization/formats/database/shelve.py +1 -1
- exonware/xwsystem/io/serialization/formats/database/sqlite3.py +1 -1
- exonware/xwsystem/io/serialization/formats/text/configparser.py +1 -1
- exonware/xwsystem/io/serialization/formats/text/csv.py +1 -1
- exonware/xwsystem/io/serialization/formats/text/formdata.py +1 -1
- exonware/xwsystem/io/serialization/formats/text/json.py +1 -1
- exonware/xwsystem/io/serialization/formats/text/json5.py +1 -1
- exonware/xwsystem/io/serialization/formats/text/jsonlines.py +1 -1
- exonware/xwsystem/io/serialization/formats/text/multipart.py +1 -1
- exonware/xwsystem/io/serialization/formats/text/toml.py +1 -1
- exonware/xwsystem/io/serialization/formats/text/xml.py +1 -1
- exonware/xwsystem/io/serialization/formats/text/yaml.py +1 -1
- exonware/xwsystem/io/serialization/registry.py +1 -1
- exonware/xwsystem/io/serialization/serializer.py +1 -1
- exonware/xwsystem/io/serialization/utils/__init__.py +1 -1
- exonware/xwsystem/io/serialization/utils/path_ops.py +1 -1
- exonware/xwsystem/io/stream/__init__.py +1 -1
- exonware/xwsystem/io/stream/async_operations.py +1 -1
- exonware/xwsystem/io/stream/base.py +1 -1
- exonware/xwsystem/io/stream/codec_io.py +1 -1
- exonware/xwsystem/ipc/async_fabric.py +1 -1
- exonware/xwsystem/ipc/base.py +1 -1
- exonware/xwsystem/ipc/contracts.py +1 -1
- exonware/xwsystem/ipc/defs.py +1 -1
- exonware/xwsystem/ipc/errors.py +1 -1
- exonware/xwsystem/lazy_bootstrap.py +79 -0
- exonware/xwsystem/monitoring/base.py +1 -1
- exonware/xwsystem/monitoring/contracts.py +1 -1
- exonware/xwsystem/monitoring/defs.py +1 -1
- exonware/xwsystem/monitoring/errors.py +1 -1
- exonware/xwsystem/monitoring/performance_manager_generic.py +1 -1
- exonware/xwsystem/monitoring/system_monitor.py +1 -1
- exonware/xwsystem/monitoring/tracing.py +17 -15
- exonware/xwsystem/monitoring/tracker.py +1 -1
- exonware/xwsystem/operations/__init__.py +1 -1
- exonware/xwsystem/operations/base.py +1 -1
- exonware/xwsystem/operations/defs.py +1 -1
- exonware/xwsystem/operations/diff.py +1 -1
- exonware/xwsystem/operations/merge.py +1 -1
- exonware/xwsystem/operations/patch.py +1 -1
- exonware/xwsystem/patterns/base.py +1 -1
- exonware/xwsystem/patterns/contracts.py +1 -1
- exonware/xwsystem/patterns/defs.py +1 -1
- exonware/xwsystem/patterns/errors.py +1 -1
- exonware/xwsystem/patterns/registry.py +1 -1
- exonware/xwsystem/plugins/__init__.py +1 -1
- exonware/xwsystem/plugins/base.py +1 -1
- exonware/xwsystem/plugins/contracts.py +1 -1
- exonware/xwsystem/plugins/defs.py +1 -1
- exonware/xwsystem/plugins/errors.py +1 -1
- exonware/xwsystem/runtime/__init__.py +1 -1
- exonware/xwsystem/runtime/base.py +1 -1
- exonware/xwsystem/runtime/contracts.py +1 -1
- exonware/xwsystem/runtime/defs.py +1 -1
- exonware/xwsystem/runtime/env.py +1 -1
- exonware/xwsystem/runtime/errors.py +1 -1
- exonware/xwsystem/runtime/reflection.py +1 -1
- exonware/xwsystem/security/auth.py +1 -1
- exonware/xwsystem/security/base.py +1 -1
- exonware/xwsystem/security/contracts.py +1 -1
- exonware/xwsystem/security/crypto.py +1 -1
- exonware/xwsystem/security/defs.py +1 -1
- exonware/xwsystem/security/errors.py +1 -1
- exonware/xwsystem/security/hazmat.py +1 -1
- exonware/xwsystem/shared/__init__.py +1 -1
- exonware/xwsystem/shared/base.py +1 -1
- exonware/xwsystem/shared/contracts.py +1 -1
- exonware/xwsystem/shared/defs.py +1 -1
- exonware/xwsystem/shared/errors.py +1 -1
- exonware/xwsystem/structures/base.py +1 -1
- exonware/xwsystem/structures/contracts.py +1 -1
- exonware/xwsystem/structures/defs.py +1 -1
- exonware/xwsystem/structures/errors.py +1 -1
- exonware/xwsystem/threading/async_primitives.py +1 -1
- exonware/xwsystem/threading/base.py +1 -1
- exonware/xwsystem/threading/contracts.py +1 -1
- exonware/xwsystem/threading/defs.py +1 -1
- exonware/xwsystem/threading/errors.py +1 -1
- exonware/xwsystem/utils/base.py +1 -1
- exonware/xwsystem/utils/contracts.py +1 -1
- exonware/xwsystem/utils/dt/__init__.py +1 -1
- exonware/xwsystem/utils/dt/base.py +1 -1
- exonware/xwsystem/utils/dt/contracts.py +1 -1
- exonware/xwsystem/utils/dt/defs.py +1 -1
- exonware/xwsystem/utils/dt/errors.py +1 -1
- exonware/xwsystem/utils/dt/formatting.py +1 -1
- exonware/xwsystem/utils/dt/humanize.py +1 -1
- exonware/xwsystem/utils/dt/parsing.py +1 -1
- exonware/xwsystem/utils/dt/timezone_utils.py +1 -1
- exonware/xwsystem/utils/errors.py +1 -1
- exonware/xwsystem/utils/test_runner.py +1 -1
- exonware/xwsystem/utils/utils_contracts.py +1 -1
- exonware/xwsystem/validation/__init__.py +1 -1
- exonware/xwsystem/validation/base.py +1 -1
- exonware/xwsystem/validation/contracts.py +1 -1
- exonware/xwsystem/validation/declarative.py +1 -1
- exonware/xwsystem/validation/defs.py +1 -1
- exonware/xwsystem/validation/errors.py +1 -1
- exonware/xwsystem/validation/fluent_validator.py +1 -1
- exonware/xwsystem/version.py +2 -2
- {exonware_xwsystem-0.0.1.407.dist-info → exonware_xwsystem-0.0.1.409.dist-info}/METADATA +3 -3
- exonware_xwsystem-0.0.1.409.dist-info/RECORD +274 -0
- exonware/xwsystem/_lazy_bootstrap.py +0 -77
- exonware/xwsystem/utils/lazy_package/ARCHITECTURE.md +0 -820
- exonware/xwsystem/utils/lazy_package/__init__.py +0 -268
- exonware/xwsystem/utils/lazy_package/config.py +0 -163
- exonware/xwsystem/utils/lazy_package/lazy_base.py +0 -465
- exonware/xwsystem/utils/lazy_package/lazy_contracts.py +0 -290
- exonware/xwsystem/utils/lazy_package/lazy_core.py +0 -2248
- exonware/xwsystem/utils/lazy_package/lazy_errors.py +0 -253
- exonware/xwsystem/utils/lazy_package/lazy_state.py +0 -86
- exonware_xwsystem-0.0.1.407.dist-info/RECORD +0 -282
- {exonware_xwsystem-0.0.1.407.dist-info → exonware_xwsystem-0.0.1.409.dist-info}/WHEEL +0 -0
- {exonware_xwsystem-0.0.1.407.dist-info → exonware_xwsystem-0.0.1.409.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
#exonware/xwsystem/src/exonware/xwsystem/utils/lazy_package/__init__.py
|
|
3
|
-
|
|
4
|
-
Company: eXonware.com
|
|
5
|
-
Author: Eng. Muhammad AlShehri
|
|
6
|
-
Email: connect@exonware.com
|
|
7
|
-
Version: 0.0.1.407
|
|
8
|
-
Generation Date: 10-Oct-2025
|
|
9
|
-
|
|
10
|
-
Lazy Package - Unified Lazy Loading System
|
|
11
|
-
|
|
12
|
-
This package provides per-package lazy loading with automatic installation
|
|
13
|
-
of missing dependencies. It consolidates all lazy loading functionality into
|
|
14
|
-
a clean, well-structured module following DEV_GUIDELINES.md.
|
|
15
|
-
|
|
16
|
-
Design Patterns:
|
|
17
|
-
- Facade: Unified API (LazySystemFacade, LazyModeFacade)
|
|
18
|
-
- Strategy: Pluggable discovery/installation/caching strategies
|
|
19
|
-
- Template Method: Base classes define common workflows
|
|
20
|
-
- Singleton: Global instances for system-wide state
|
|
21
|
-
- Registry: Per-package isolation (LazyInstallerRegistry)
|
|
22
|
-
- Observer: Performance monitoring
|
|
23
|
-
- Proxy: Deferred loading (LazyLoader, DeferredImportError)
|
|
24
|
-
- Factory: Handler creation
|
|
25
|
-
|
|
26
|
-
Core Goal: Per-Package Lazy Loading
|
|
27
|
-
Each package (xwsystem, xwnode, xwdata) can independently enable lazy mode.
|
|
28
|
-
Only packages installed with [lazy] extra get auto-installation.
|
|
29
|
-
|
|
30
|
-
Quick Start:
|
|
31
|
-
# In your package's __init__.py
|
|
32
|
-
from exonware.xwsystem.utils.lazy_package import config_package_lazy_install_enabled
|
|
33
|
-
config_package_lazy_install_enabled("yourpackage") # Auto-detect from pip install
|
|
34
|
-
|
|
35
|
-
Usage:
|
|
36
|
-
# Then just use normal Python imports!
|
|
37
|
-
import fastavro # Missing? Auto-installed! ✨
|
|
38
|
-
import pandas # Missing? Auto-installed! ✨
|
|
39
|
-
"""
|
|
40
|
-
|
|
41
|
-
# Import all from submodules
|
|
42
|
-
from .lazy_contracts import (
|
|
43
|
-
# Enums
|
|
44
|
-
LazyInstallMode,
|
|
45
|
-
PathType,
|
|
46
|
-
# Dataclasses
|
|
47
|
-
DependencyInfo,
|
|
48
|
-
# Interfaces
|
|
49
|
-
IPackageDiscovery,
|
|
50
|
-
IPackageInstaller,
|
|
51
|
-
IImportHook,
|
|
52
|
-
IPackageCache,
|
|
53
|
-
ILazyLoader,
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
from .lazy_errors import (
|
|
57
|
-
# Exceptions
|
|
58
|
-
LazySystemError,
|
|
59
|
-
LazyInstallError,
|
|
60
|
-
LazyDiscoveryError,
|
|
61
|
-
LazyHookError,
|
|
62
|
-
LazySecurityError,
|
|
63
|
-
ExternallyManagedError,
|
|
64
|
-
DeferredImportError,
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
from .lazy_base import (
|
|
68
|
-
# Abstract base classes
|
|
69
|
-
APackageDiscovery,
|
|
70
|
-
APackageInstaller,
|
|
71
|
-
AImportHook,
|
|
72
|
-
APackageCache,
|
|
73
|
-
ALazyLoader,
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
from .lazy_core import (
|
|
77
|
-
# Core classes
|
|
78
|
-
DependencyMapper,
|
|
79
|
-
LazyDiscovery,
|
|
80
|
-
LazyInstaller,
|
|
81
|
-
LazyInstallPolicy,
|
|
82
|
-
LazyInstallerRegistry,
|
|
83
|
-
LazyImportHook,
|
|
84
|
-
LazyMetaPathFinder,
|
|
85
|
-
LazyLoader,
|
|
86
|
-
LazyImporter,
|
|
87
|
-
LazyModuleRegistry,
|
|
88
|
-
LazyPerformanceMonitor,
|
|
89
|
-
LazyInstallConfig,
|
|
90
|
-
LazyModeFacade,
|
|
91
|
-
|
|
92
|
-
# Discovery functions
|
|
93
|
-
get_lazy_discovery,
|
|
94
|
-
discover_dependencies,
|
|
95
|
-
export_dependency_mappings,
|
|
96
|
-
|
|
97
|
-
# Install functions
|
|
98
|
-
enable_lazy_install,
|
|
99
|
-
disable_lazy_install,
|
|
100
|
-
is_lazy_install_enabled,
|
|
101
|
-
set_lazy_install_mode,
|
|
102
|
-
get_lazy_install_mode,
|
|
103
|
-
install_missing_package,
|
|
104
|
-
install_and_import,
|
|
105
|
-
get_lazy_install_stats,
|
|
106
|
-
get_all_lazy_install_stats,
|
|
107
|
-
lazy_import_with_install,
|
|
108
|
-
xwimport,
|
|
109
|
-
|
|
110
|
-
# Hook functions
|
|
111
|
-
install_import_hook,
|
|
112
|
-
uninstall_import_hook,
|
|
113
|
-
is_import_hook_installed,
|
|
114
|
-
|
|
115
|
-
# Lazy loading functions
|
|
116
|
-
enable_lazy_imports,
|
|
117
|
-
disable_lazy_imports,
|
|
118
|
-
is_lazy_import_enabled,
|
|
119
|
-
lazy_import,
|
|
120
|
-
register_lazy_module,
|
|
121
|
-
preload_module,
|
|
122
|
-
get_lazy_module,
|
|
123
|
-
get_loading_stats,
|
|
124
|
-
preload_frequently_used,
|
|
125
|
-
get_lazy_import_stats,
|
|
126
|
-
|
|
127
|
-
# Lazy mode facade functions
|
|
128
|
-
enable_lazy_mode,
|
|
129
|
-
disable_lazy_mode,
|
|
130
|
-
is_lazy_mode_enabled,
|
|
131
|
-
get_lazy_mode_stats,
|
|
132
|
-
configure_lazy_mode,
|
|
133
|
-
preload_modules,
|
|
134
|
-
optimize_lazy_mode,
|
|
135
|
-
|
|
136
|
-
# Configuration
|
|
137
|
-
config_package_lazy_install_enabled,
|
|
138
|
-
|
|
139
|
-
# Security & Policy
|
|
140
|
-
set_package_allow_list,
|
|
141
|
-
set_package_deny_list,
|
|
142
|
-
add_to_package_allow_list,
|
|
143
|
-
add_to_package_deny_list,
|
|
144
|
-
set_package_index_url,
|
|
145
|
-
set_package_extra_index_urls,
|
|
146
|
-
add_package_trusted_host,
|
|
147
|
-
set_package_lockfile,
|
|
148
|
-
generate_package_sbom,
|
|
149
|
-
check_externally_managed_environment,
|
|
150
|
-
)
|
|
151
|
-
|
|
152
|
-
from .config import LazyConfig, DEFAULT_LAZY_CONFIG
|
|
153
|
-
|
|
154
|
-
# Version info
|
|
155
|
-
__version__ = "0.0.1.382"
|
|
156
|
-
__author__ = "Eng. Muhammad AlShehri"
|
|
157
|
-
__email__ = "connect@exonware.com"
|
|
158
|
-
__company__ = "eXonware.com"
|
|
159
|
-
|
|
160
|
-
# Export all
|
|
161
|
-
__all__ = [
|
|
162
|
-
# Enums
|
|
163
|
-
'LazyInstallMode',
|
|
164
|
-
'PathType',
|
|
165
|
-
|
|
166
|
-
# Dataclasses
|
|
167
|
-
'DependencyInfo',
|
|
168
|
-
|
|
169
|
-
# Interfaces
|
|
170
|
-
'IPackageDiscovery',
|
|
171
|
-
'IPackageInstaller',
|
|
172
|
-
'IImportHook',
|
|
173
|
-
'IPackageCache',
|
|
174
|
-
'ILazyLoader',
|
|
175
|
-
|
|
176
|
-
# Exceptions
|
|
177
|
-
'LazySystemError',
|
|
178
|
-
'LazyInstallError',
|
|
179
|
-
'LazyDiscoveryError',
|
|
180
|
-
'LazyHookError',
|
|
181
|
-
'LazySecurityError',
|
|
182
|
-
'ExternallyManagedError',
|
|
183
|
-
'DeferredImportError',
|
|
184
|
-
|
|
185
|
-
# Abstract base classes
|
|
186
|
-
'APackageDiscovery',
|
|
187
|
-
'APackageInstaller',
|
|
188
|
-
'AImportHook',
|
|
189
|
-
'APackageCache',
|
|
190
|
-
'ALazyLoader',
|
|
191
|
-
|
|
192
|
-
# Core classes
|
|
193
|
-
'DependencyMapper',
|
|
194
|
-
'LazyDiscovery',
|
|
195
|
-
'LazyInstaller',
|
|
196
|
-
'LazyInstallPolicy',
|
|
197
|
-
'LazyInstallerRegistry',
|
|
198
|
-
'LazyImportHook',
|
|
199
|
-
'LazyMetaPathFinder',
|
|
200
|
-
'LazyLoader',
|
|
201
|
-
'LazyImporter',
|
|
202
|
-
'LazyModuleRegistry',
|
|
203
|
-
'LazyPerformanceMonitor',
|
|
204
|
-
'LazyInstallConfig',
|
|
205
|
-
'LazyModeFacade',
|
|
206
|
-
|
|
207
|
-
# Discovery functions
|
|
208
|
-
'get_lazy_discovery',
|
|
209
|
-
'discover_dependencies',
|
|
210
|
-
'export_dependency_mappings',
|
|
211
|
-
|
|
212
|
-
# Install functions
|
|
213
|
-
'enable_lazy_install',
|
|
214
|
-
'disable_lazy_install',
|
|
215
|
-
'is_lazy_install_enabled',
|
|
216
|
-
'set_lazy_install_mode',
|
|
217
|
-
'get_lazy_install_mode',
|
|
218
|
-
'install_missing_package',
|
|
219
|
-
'install_and_import',
|
|
220
|
-
'get_lazy_install_stats',
|
|
221
|
-
'get_all_lazy_install_stats',
|
|
222
|
-
'lazy_import_with_install',
|
|
223
|
-
'xwimport',
|
|
224
|
-
|
|
225
|
-
# Hook functions
|
|
226
|
-
'install_import_hook',
|
|
227
|
-
'uninstall_import_hook',
|
|
228
|
-
'is_import_hook_installed',
|
|
229
|
-
|
|
230
|
-
# Lazy loading functions
|
|
231
|
-
'enable_lazy_imports',
|
|
232
|
-
'disable_lazy_imports',
|
|
233
|
-
'is_lazy_import_enabled',
|
|
234
|
-
'lazy_import',
|
|
235
|
-
'register_lazy_module',
|
|
236
|
-
'preload_module',
|
|
237
|
-
'get_lazy_module',
|
|
238
|
-
'get_loading_stats',
|
|
239
|
-
'preload_frequently_used',
|
|
240
|
-
'get_lazy_import_stats',
|
|
241
|
-
|
|
242
|
-
# Lazy mode facade functions
|
|
243
|
-
'enable_lazy_mode',
|
|
244
|
-
'disable_lazy_mode',
|
|
245
|
-
'is_lazy_mode_enabled',
|
|
246
|
-
'get_lazy_mode_stats',
|
|
247
|
-
'configure_lazy_mode',
|
|
248
|
-
'preload_modules',
|
|
249
|
-
'optimize_lazy_mode',
|
|
250
|
-
|
|
251
|
-
# Configuration
|
|
252
|
-
'config_package_lazy_install_enabled',
|
|
253
|
-
'LazyConfig',
|
|
254
|
-
'DEFAULT_LAZY_CONFIG',
|
|
255
|
-
|
|
256
|
-
# Security & Policy
|
|
257
|
-
'set_package_allow_list',
|
|
258
|
-
'set_package_deny_list',
|
|
259
|
-
'add_to_package_allow_list',
|
|
260
|
-
'add_to_package_deny_list',
|
|
261
|
-
'set_package_index_url',
|
|
262
|
-
'set_package_extra_index_urls',
|
|
263
|
-
'add_package_trusted_host',
|
|
264
|
-
'set_package_lockfile',
|
|
265
|
-
'generate_package_sbom',
|
|
266
|
-
'check_externally_managed_environment',
|
|
267
|
-
]
|
|
268
|
-
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
"""Configuration helpers for the lazy-loading subsystem."""
|
|
4
|
-
|
|
5
|
-
from dataclasses import dataclass, field
|
|
6
|
-
from typing import Tuple
|
|
7
|
-
|
|
8
|
-
from .lazy_core import (
|
|
9
|
-
config_package_lazy_install_enabled,
|
|
10
|
-
disable_lazy_mode,
|
|
11
|
-
enable_lazy_mode,
|
|
12
|
-
is_import_hook_installed,
|
|
13
|
-
is_lazy_install_enabled,
|
|
14
|
-
is_lazy_mode_enabled,
|
|
15
|
-
install_import_hook,
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
@dataclass
|
|
20
|
-
class LazyConfig:
|
|
21
|
-
"""Bridge configuration settings with the lazy package implementation."""
|
|
22
|
-
|
|
23
|
-
packages: Tuple[str, ...] = field(
|
|
24
|
-
default_factory=lambda: ("xwsystem", "default")
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
def __post_init__(self) -> None:
|
|
28
|
-
self.packages = tuple(package.lower() for package in self.packages)
|
|
29
|
-
|
|
30
|
-
# High-level API -----------------------------------------------------
|
|
31
|
-
@property
|
|
32
|
-
def lazy_import(self) -> bool:
|
|
33
|
-
"""Return whether lazy mode is currently active."""
|
|
34
|
-
return is_lazy_mode_enabled()
|
|
35
|
-
|
|
36
|
-
@lazy_import.setter
|
|
37
|
-
def lazy_import(self, value: bool) -> None:
|
|
38
|
-
self.set_lazy_import(bool(value))
|
|
39
|
-
|
|
40
|
-
def set_lazy_import(
|
|
41
|
-
self,
|
|
42
|
-
enabled: bool,
|
|
43
|
-
*,
|
|
44
|
-
lazy_imports: bool = True,
|
|
45
|
-
lazy_install: bool = True,
|
|
46
|
-
install_hook: bool = True,
|
|
47
|
-
mode: str = "auto",
|
|
48
|
-
) -> None:
|
|
49
|
-
"""
|
|
50
|
-
Toggle lazy mode with optional fine-grained controls.
|
|
51
|
-
|
|
52
|
-
Includes re-hooking support: If lazy is enabled and install_hook is True,
|
|
53
|
-
ensures the import hook is installed even if it wasn't installed initially.
|
|
54
|
-
"""
|
|
55
|
-
if enabled:
|
|
56
|
-
self._configure_packages(True, mode=mode, install_hook=install_hook)
|
|
57
|
-
enable_lazy_mode(
|
|
58
|
-
package_name=self.packages[0],
|
|
59
|
-
enable_lazy_imports=lazy_imports,
|
|
60
|
-
enable_lazy_install=lazy_install,
|
|
61
|
-
install_hook=install_hook,
|
|
62
|
-
lazy_install_mode=mode,
|
|
63
|
-
)
|
|
64
|
-
# Re-hook: Install hook if lazy is enabled and hook not already installed
|
|
65
|
-
# Root cause: Hook not installed when lazy enabled after package load
|
|
66
|
-
# Priority impact: Usability (#2) - Users expect lazy to work when enabled
|
|
67
|
-
if install_hook:
|
|
68
|
-
self._ensure_hook_installed()
|
|
69
|
-
else:
|
|
70
|
-
disable_lazy_mode()
|
|
71
|
-
self._configure_packages(False, install_hook=False)
|
|
72
|
-
|
|
73
|
-
def enable(
|
|
74
|
-
self,
|
|
75
|
-
*,
|
|
76
|
-
lazy_imports: bool = True,
|
|
77
|
-
lazy_install: bool = True,
|
|
78
|
-
install_hook: bool = True,
|
|
79
|
-
mode: str = "auto",
|
|
80
|
-
) -> None:
|
|
81
|
-
"""Enable lazy mode using the provided options."""
|
|
82
|
-
self.set_lazy_import(
|
|
83
|
-
True,
|
|
84
|
-
lazy_imports=lazy_imports,
|
|
85
|
-
lazy_install=lazy_install,
|
|
86
|
-
install_hook=install_hook,
|
|
87
|
-
mode=mode,
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
def disable(self) -> None:
|
|
91
|
-
"""Disable lazy mode entirely."""
|
|
92
|
-
self.set_lazy_import(False)
|
|
93
|
-
|
|
94
|
-
# DX: Status check methods -------------------------------------------
|
|
95
|
-
def get_lazy_status(self) -> dict:
|
|
96
|
-
"""
|
|
97
|
-
Get detailed lazy installation status (DX enhancement).
|
|
98
|
-
|
|
99
|
-
Returns:
|
|
100
|
-
Dictionary with lazy mode status information
|
|
101
|
-
"""
|
|
102
|
-
try:
|
|
103
|
-
primary_package = self.packages[0] if self.packages else "xwsystem"
|
|
104
|
-
return {
|
|
105
|
-
'enabled': self.lazy_import,
|
|
106
|
-
'hook_installed': is_import_hook_installed(primary_package),
|
|
107
|
-
'lazy_install_enabled': is_lazy_install_enabled(primary_package),
|
|
108
|
-
'active': self.lazy_import and is_import_hook_installed(primary_package)
|
|
109
|
-
}
|
|
110
|
-
except Exception:
|
|
111
|
-
return {
|
|
112
|
-
'enabled': self.lazy_import,
|
|
113
|
-
'hook_installed': False,
|
|
114
|
-
'lazy_install_enabled': False,
|
|
115
|
-
'active': False,
|
|
116
|
-
'error': 'Could not check hook status'
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
def is_lazy_active(self) -> bool:
|
|
120
|
-
"""
|
|
121
|
-
Check if lazy mode is active (DX enhancement).
|
|
122
|
-
|
|
123
|
-
Returns:
|
|
124
|
-
True if lazy mode is enabled and hook is installed
|
|
125
|
-
"""
|
|
126
|
-
try:
|
|
127
|
-
primary_package = self.packages[0] if self.packages else "xwsystem"
|
|
128
|
-
return self.lazy_import and is_import_hook_installed(primary_package)
|
|
129
|
-
except Exception:
|
|
130
|
-
return False
|
|
131
|
-
|
|
132
|
-
# Internal helpers ---------------------------------------------------
|
|
133
|
-
def _configure_packages(
|
|
134
|
-
self,
|
|
135
|
-
enabled: bool,
|
|
136
|
-
*,
|
|
137
|
-
mode: str = "auto",
|
|
138
|
-
install_hook: bool = True,
|
|
139
|
-
) -> None:
|
|
140
|
-
for package in self.packages:
|
|
141
|
-
config_package_lazy_install_enabled(
|
|
142
|
-
package,
|
|
143
|
-
enabled,
|
|
144
|
-
mode,
|
|
145
|
-
install_hook=install_hook,
|
|
146
|
-
)
|
|
147
|
-
|
|
148
|
-
def _ensure_hook_installed(self) -> None:
|
|
149
|
-
"""
|
|
150
|
-
Ensure import hook is installed for primary package.
|
|
151
|
-
|
|
152
|
-
Re-hooking support: Install hook if not already installed.
|
|
153
|
-
"""
|
|
154
|
-
try:
|
|
155
|
-
primary_package = self.packages[0] if self.packages else "xwsystem"
|
|
156
|
-
if not is_import_hook_installed(primary_package):
|
|
157
|
-
install_import_hook(primary_package)
|
|
158
|
-
except Exception:
|
|
159
|
-
# Fail silently - hook installation failure shouldn't break package
|
|
160
|
-
pass
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
DEFAULT_LAZY_CONFIG = LazyConfig()
|