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
forpillow
) - 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
- PyDepDetective parses the given Python file and extracts all import statements.
- It filters out standard library imports to identify third-party packages.
- The file content is also analyzed for
# pip install
comments and references torequirements.txt
. - The tool checks which packages are already installed in your environment.
- You are prompted to confirm the installation of detected dependencies.
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd5d4dd3ac2dc1436ef469e3db33c19f17c844b5888c946167722810f2295c59 |
|
MD5 | f8fdf7c9765c4655699e4d824e96e953 |
|
BLAKE2b-256 | d8379c6cb8e0d2837d7ab41d5f119869a2e535739295bfe419db33648628d376 |
File details
Details for the file pydepdetective-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: pydepdetective-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3de4f7e7e99ca6f9607eaf11c2bc51912340e19c86b7cb9e92108f182ef0b9b0 |
|
MD5 | 64ba5dca81709e584b4fa235b679a683 |
|
BLAKE2b-256 | 23a760351469d432c6484edce8a6af4c64889895ad6b2acb4ccce61646b9abfa |