exonware-xwlazy 0.1.0.1__tar.gz → 0.1.0.9__tar.gz

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 (99) hide show
  1. {exonware_xwlazy-0.1.0.1 → exonware_xwlazy-0.1.0.9}/.gitignore +0 -4
  2. exonware_xwlazy-0.1.0.9/PKG-INFO +0 -0
  3. exonware_xwlazy-0.1.0.9/README.md +0 -0
  4. {exonware_xwlazy-0.1.0.1 → exonware_xwlazy-0.1.0.9}/pyproject.toml +7 -6
  5. exonware_xwlazy-0.1.0.9/src/exonware/xwlazy/__init__.py +0 -0
  6. {exonware_xwlazy-0.1.0.1 → exonware_xwlazy-0.1.0.9}/src/exonware/xwlazy/version.py +2 -2
  7. exonware_xwlazy-0.1.0.1/PKG-INFO +0 -454
  8. exonware_xwlazy-0.1.0.1/README.md +0 -431
  9. exonware_xwlazy-0.1.0.1/src/exonware/__init__.py +0 -42
  10. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/__init__.py +0 -379
  11. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/common/__init__.py +0 -55
  12. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/common/base.py +0 -65
  13. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/common/cache.py +0 -504
  14. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/common/logger.py +0 -257
  15. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/common/services/__init__.py +0 -72
  16. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/common/services/dependency_mapper.py +0 -250
  17. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/common/services/install_async_utils.py +0 -170
  18. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/common/services/install_cache_utils.py +0 -245
  19. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/common/services/keyword_detection.py +0 -283
  20. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/common/services/spec_cache.py +0 -165
  21. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/common/services/state_manager.py +0 -84
  22. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/common/strategies/__init__.py +0 -28
  23. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/common/strategies/caching_dict.py +0 -44
  24. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/common/strategies/caching_installation.py +0 -88
  25. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/common/strategies/caching_lfu.py +0 -66
  26. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/common/strategies/caching_lru.py +0 -63
  27. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/common/strategies/caching_multitier.py +0 -59
  28. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/common/strategies/caching_ttl.py +0 -59
  29. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/common/utils.py +0 -142
  30. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/config.py +0 -193
  31. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/contracts.py +0 -1533
  32. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/defs.py +0 -378
  33. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/errors.py +0 -276
  34. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/facade.py +0 -1137
  35. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/host/__init__.py +0 -8
  36. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/host/conf.py +0 -16
  37. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/module/__init__.py +0 -18
  38. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/module/base.py +0 -643
  39. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/module/data.py +0 -17
  40. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/module/facade.py +0 -246
  41. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/module/importer_engine.py +0 -2964
  42. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/module/partial_module_detector.py +0 -275
  43. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/module/strategies/__init__.py +0 -22
  44. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/module/strategies/module_helper_lazy.py +0 -93
  45. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/module/strategies/module_helper_simple.py +0 -65
  46. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/module/strategies/module_manager_advanced.py +0 -111
  47. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/module/strategies/module_manager_simple.py +0 -95
  48. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/__init__.py +0 -18
  49. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/base.py +0 -877
  50. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/conf.py +0 -324
  51. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/data.py +0 -17
  52. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/facade.py +0 -480
  53. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/services/__init__.py +0 -84
  54. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/services/async_install_handle.py +0 -87
  55. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/services/config_manager.py +0 -249
  56. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/services/discovery.py +0 -435
  57. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/services/host_packages.py +0 -180
  58. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/services/install_async.py +0 -291
  59. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/services/install_cache.py +0 -145
  60. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/services/install_interactive.py +0 -59
  61. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/services/install_policy.py +0 -156
  62. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/services/install_registry.py +0 -54
  63. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/services/install_result.py +0 -17
  64. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/services/install_sbom.py +0 -153
  65. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/services/install_utils.py +0 -79
  66. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/services/installer_engine.py +0 -406
  67. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/services/lazy_installer.py +0 -803
  68. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/services/manifest.py +0 -503
  69. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/services/strategy_registry.py +0 -324
  70. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/strategies/__init__.py +0 -57
  71. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/strategies/package_discovery_file.py +0 -129
  72. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/strategies/package_discovery_hybrid.py +0 -84
  73. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/strategies/package_discovery_manifest.py +0 -101
  74. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/strategies/package_execution_async.py +0 -113
  75. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/strategies/package_execution_cached.py +0 -90
  76. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/strategies/package_execution_pip.py +0 -99
  77. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/strategies/package_execution_wheel.py +0 -106
  78. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/strategies/package_mapping_discovery_first.py +0 -100
  79. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/strategies/package_mapping_hybrid.py +0 -105
  80. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/strategies/package_mapping_manifest_first.py +0 -100
  81. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/strategies/package_policy_allow_list.py +0 -57
  82. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/strategies/package_policy_deny_list.py +0 -57
  83. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/strategies/package_policy_permissive.py +0 -46
  84. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/strategies/package_timing_clean.py +0 -67
  85. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/strategies/package_timing_full.py +0 -66
  86. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/strategies/package_timing_smart.py +0 -68
  87. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/package/strategies/package_timing_temporary.py +0 -66
  88. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/runtime/__init__.py +0 -18
  89. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/runtime/adaptive_learner.py +0 -129
  90. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/runtime/base.py +0 -274
  91. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/runtime/facade.py +0 -94
  92. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/runtime/intelligent_selector.py +0 -170
  93. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/runtime/metrics.py +0 -60
  94. exonware_xwlazy-0.1.0.1/src/exonware/xwlazy/runtime/performance.py +0 -37
  95. exonware_xwlazy-0.1.0.1/src/xwlazy/__init__.py +0 -14
  96. exonware_xwlazy-0.1.0.1/src/xwlazy/lazy.py +0 -30
  97. exonware_xwlazy-0.1.0.1/src/xwlazy.py +0 -43
  98. exonware_xwlazy-0.1.0.1/src/xwlazy_wrapper.py +0 -20
  99. {exonware_xwlazy-0.1.0.1 → exonware_xwlazy-0.1.0.9}/LICENSE +0 -0
