Skip to main content

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., 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

depscan-0.1.5.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

depscan-0.1.5-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

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

Hashes for depscan-0.1.5.tar.gz
Algorithm Hash digest
SHA256 0f6aa66cbc72b2a7dd821b7dca4de2cec1147939f9a735a874c2c9bf52df76bf
MD5 46d0dc890a9d26add076dc47dc5e6895
BLAKE2b-256 62f9e76e74a12249c2d4e2977658de6021b79a56ec9f357566ecec3cddd37c31

See more details on using hashes here.

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

Hashes for depscan-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 6b229d100c6c2d5893918627a4180beb3be785837b2b04b8729f24f63bc1ebc6
MD5 0b85387df8f79b7a285d26942cfc20d3
BLAKE2b-256 e2f227ee71beb283551a1a6e86bc9bcc2fdc8cf1ae4d736ee5dbbd47fc4a9220

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page