Skip to main content

DependencyDetective

PyPI version Python Versions License: MIT Build Status

DependencyDetective is a powerful tool for analyzing Python project dependencies. It scans your project to identify installed packages, compare them with requirements.txt (if it exists), and analyze usage across files. This tool helps maintain clean and efficient Python projects by providing insights into package usage and potential issues.

Features

  • Scans all Python files in a project to find imported packages
  • Identifies used packages and unused or nested packages
  • Detects missing packages not listed in requirements.txt
  • Highlights potentially outdated packages in requirements.txt
  • Excludes standard library modules from analysis
  • Allows exclusion of specific directories from analysis
  • Generates comprehensive reports for easy dependency management
  • Creates a new requirements.txt with only necessary packages

Installation

pip install dependency-detective

Usage

dependency-detective /path/to/your/project [options]

Optional arguments:

  • --requirements, -r: Specify a custom path to the requirements.txt file (default: requirements.txt)
  • --output, -o: Specify an output file for the analysis report
  • --new-requirements, -n: Generate a new requirements.txt with only necessary packages
  • --exclude, -e: Specify directories to exclude from analysis (default: venv .venv env .env)
  • --verbose, -v: Enable verbose logging

Example

dependency-detective /path/to/your/project -r custom_requirements.txt -o analysis_report.txt -n new_requirements.txt -e venv example_dir

This command will:

  1. Analyze the project at /path/to/your/project
  2. Use custom_requirements.txt as the requirements file
  3. Save the analysis report to analysis_report.txt
  4. Generate a new requirements file named new_requirements.txt with only necessary packages
  5. Exclude the venv and example_dir directories from the analysis

Output

DependencyDetective generates a report that includes:

  • Used Packages: Packages that are imported and used in your project
  • Unused or Nested Packages: Packages that are installed but not directly imported in your project (they might be dependencies of other packages)
  • Missing Packages: Packages that are imported in your project but not installed
  • Potentially Outdated Packages: Packages listed in requirements.txt but not used in the project

The new requirements file (if requested) will contain only the packages directly used in your project, helping to minimize unnecessary dependencies.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for dependency-detective 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dependency-detective 0.1.1
File Size Uploaded
dependency_detective-0.1.1.tar.gz 7.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dependency-detective 0.1.1
File Interpreter ABI Platform
dependency_detective-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 13.0 kB

Release files / dependency_detective-0.1.1.tar.gz

Download URL dependency_detective-0.1.1.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
00be078ad0ffed5209e486e9ed6950b2ca04b7a8c9b7a678d88281c2f230c93b
BLAKE2b-256 checksum
How to use checksums
0bc1a2f3d9c50dd772dfe0e5cc086ecf21ce027afdc4ccf10728d31ff14e2f6c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Release files / dependency_detective-0.1.1-py3-none-any.whl

Download URL dependency_detective-0.1.1-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d15459e1a9865a7609618069216387d34459e8b75ef65d0674fdf97b6bd86ca9
BLAKE2b-256 checksum
How to use checksums
e79b6ef0f0479460e4a0d6e733e55fe3fab8166f8ac5e696a7510e04c053fc4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

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