deptracer 0.1.0__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 its.an.error.ssms.is.here
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,537 @@
1
+ Metadata-Version: 2.4
2
+ Name: deptracer
3
+ Version: 0.1.0
4
+ Summary: OS-Level Dependency Resolver & Auto-Patcher for PyInstaller
5
+ Home-page: https://github.com/Arvind-NITCG/deptracer
6
+ Author: Arvind K N
7
+ Author-email: sooryarvind@gmail.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: POSIX :: Linux
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Topic :: Software Development :: Build Tools
14
+ Requires-Python: >=3.8
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: PyInstaller>=5.0
18
+ Dynamic: author
19
+ Dynamic: author-email
20
+ Dynamic: classifier
21
+ Dynamic: description
22
+ Dynamic: description-content-type
23
+ Dynamic: home-page
24
+ Dynamic: license-file
25
+ Dynamic: requires-dist
26
+ Dynamic: requires-python
27
+ Dynamic: summary
28
+
29
+ # deptracer — Auto-Fix PyInstaller Dependency Hell
30
+
31
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
32
+ [![Python 3.8+](https://img.shields.io/badge/Python-3.8%2B-blue)]()
33
+ [![Linux](https://img.shields.io/badge/Platform-Linux-green)]()
34
+
35
+ ## The Problem
36
+
37
+ You bundle a Python app with PyInstaller. It works on your machine. You ship it to a customer's clean machine. It crashes:
38
+
39
+ ```
40
+ ImportError: libmagic.so: cannot open shared object file: No such file or directory
41
+ ```
42
+
43
+ or
44
+
45
+ ```
46
+ FileNotFoundError: [Errno 2] No such file or directory: 'model.pt'
47
+ ```
48
+
49
+ **PyInstaller doesn't know about dependencies you haven't explicitly told it.**
50
+
51
+ ## The Solution
52
+
53
+ **deptracer** automatically discovers missing dependencies and patches your binary.
54
+
55
+ ```bash
56
+ deptracer build /path/to/project app app.spec
57
+ ```
58
+
59
+ That's it. Your binary now works everywhere.
60
+
61
+ ---
62
+
63
+ ## What deptracer Does
64
+
65
+ 1. **Compiles** your Python app with PyInstaller
66
+ 2. **Traces** all system calls using `strace` in a sandbox
67
+ 3. **Identifies** missing files (binaries, models, configs)
68
+ 4. **Locates** them on your system
69
+ 5. **Patches** PyInstaller's spec to bundle them
70
+ 6. **Recompiles** and repeats until everything is bundled
71
+ 7. **Tests** in an isolated sandbox to verify self-containment
72
+
73
+ All automatically. No manual spec editing.
74
+
75
+ ---
76
+
77
+ ## What It Bundles
78
+
79
+ - **Binary Dependencies**: `.so`, `.dll`, `.dylib` (C/C++ libraries)
80
+ - **ML Models**: `.pt`, `.onnx`, `.h5` (PyTorch, ONNX, TensorFlow)
81
+ - **Data Files**: `.json`, `.yaml`, `.npy`, `.csv` (configs, datasets)
82
+ - **Media**: `.wav`, `.jpg`, `.png` (audio, images)
83
+
84
+ ---
85
+
86
+ ## Installation
87
+
88
+ ```bash
89
+ pip install deptracer
90
+ ```
91
+
92
+ ### Requirements
93
+
94
+ - **Linux** (x86_64 or arm64)
95
+ - **Python 3.8+**
96
+ - **PyInstaller 5.0+**
97
+ - `strace` (usually pre-installed)
98
+ - `bwrap` (for sandboxing)
99
+
100
+ ```bash
101
+ # On Ubuntu/Debian:
102
+ sudo apt-get install strace bubblewrap
103
+
104
+ # On Fedora/RHEL:
105
+ sudo dnf install strace bubblewrap
106
+
107
+ # On Alpine:
108
+ apk add strace bubblewrap
109
+ ```
110
+
111
+ ---
112
+
113
+ ## Quick Start
114
+
115
+ ### 1. Build your app normally
116
+
117
+ ```bash
118
+ # Create your Python app
119
+ cat > my_app.py << 'EOF'
120
+ import magic # Needs libmagic.so
121
+
122
+ def detect_file(path):
123
+ mime = magic.Magic(mime=True)
124
+ return mime.from_file(path)
125
+
126
+ if __name__ == '__main__':
127
+ print(detect_file('/etc/passwd'))
128
+ EOF
129
+
130
+ # Generate PyInstaller spec
131
+ pyinstaller --onefile my_app.py
132
+ ```
133
+
134
+ ### 2. Use deptracer
135
+
136
+ ```bash
137
+ deptracer build . my_app my_app.spec
138
+ ```
139
+
140
+ ### 3. Done!
141
+
142
+ ```bash
143
+ ./dist/my_app
144
+ # Works! Even on machines without libmagic installed
145
+ ```
146
+
147
+ ---
148
+
149
+ ## Real-World Example: File Type Detective
150
+
151
+ Here's a complete example that uses:
152
+ - Binary dependencies: `libmagic.so`
153
+ - Data dependencies: magic database files
154
+ - ML dependencies: None (but easily extensible)
155
+
156
+ ### The Application
157
+
158
+ ```python
159
+ import magic
160
+ import sys
161
+
162
+ class FileTypeDetective:
163
+ def __init__(self):
164
+ self.detector = magic.Magic(mime=True)
165
+
166
+ def detect(self, file_path):
167
+ return self.detector.from_file(file_path)
168
+
169
+ def main():
170
+ detective = FileTypeDetective()
171
+
172
+ test_files = [
173
+ '/etc/passwd', # Text file
174
+ '/bin/bash', # ELF binary
175
+ '/usr/share/doc', # Directory
176
+ ]
177
+
178
+ for path in test_files:
179
+ try:
180
+ file_type = detective.detect(path)
181
+ print(f"{path}: {file_type}")
182
+ except Exception as e:
183
+ print(f"{path}: Error - {e}")
184
+
185
+ if __name__ == '__main__':
186
+ main()
187
+ ```
188
+
189
+ ### Without deptracer (fails):
190
+
191
+ ```bash
192
+ $ pyinstaller --onefile app.py
193
+ $ ./dist/app
194
+ Traceback (most recent call last):
195
+ File "magic.py", line 1, in <module>
196
+ from ctypes import find_library
197
+ ImportError: libmagic.so.1: cannot open shared object file
198
+ ```
199
+
200
+ ### With deptracer (works):
201
+
202
+ ```bash
203
+ $ deptracer build . app app.spec
204
+
205
+ [CORE] INITIATING SWEEP ITERATION: 1
206
+ [TRACER] Initiating Zero-Trust Isolation Sandbox...
207
+ [PARSER] Found missing: libmagic.so.1
208
+ [RESOLVER] Located: /usr/lib/libmagic.so.1
209
+ [FIXER] Patching app.spec...
210
+ [COMPILER] Recompiling...
211
+
212
+ [CORE] EXECUTABLE IS FULLY SAFE FOR PRODUCTION!
213
+
214
+ $ ./dist/app
215
+ /etc/passwd: text/plain
216
+ /bin/bash: application/x-executable
217
+ /usr/share/doc: inode/directory
218
+ ```
219
+
220
+ ---
221
+
222
+ ## Advanced Features
223
+
224
+ ### Multi-Level Dependencies
225
+
226
+ deptracer handles complex dependency chains:
227
+
228
+ ```
229
+ Application
230
+ ├─ libA.so (found, bundled)
231
+ │ └─ libB.so (not found yet)
232
+ │ └─ libC.so (not found yet)
233
+ └─ model.pt (found, bundled)
234
+ └─ config.json (found, bundled)
235
+
236
+ Iteration 1: Finds and bundles libA.so
237
+ Iteration 2: Finds and bundles libB.so
238
+ Iteration 3: Finds and bundles libC.so
239
+ Iteration 4: Clean! ✅
240
+ ```
241
+
242
+ ### Plugin Systems
243
+
244
+ If your app discovers plugins at runtime:
245
+
246
+ ```python
247
+ import glob
248
+ import ctypes
249
+
250
+ for plugin_path in glob.glob('plugins/*.so'):
251
+ plugin = ctypes.CDLL(plugin_path) # deptracer catches this!
252
+ ```
253
+
254
+ deptracer will find and bundle all dynamically-loaded plugins.
255
+
256
+ ### Version-Specific Libraries
257
+
258
+ If you have multiple versions of a library:
259
+
260
+ ```
261
+ /usr/lib/libcustom.so.1 (old)
262
+ /usr/lib/libcustom.so.2 (new)
263
+ /home/user/vendor/lib/libcustom.so (your version)
264
+ ```
265
+
266
+ deptracer intelligently selects the correct version based on load order.
267
+
268
+ ---
269
+
270
+ ## How It Works
271
+
272
+ ### Step 1: Tracer (Sandbox Execution)
273
+
274
+ deptracer runs your binary in a Bubblewrap sandbox, tracing all system calls:
275
+
276
+ ```
277
+ strace -e trace=file -o trace.log ./dist/app
278
+
279
+ Trace output:
280
+ openat(AT_FDCWD, "/usr/lib/libmagic.so.1", O_RDONLY) = 3 ✅ found
281
+ openat(AT_FDCWD, "/tmp/_MEI.../libmagic.so.1", O_RDONLY) = -1 ENOENT ❌ missing
282
+ ```
283
+
284
+ ### Step 2: Parser (Dependency Detection)
285
+
286
+ Parses strace output to identify missing files:
287
+
288
+ ```python
289
+ # Finds:
290
+ # - Binary libraries (.so, .dll, .dylib)
291
+ # - ML models (.pt, .onnx, .h5)
292
+ # - Data files (.json, .yaml, .csv)
293
+ # - Media (.wav, .jpg, .png)
294
+
295
+ # Filters out:
296
+ # - System libraries (already available)
297
+ # - Python internals (_ctypes, _socket, etc)
298
+ # - Architecture-specific variants (glibc-hwcaps)
299
+ ```
300
+
301
+ ### Step 3: Resolver (File Location)
302
+
303
+ Searches your system for missing files:
304
+
305
+ ```python
306
+ Search order:
307
+ 1. Project directory
308
+ 2. Project lib/ subdirectory
309
+ 3. Project build/ subdirectory
310
+ 4. System paths (/usr/lib, /lib64, etc)
311
+ 5. Deep search (find /, with timeout)
312
+ ```
313
+
314
+ ### Step 4: Fixer (Spec Patching)
315
+
316
+ Patches PyInstaller spec to bundle dependencies:
317
+
318
+ ```python
319
+ # For binaries:
320
+ a.binaries += [
321
+ ('/usr/lib/libmagic.so.1', '/usr/lib/libmagic.so.1', 'BINARY')
322
+ ]
323
+
324
+ # For data:
325
+ a.datas += [
326
+ ('/home/user/.cache/magic.mgc', 'magic/'),
327
+ ]
328
+ ```
329
+
330
+ ### Step 5: Compiler (Rebuild)
331
+
332
+ Recompiles with PyInstaller and repeats until clean.
333
+
334
+ ---
335
+
336
+ ## Troubleshooting
337
+
338
+ ### Binary crashes with "library not found"
339
+
340
+ Run deptracer again:
341
+
342
+ ```bash
343
+ deptracer build . app app.spec
344
+ ```
345
+
346
+ It will find any remaining missing dependencies.
347
+
348
+ ### "File not found" errors during bundling
349
+
350
+ Check if the file exists on your system:
351
+
352
+ ```bash
353
+ # deptracer will show which file is missing
354
+ # Find it manually:
355
+ find / -name "libmagic.so*" 2>/dev/null
356
+
357
+ # If not found, install it:
358
+ sudo apt-get install libmagic1
359
+ ```
360
+
361
+ ### Binary is too large
362
+
363
+ deptracer bundles all dependencies. This is by design — the binary must be self-contained.
364
+
365
+ Typical sizes:
366
+ - Simple app: 5-10MB
367
+ - With ML models: 50-200MB
368
+ - With heavy dependencies: 500MB+
369
+
370
+ ### Performance issues
371
+
372
+ deptracer traces all system calls. On slow systems:
373
+ - Tracing can take 10-30 seconds
374
+ - Use `-v` flag for verbose output to see progress
375
+
376
+ ---
377
+
378
+ ## Advanced Usage
379
+
380
+ ### Custom Search Paths
381
+
382
+ ```python
383
+ # In your project, create deptracer_config.py:
384
+ SEARCH_PATHS = [
385
+ '/opt/custom/lib',
386
+ '/home/user/vendor',
387
+ '/usr/local/lib',
388
+ ]
389
+ ```
390
+
391
+ ### Exclude System Libraries
392
+
393
+ ```bash
394
+ # Skip bundling system libraries
395
+ deptracer build . app app.spec --exclude-system
396
+ ```
397
+
398
+ ### Verbose Output
399
+
400
+ ```bash
401
+ # See all steps:
402
+ deptracer build . app app.spec -v
403
+ ```
404
+
405
+ ---
406
+
407
+ ## Architecture
408
+
409
+ deptracer is designed to be **language-agnostic**. Currently supports:
410
+ - ✅ **Python** (PyInstaller)
411
+
412
+ Planned (v0.2+):
413
+ - 🚧 **C/C++** (ELF binaries with RPATH patching)
414
+ - 🚧 **Java** (JAR bundling)
415
+ - 🚧 **Windows** (DLL bundling)
416
+
417
+ ---
418
+
419
+ ## Performance
420
+
421
+ Typical build time with deptracer:
422
+
423
+ | Scenario | Time |
424
+ |----------|------|
425
+ | Simple app (1-2 libs) | 15-30s |
426
+ | Medium app (5-10 libs) | 30-60s |
427
+ | Complex app (20+ libs) | 1-3 minutes |
428
+ | With ML models | 2-10 minutes |
429
+
430
+ Most time is spent in PyInstaller recompilation, not deptracer.
431
+
432
+ ---
433
+
434
+ ## Testing
435
+
436
+ Run the regression suite:
437
+
438
+ ```bash
439
+ # Full test suite with 9 test cases
440
+ python regression_suite.py
441
+
442
+ # Includes:
443
+ # - Simple chains (libA.so)
444
+ # - Deep nesting (vendor/deep/nested/)
445
+ # - Circular symlinks
446
+ # - Plugin systems
447
+ # - Real project test (python-libmagic)
448
+ ```
449
+
450
+ ---
451
+
452
+ ## Contributing
453
+
454
+ deptracer is open source. Contributions welcome!
455
+
456
+ - **Bug reports**: GitHub Issues
457
+ - **Feature requests**: GitHub Discussions
458
+ - **Code**: Pull requests welcome
459
+
460
+ ---
461
+
462
+ ## License
463
+
464
+ MIT License — See LICENSE file for details
465
+
466
+ ---
467
+
468
+ ## Real Success Story
469
+
470
+ **Project**: Shakthi 2.0 (Voice Authentication)
471
+
472
+ **Problem**: Binary crashed with missing Resemblyzer pretrained model
473
+
474
+ ```
475
+ FileNotFoundError: /tmp/_MEI.../resemblyzer/pretrained.pt
476
+ ```
477
+
478
+ **Solution**: One command
479
+
480
+ ```bash
481
+ deptracer build . shakthi_app shakthi_app.spec
482
+ ```
483
+
484
+ **Result**: ✅ Binary works on any system
485
+
486
+ **Files bundled**:
487
+ - Binary: `_soundfile.so`
488
+ - ML Model: `pretrained.pt` (40MB)
489
+ - Data: Audio samples, config files
490
+
491
+ ---
492
+
493
+ ## Support
494
+
495
+ - **Issues**: Report on GitHub
496
+ - **Questions**: GitHub Discussions
497
+ - **Security**: Email security@deptracer.dev
498
+
499
+ ---
500
+
501
+ ## Acknowledgments
502
+
503
+ deptracer uses:
504
+ - `strace` for system call tracing
505
+ - `bwrap` (Bubblewrap) for sandboxing
506
+ - `patchelf` for binary patching
507
+ - `PyInstaller` for Python bundling
508
+
509
+ ---
510
+
511
+ ## What's Next?
512
+
513
+ deptracer is version **0.1.0** and already production-ready for Python projects.
514
+
515
+ Future versions:
516
+ - **0.2**: C/C++ binary support (RPATH patching)
517
+ - **0.3**: Windows & macOS support
518
+ - **1.0**: Multi-language universal bundler
519
+
520
+ ---
521
+
522
+ ## TL;DR
523
+
524
+ ```bash
525
+ # Install
526
+ pip install deptracer
527
+
528
+ # Bundle your app
529
+ deptracer build . my_app my_app.spec
530
+
531
+ # Ship it!
532
+ ./dist/my_app # Works everywhere
533
+ ```
534
+
535
+ That's it. Your dependencies are handled automatically.
536
+
537
+ **Ship with confidence.** 🚀