A fast Python dependency analyzer that automatically discovers and extracts third-party imports
Project description
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.txt
file - 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.txt
file (orrequirements-depscan.txt
if 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 📄
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file depscan-0.1.5.tar.gz
.
File metadata
- Download URL: depscan-0.1.5.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f6aa66cbc72b2a7dd821b7dca4de2cec1147939f9a735a874c2c9bf52df76bf |
|
MD5 | 46d0dc890a9d26add076dc47dc5e6895 |
|
BLAKE2b-256 | 62f9e76e74a12249c2d4e2977658de6021b79a56ec9f357566ecec3cddd37c31 |
File details
Details for the file depscan-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: depscan-0.1.5-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b229d100c6c2d5893918627a4180beb3be785837b2b04b8729f24f63bc1ebc6 |
|
MD5 | 0b85387df8f79b7a285d26942cfc20d3 |
|
BLAKE2b-256 | e2f227ee71beb283551a1a6e86bc9bcc2fdc8cf1ae4d736ee5dbbd47fc4a9220 |