@@ -5,10 +5,6 @@
5
5
  # CI/CD Tools (keep private)
6
6
  .ci/
7
7
 
8
- # Migration/legacy directories (may contain paths too long for Windows)
9
- MIGRAT/
10
- MIGRATE/
11
-
12
8
  # ========================================
13
9
  # Python
14
10
  # ========================================
Binary file
Binary file
@@ -7,7 +7,7 @@ name = "exonware-xwlazy"
7
7
  dynamic = ["version"]
8
8
  description = "Marker package that enables lazy install features across the eXonware suite."
9
9
  readme = "README.md"
10
- requires-python = ">=3.12"
10
+ requires-python = ">=3.8"
11
11
  keywords = ["lazy", "exonware", "xwlazy"]
12
12
  classifiers = [
13
13
  "Development Status :: 4 - Beta",
@@ -15,12 +15,14 @@ classifiers = [
15
15
  "License :: OSI Approved :: MIT License",
16
16
  "Operating System :: OS Independent",
17
17
  "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.8",
19
+ "Programming Language :: Python :: 3.9",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
18
22
  "Programming Language :: Python :: 3.12",
19
23
  "Topic :: Software Development :: Libraries :: Python Modules",
20
24
  ]
21
- dependencies = [
22
- "tomli>=2.0.1; python_version < \"3.11\"",
23
- ]
25
+ dependencies = []
24
26
 
25
27
  [[project.authors]]
26
28
  name = "Eng. Muhammad AlShehri"
@@ -33,13 +35,12 @@ text = "MIT"
33
35
  Homepage = "https://exonware.com"
34
36
  Repository = "https://github.com/exonware/xwlazy"
35
37
  Documentation = "https://github.com/exonware/xwlazy#readme"
36
- Subtree = "https://github.com/Exonware/XWLazy.git"
37
38
 
38
39
  [tool.hatch.version]
39
40
  path = "src/exonware/xwlazy/version.py"
40
41
 
41
42
  [tool.hatch.build.targets.wheel]
42
- packages = ["src/exonware", "src/xwlazy"]
43
+ packages = ["src/exonware"]
43
44
 
44
45
  [tool.hatch.build.targets.sdist]
45
46
  include = ["/src", "/README.md", "/LICENSE"]
@@ -14,13 +14,13 @@ All version references should import from this module to ensure consistency.
14
14
  # =============================================================================
15
15
 
16
16
  # Main version - update this to change version across entire project
17
- __version__ = "0.1.0.1"
17
+ __version__ = "0.1.0.9"
18
18
 
19
19
  # Version components for programmatic access
20
20
  VERSION_MAJOR = 0
21
21
  VERSION_MINOR = 1
22
22
  VERSION_PATCH = 0
23
- VERSION_BUILD = 1 # Set to None for releases, or build number for dev builds
23
+ VERSION_BUILD = 9 # Set to None for releases, or build number for dev builds
24
24
 
25
25
  # Version metadata
26
26
  VERSION_SUFFIX = "" # e.g., "dev", "alpha", "beta", "rc1"
@@ -1,454 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: exonware-xwlazy
3
- Version: 0.1.0.1
4
- Summary: Marker package that enables lazy install features across the eXonware suite.
5
- Project-URL: Homepage, https://exonware.com
6
- Project-URL: Repository, https://github.com/exonware/xwlazy
7
- Project-URL: Documentation, https://github.com/exonware/xwlazy#readme
8
- Project-URL: Subtree, https://github.com/Exonware/XWLazy.git
9
- Author-email: "Eng. Muhammad AlShehri" <connect@exonware.com>
10
- License: MIT
11
- License-File: LICENSE
12
- Keywords: exonware,lazy,xwlazy
13
- Classifier: Development Status :: 4 - Beta
14
- Classifier: Intended Audience :: Developers
15
- Classifier: License :: OSI Approved :: MIT License
16
- Classifier: Operating System :: OS Independent
17
- Classifier: Programming Language :: Python :: 3
18
- Classifier: Programming Language :: Python :: 3.12
19
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
- Requires-Python: >=3.12
21
- Requires-Dist: tomli>=2.0.1; python_version < '3.11'
22
- Description-Content-Type: text/markdown
23
-
24
- # xwlazy
25
-
26
- **Enterprise-grade lazy loading with automatic dependency installation—the only lazy import library that installs missing packages on-demand while maintaining per-package isolation and security.**
27
-
28
- [![Status](https://img.shields.io/badge/status-beta-blue.svg)](https://exonware.com)
29
- [![Python](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org)
30
- [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
31
-
32
- ## 🎯 Overview
33
-
34
- xwlazy is a production-ready lazy loading system that enables Python packages to automatically install missing dependencies when they're actually used. Unlike traditional dependency management, xwlazy installs dependencies **on-demand** at runtime, reducing initial installation size, avoiding conflicts, and enabling truly optional features.
35
-
36
- **Why xwlazy exists:** Traditional dependency management requires installing all dependencies upfront, even if they're never used. This leads to bloated installations, longer setup times, and potential conflicts. xwlazy solves this by installing dependencies only when code actually needs them, while maintaining full security and isolation between packages.
37
-
38
- ## ✨ Key Features
39
-
40
- ### 🚀 **Auto-Installation on Demand**
41
- Dependencies are automatically installed when code first uses them—no manual intervention required. Perfect for optional features that users may never need.
42
-
43
- **Why it matters:** Reduces initial installation size by 60-80% for packages with many optional dependencies, while maintaining zero overhead for successful imports.
44
-
45
- ### 🔒 **Per-Package Isolation**
46
- Each package (xwsystem, xwnode, xwdata, etc.) can independently enable lazy mode without affecting others. Complete isolation prevents conflicts and enables flexible deployment strategies.
47
-
48
- **Why it matters:** Allows mixing lazy and non-lazy packages in the same environment, giving developers full control over which packages use auto-installation.
49
-
50
- ### 🎯 **Keyword-Based Auto-Detection**
51
- Packages can opt-in to lazy loading by simply adding `"xwlazy-enabled"` to their `pyproject.toml` keywords—no code changes required.
52
-
53
- **Why it matters:** Zero-code integration for package maintainers. Just add a keyword and lazy loading works automatically.
54
-
55
- ### 🛡️ **Enterprise Security**
56
- - **Allow/Deny Lists:** Whitelist or blacklist specific packages
57
- - **SBOM Generation:** Software Bill of Materials for compliance
58
- - **Vulnerability Auditing:** Automatic security scanning with pip-audit
59
- - **Lockfile Management:** Track installed packages with versions
60
- - **PEP 668 Compliance:** Respects externally-managed environments
61
-
62
- **Why it matters:** Production environments require security controls. xwlazy provides enterprise-grade security without sacrificing usability.
63
-
64
- ### ⚡ **Two-Stage Lazy Loading**
65
- **Stage 1 (Import Time):** Missing imports are logged but don't raise errors—modules load successfully.
66
- **Stage 2 (Usage Time):** Dependencies are installed automatically when code first accesses them.
67
-
68
- **Why it matters:** Enables clean Python code with standard imports. No defensive `try/except ImportError` blocks needed.
69
-
70
- ### 📊 **Performance Monitoring**
71
- Built-in tracking of module load times, access counts, memory usage, and cache hit ratios. Comprehensive statistics API for optimization.
72
-
73
- **Why it matters:** Visibility into lazy loading performance helps identify bottlenecks and optimize import strategies.
74
-
75
- ### 🎨 **Two-Dimensional Mode System**
76
-
77
- xwlazy uses a powerful two-dimensional mode system that separates **loading behavior** from **installation behavior**, giving you precise control over how modules are loaded and when packages are installed.
78
-
79
- #### **Lazy Load Modes** (When modules load)
80
- - **NONE:** Standard imports (no lazy loading)
81
- - **AUTO:** Lazy loading enabled (deferred module loading)
82
- - **PRELOAD:** Preload all modules on start (parallel loading)
83
- - **BACKGROUND:** Load modules in background threads (non-blocking)
84
- - **CACHED:** Cache loaded modules but allow unloading
85
-
86
- #### **Lazy Install Modes** (When packages install)
87
- - **NONE:** No auto-installation
88
- - **SMART:** Install on first usage (on-demand)
89
- - **FULL:** Install all dependencies on start (parallel batch)
90
- - **CLEAN:** Install on usage + uninstall after completion
91
- - **TEMPORARY:** Always uninstall after use (aggressive cleanup)
92
- - **SIZE_AWARE:** Install small packages, skip large ones
93
- - **INTERACTIVE:** Ask user before installing
94
- - **WARN:** Log warning but don't install (monitoring mode)
95
- - **DISABLED:** Don't install anything (explicit)
96
- - **DRY_RUN:** Show what would be installed
97
-
98
- #### **Preset Modes** (Quick combinations)
99
- - **none:** NONE load + NONE install (standard imports)
100
- - **lite:** AUTO load + NONE install (lazy loading only)
101
- - **smart:** AUTO load + SMART install (on-demand installation)
102
- - **full:** AUTO load + FULL install (install all on start)
103
- - **clean:** AUTO load + CLEAN install (install + cleanup)
104
- - **temporary:** AUTO load + TEMPORARY install (aggressive cleanup)
105
- - **size_aware:** AUTO load + SIZE_AWARE install (smart sizing)
106
- - **auto:** AUTO load + SMART install + auto-uninstall large packages
107
-
108
- **Why it matters:** Different environments need different policies. Development might use `smart`, production might use `lite` or `warn`, CI/CD might use `clean` or `temporary`.
109
-
110
- ## 🏆 Performance Benchmarks
111
-
112
- xwlazy has been benchmarked against 8 competing lazy import libraries. **Results show xwlazy is competitive across all load scenarios** while providing significantly more features.
113
-
114
- ### Latest Benchmark Results (2025-11-17)
115
-
116
- | Load Type | xwlazy Time | Rank | vs. Winner | Features |
117
- |-----------|-------------|------|------------|----------|
118
- | **Light Load** (1 module) | 2.08 ms | 🥇 **1st** | 2.54x faster | 7 features |
119
- | **Medium Load** (8 modules) | 6.99 ms | 🥇 **1st** | 8.52x faster | 7 features |
120
- | **Heavy Load** (22 modules) | 21.13 ms | 🥇 **1st** | 25.75x faster | 7 features |
121
- | **Enterprise Load** (50+ modules) | 61.28 ms | 🥇 **1st** | 74.66x faster | 7 features |
122
-
123
- **Competitive Advantage:** While competitors offer 1-2 features (basic lazy loading), xwlazy provides **7 enterprise features** including auto-installation, security policies, SBOM generation, and per-package isolation.
124
-
125
- **See full benchmarks:** [benchmarks/competition_tests/output_log/](benchmarks/competition_tests/output_log/)
126
-
127
- ## 🚀 Quick Start
128
-
129
- ### Installation
130
-
131
- ```bash
132
- # Standard installation
133
- pip install exonware-xwlazy
134
-
135
- # Or install as xwlazy (alias package)
136
- pip install xwlazy
137
- ```
138
-
139
- ### Basic Usage
140
-
141
- **One-line setup** for per-package lazy loading:
142
-
143
- ```python
144
- # In your package's __init__.py
145
- from xwlazy.lazy import config_package_lazy_install_enabled
146
-
147
- # Auto-detects from pip install your-package[lazy]
148
- config_package_lazy_install_enabled("your-package")
149
- ```
150
-
151
- **That's it!** Now use standard imports—missing dependencies install automatically:
152
-
153
- ```python
154
- # your-package/serialization/avro.py
155
- import fastavro # Auto-installed if missing! ✨
156
-
157
- # User code
158
- from your-package.serialization.avro import AvroSerializer
159
- serializer = AvroSerializer() # Installs fastavro on first use
160
- ```
161
-
162
- ### Keyword-Based Detection (Zero Code)
163
-
164
- Add to your `pyproject.toml`:
165
-
166
- ```toml
167
- [project]
168
- name = "my-package"
169
- keywords = ["xwlazy-enabled"] # <-- Add this
170
- ```
171
-
172
- After `pip install -e .`, xwlazy automatically enables lazy loading for your package—no code changes needed!
173
-
174
- ## 📖 Documentation
175
-
176
- - **[Architecture Reference](docs/REF_ARCH.md)** - System design, patterns, and structure
177
- - **[Keyword Detection Guide](docs/KEYWORD_DETECTION.md)** - Zero-code integration
178
- - **[Competition Benchmarks](benchmarks/competition_tests/)** - Performance comparisons
179
- - **[Performance Analysis](benchmarks/competition_tests/PERFORMANCE_ANALYSIS.md)** - Optimization recommendations
180
-
181
- ## 💡 Use Cases
182
-
183
- ### 1. Optional Format Support
184
-
185
- ```python
186
- # xwsystem/serialization/avro.py
187
- import fastavro # Only installed if user needs Avro support
188
-
189
- class AvroSerializer:
190
- def serialize(self, data):
191
- return fastavro.schemaless_writer(...)
192
- ```
193
-
194
- **Benefit:** Users who never use Avro don't install fastavro, reducing installation size.
195
-
196
- ### 2. Development Tools
197
-
198
- ```python
199
- # xwnode/visualization/graphviz.py
200
- import graphviz # Only installed in development
201
-
202
- def visualize_graph(node):
203
- return graphviz.render(...)
204
- ```
205
-
206
- **Benefit:** Production deployments don't include development-only dependencies.
207
-
208
- ### 3. Platform-Specific Features
209
-
210
- ```python
211
- # xwdata/formats/excel.py
212
- try:
213
- import openpyxl # Windows/Linux
214
- except ImportError:
215
- import xlrd # macOS fallback
216
- ```
217
-
218
- **Benefit:** Platform-specific dependencies install automatically based on availability.
219
-
220
- ### 4. Security-Controlled Environments
221
-
222
- ```python
223
- from xwlazy.lazy import (
224
- config_package_lazy_install_enabled,
225
- set_package_allow_list,
226
- )
227
-
228
- # Only allow specific packages
229
- config_package_lazy_install_enabled("xwsystem")
230
- set_package_allow_list("xwsystem", ["fastavro", "protobuf", "msgpack"])
231
-
232
- # Attempts to install other packages are blocked
233
- import suspicious_package # ❌ Blocked by security policy
234
- ```
235
-
236
- **Benefit:** Enterprise environments can restrict auto-installation to approved packages only.
237
-
238
- ## 🔧 Advanced Configuration
239
-
240
- ### Two-Dimensional Mode Configuration
241
-
242
- #### Using Preset Modes (Recommended)
243
-
244
- ```python
245
- from xwlazy.lazy import config_package_lazy_install_enabled
246
-
247
- # Quick preset modes
248
- config_package_lazy_install_enabled("xwsystem", enabled=True, mode="smart") # On-demand install
249
- config_package_lazy_install_enabled("xwsystem", enabled=True, mode="full") # Install all on start
250
- config_package_lazy_install_enabled("xwsystem", enabled=True, mode="clean") # Install + cleanup
251
- config_package_lazy_install_enabled("xwsystem", enabled=True, mode="lite") # Lazy load only
252
- ```
253
-
254
- #### Using Explicit Mode Configuration
255
-
256
- ```python
257
- from xwlazy.lazy import (
258
- config_package_lazy_install_enabled,
259
- LazyLoadMode,
260
- LazyInstallMode,
261
- LazyModeConfig,
262
- )
263
-
264
- # Explicit two-dimensional configuration
265
- config_package_lazy_install_enabled(
266
- "xwsystem",
267
- enabled=True,
268
- load_mode=LazyLoadMode.PRELOAD, # Preload all modules
269
- install_mode=LazyInstallMode.SMART # Install on-demand
270
- )
271
-
272
- # Or use LazyModeConfig for full control
273
- config = LazyModeConfig(
274
- load_mode=LazyLoadMode.BACKGROUND,
275
- install_mode=LazyInstallMode.SIZE_AWARE,
276
- large_package_threshold_mb=100.0, # Skip packages > 100MB
277
- background_workers=4 # 4 background workers
278
- )
279
- config_package_lazy_install_enabled(
280
- "xwsystem",
281
- enabled=True,
282
- mode_config=config
283
- )
284
- ```
285
-
286
- #### Using exonware.conf (Global Configuration)
287
-
288
- ```python
289
- import exonware.conf as conf
290
-
291
- # Set global lazy mode for all packages
292
- conf.lazy = "smart" # or "lite", "full", "clean", "auto", etc.
293
- ```
294
-
295
- #### Special Purpose Modes
296
-
297
- ```python
298
- # Interactive mode: Ask user before installing
299
- config_package_lazy_install_enabled(
300
- "xwsystem",
301
- enabled=True,
302
- mode="interactive" # or LazyInstallMode.INTERACTIVE
303
- )
304
-
305
- # Warn mode: Log but don't install (monitoring)
306
- config_package_lazy_install_enabled(
307
- "xwsystem",
308
- enabled=True,
309
- mode="warn" # or LazyInstallMode.WARN
310
- )
311
- ```
312
-
313
- ### Security Policies
314
-
315
- ```python
316
- from xwlazy.lazy import (
317
- set_package_allow_list,
318
- set_package_deny_list,
319
- set_package_lockfile,
320
- )
321
-
322
- # Whitelist approach
323
- set_package_allow_list("xwsystem", ["fastavro", "protobuf"])
324
-
325
- # Blacklist approach
326
- set_package_deny_list("xwsystem", ["suspicious-package"])
327
-
328
- # Track installations
329
- set_package_lockfile("xwsystem", "xwsystem-lazy-lock.json")
330
- ```
331
-
332
- ### SBOM Generation
333
-
334
- ```python
335
- from xwlazy.lazy import generate_package_sbom
336
-
337
- # Generate Software Bill of Materials for compliance
338
- sbom = generate_package_sbom("xwsystem", "xwsystem-sbom.json")
339
- ```
340
-
341
- ### Statistics and Monitoring
342
-
343
- ```python
344
- from xwlazy.lazy import get_lazy_install_stats
345
-
346
- # Get installation statistics
347
- stats = get_lazy_install_stats("xwsystem")
348
- # {
349
- # 'enabled': True,
350
- # 'mode': 'auto',
351
- # 'installed_packages': ['fastavro', 'protobuf'],
352
- # 'failed_packages': [],
353
- # 'total_installed': 2
354
- # }
355
- ```
356
-
357
- ## 🎨 Design Patterns
358
-
359
- xwlazy implements 8 design patterns for maintainability and extensibility:
360
-
361
- 1. **Facade Pattern** - Unified API to complex subsystems
362
- 2. **Strategy Pattern** - Pluggable discovery/installation strategies
363
- 3. **Template Method** - Base classes define common workflows
364
- 4. **Singleton** - Global instances for system-wide state
365
- 5. **Registry** - Per-package isolation and management
366
- 6. **Observer** - Performance monitoring and tracking
367
- 7. **Proxy** - Deferred loading and lazy access
368
- 8. **Factory** - Creating appropriate handlers by context
369
-
370
- ## 🔒 Security Considerations
371
-
372
- ### PEP 668 Compliance
373
- xwlazy respects externally-managed Python environments and refuses to install in system Python, suggesting virtual environments instead.
374
-
375
- ### System Module Protection
376
- Built-in modules (stdlib) are never auto-installed, preventing accidental system modifications.
377
-
378
- ### Vulnerability Scanning
379
- Optional pip-audit integration scans packages after installation and logs security warnings.
380
-
381
- ### Custom PyPI Mirrors
382
- Support for internal PyPI servers with custom index URLs and trusted hosts.
383
-
384
- ## ⚡ Performance Characteristics
385
-
386
- - **Zero overhead** for successful imports (hooks only trigger on failures)
387
- - **Aggressive caching** with file modification time checks
388
- - **Lazy initialization** - everything loads only when needed
389
- - **Thread-safe** operations with proper locking
390
- - **Import overhead:** ~0.1ms for successful imports
391
- - **First failure:** ~50ms (discovery + policy check)
392
- - **Subsequent failures:** ~5ms (cached discovery)
393
-
394
- ## 🧪 Testing
395
-
396
- xwlazy includes comprehensive test suites:
397
-
398
- ```bash
399
- # Run all tests
400
- python tests/runner.py
401
-
402
- # Run specific test layers
403
- python tests/0.core/runner.py # Core tests (< 30s)
404
- python tests/1.unit/runner.py # Unit tests (< 5m)
405
- ```
406
-
407
- ## 📊 Comparison with Competitors
408
-
409
- | Feature | xwlazy | lazy-imports-lite | lazy-loader | lazy_import |
410
- |---------|--------|-------------------|-------------|-------------|
411
- | **Lazy Import** | ✅ | ✅ | ✅ | ✅ |
412
- | **Auto-Installation** | ✅ | ❌ | ❌ | ❌ |
413
- | **Keyword Detection** | ✅ | ✅ | ❌ | ❌ |
414
- | **Per-Package Isolation** | ✅ | ❌ | ❌ | ❌ |
415
- | **Security Policies** | ✅ | ❌ | ❌ | ❌ |
416
- | **SBOM Generation** | ✅ | ❌ | ❌ | ❌ |
417
- | **Performance Monitoring** | ✅ | ❌ | ❌ | ❌ |
418
- | **Two-Stage Loading** | ✅ | ❌ | ❌ | ❌ |
419
- | **Total Features** | **7** | **2** | **1** | **1** |
420
-
421
- ## 🤝 Contributing
422
-
423
- xwlazy is part of the eXonware ecosystem. For contributions, please follow:
424
-
425
- - [Development Guide](../../docs/guides/GUIDE_DEV.md) - Core development standards
426
- - [Testing Guide](../../docs/guides/GUIDE_TEST.md) - Testing standards
427
- - [Documentation Guide](../../docs/guides/GUIDE_DOCS.md) - Documentation standards
428
-
429
- ## 📄 License
430
-
431
- MIT License - see [LICENSE](LICENSE) for details.
432
-
433
- ## 🔗 Links
434
-
435
- - **Homepage:** https://exonware.com
436
- - **Repository:** https://github.com/exonware/xwlazy
437
- - **Email:** connect@exonware.com
438
- - **Author:** Eng. Muhammad AlShehri
439
-
440
- ## 🙏 Acknowledgments
441
-
442
- xwlazy is built with inspiration from the Python lazy import ecosystem, particularly:
443
- - `lazy-imports-lite` for keyword-based detection concept
444
- - `lazy-loader` for scientific Python patterns
445
- - The broader Python import system for hook mechanisms
446
-
447
- ---
448
-
449
- **Part of the eXonware ecosystem** - Enterprise-grade Python libraries for modern software development.
450
-
451
- *Last Updated: 17-Nov-2025*
452
-
453
- > **Note:** For the current version, use `from exonware.xwlazy import __version__` or `import exonware.xwlazy; print(exonware.xwlazy.__version__)`
454
-