Skip to main content

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., PILpillow, cv2opencv-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 🛠️

  1. Traverses Python files using Black's file discovery approach
  2. Uses AST parsing to safely extract imports
  3. Filters out standard library and project-internal imports
  4. Maps common import aliases to their correct PyPI package names
  5. Generates a clean requirements file

Output 📝

The tool will:

  1. Show all scanned files
  2. List discovered third-party dependencies
  3. Generate a requirements.txt file (or requirements-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 📄

MIT

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)

Source distribution for depscan 0.1.5
File Size Uploaded
depscan-0.1.5.tar.gz 10.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for depscan 0.1.5
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page