Skip to main content

A tool to automatically detect and install Python dependencies

Project description

PyDepDetective

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.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

pydepdetective-0.1.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydepdetective-0.1.0.tar.gz
  • Upload date:
  • Size: 3.9 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.0.tar.gz
Algorithm Hash digest
SHA256 004acb0e4e77137127523c4589b7bad9e179860351f78ecca4b4cb05f690e9c4
MD5 17d6822aaae2056f5c40fd30d5a7e8af
BLAKE2b-256 c9a89bffe543d1d62fef227473e6c829ea53d2cdb0064a7428a9baa83914284f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydepdetective-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da54649fc63c2a3dba556b4d68a5a85005a2cd101bebf440dee6ecbdc5b2117d
MD5 57199e616a8047d065f38f77451c149c
BLAKE2b-256 30ded29358cb308800406731da72d4692a3e4e152f2cf879b605b0ecce4b0cf8

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