Skip to main content

A tool to automatically detect and install Python dependencies

Project description

PyDepDetective

PyPI version License: MIT

Ever hated starting a new python project (or an existing one) and having to install dependencies one by one?

PyDepDetective is a Python tool that automatically detects and installs dependencies for a given Python file. It simplifies the process of setting up project dependencies by analyzing import statements, comments, and even references to requirements.txt files.

Features

  • Analyzes Python files to detect import statements
  • Identifies third-party imports by filtering out standard library modules
  • Detects pip install comments in the code
  • Recognizes references to requirements.txt files
  • Checks for already installed packages to avoid unnecessary reinstallation
  • Handles common package name mismatches (e.g., PIL for pillow)
  • Provides an interactive prompt to confirm installations
  • Supports installation from requirements.txt files

Installation

You can install PyDepDetective using pip:

pip install pydepdetective

Usage

After installation, you can run PyDepDetective from the command line:

pydepdetective path/to/your/file.py

The tool will analyze the file and prompt you to install any detected dependencies.

How It Works

  1. PyDepDetective parses the given Python file and extracts all import statements.
  2. It filters out standard library imports to identify third-party packages.
  3. The file content is also analyzed for # pip install comments and references to requirements.txt.
  4. The tool checks which packages are already installed in your environment.
  5. You are prompted to confirm the installation of detected dependencies.
  6. If confirmed, PyDepDetective uses pip to install the required packages.

Limitations (for now)

  • May not detect very complex dynamic imports or imports within deeply nested code.
  • The package name mapping is limited to common cases and may need expansion for less common packages.
  • Does not handle version specifications (e.g., package>=1.0.0).

Contributing

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

License

This project is open source and available under the MIT License.

Contact

If you have any questions or feedback, please open an issue on the GitHub repository.

Happy coding!

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

pydepdetective-0.1.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

pydepdetective-0.1.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file pydepdetective-0.1.1.tar.gz.

File metadata

  • Download URL: pydepdetective-0.1.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for pydepdetective-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cd5d4dd3ac2dc1436ef469e3db33c19f17c844b5888c946167722810f2295c59
MD5 f8fdf7c9765c4655699e4d824e96e953
BLAKE2b-256 d8379c6cb8e0d2837d7ab41d5f119869a2e535739295bfe419db33648628d376

See more details on using hashes here.

File details

Details for the file pydepdetective-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pydepdetective-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3de4f7e7e99ca6f9607eaf11c2bc51912340e19c86b7cb9e92108f182ef0b9b0
MD5 64ba5dca81709e584b4fa235b679a683
BLAKE2b-256 23a760351469d432c6484edce8a6af4c64889895ad6b2acb4ccce61646b9abfa

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 Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page