depscan 🔍
A Python dependency analyzer inspired by Black's implementation that automatically discovers and extracts third-party imports from your Python projects. It scans your codebase to identify external dependencies while filtering out project-internal imports.
Features ✨
- Follows Black's approach to traverse Python files
- Smart package name resolution (e.g.,
PIL→pillow,cv2→opencv-python) - Filters out both standard library and project-internal imports
- Handles common import name mismatches
- Generates
requirements.txtfile - Parallel processing for faster scanning
⚠️ Note: The tool may occasionally fail to identify some dependencies due to complex import patterns or dynamic imports.
Installation 📦
pip install depscan
Usage 🚀
You can use depscan either as a module or directly as a command (like Black):
# As a command (recommended)
depscan src/
depscan . # Current directory
depscan src/ tests/ # Multiple paths
# As a module
python -m depscan src/
python -m depscan .
Options:
depscan src/ --no-save # Don't generate requirements file
depscan src/ --workers 4 # Specify number of parallel workers
How it Works 🛠️
- Traverses Python files using Black's file discovery approach
- Uses AST parsing to safely extract imports
- Filters out standard library and project-internal imports
- Maps common import aliases to their correct PyPI package names
- Generates a clean requirements file
Output 📝
The tool will:
- Show all scanned files
- List discovered third-party dependencies
- Generate a
requirements.txtfile (orrequirements-depscan.txtif the former exists)
Known Limitations 🚧
- May not detect dependencies from dynamic imports
- Some complex import patterns might be missed
- Package name mapping might not cover all cases
Contributing 🤝
Found a bug or want to improve the package name mapping? Contributions are welcome! Please feel free to submit a Pull Request.
License 📄
Release files for depscan 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| depscan-0.1.5.tar.gz | 10.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| depscan-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.9 kB
Release files / depscan-0.1.5.tar.gz
| Download URL | depscan-0.1.5.tar.gz |
|---|---|
| Size | 10.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0f6aa66cbc72b2a7dd821b7dca4de2cec1147939f9a735a874c2c9bf52df76bf
|
|
BLAKE2b-256 checksum How to use checksums |
62f9e76e74a12249c2d4e2977658de6021b79a56ec9f357566ecec3cddd37c31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.5
|
Release files / depscan-0.1.5-py3-none-any.whl
| Download URL | depscan-0.1.5-py3-none-any.whl |
|---|---|
| Size | 10.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6b229d100c6c2d5893918627a4180beb3be785837b2b04b8729f24f63bc1ebc6
|
|
BLAKE2b-256 checksum How to use checksums |
e2f227ee71beb283551a1a6e86bc9bcc2fdc8cf1ae4d736ee5dbbd47fc4a9220
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.5
|