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