Automatically install missing dependencies in your Python project
Project description
Auto Dependency Installer
Auto Dependency Installer is a Python package that automatically scans your project's source code for imported modules, detects which ones are missing in your environment, and installs them for you. It can create and use virtual environments to keep your dependencies isolated.
Installation
Install directly from PyPI:
pip install auto-dep-installer
Features
- Virtual Environment Support: Automatically create and activate virtual environments
- Automated Scanning: Recursively scans Python files for import statements
- Dependency Detection: Identifies which imported modules are missing
- Automatic Installation: Installs missing packages via pip
- Command-Line Interface: Simple and intuitive CLI
- Customizable Mappings: Support for custom module-to-package mappings
- Dependency Resolution: Attempts to resolve dependency conflicts when packages fail to install
- Cross-Platform Support: Works on Windows, macOS, and Linux
Quick Start
Basic Usage
To scan the current directory and install all dependencies in a new virtual environment:
auto-dep
This will:
- Create a virtual environment named
.venvin the current directory (if it doesn't exist) - Activate the virtual environment
- Scan for Python files and detect imports
- Install missing dependencies
Advanced Usage
Specify a custom virtual environment name:
auto-dep --venv my_project_env
Scan a specific directory:
auto-dep --directory ./path/to/project
Skip virtual environment creation:
auto-dep --no-venv
Use custom module-to-package mappings:
auto-dep --custom-mappings mappings.json
Enable verbose logging:
auto-dep --verbose
Attempt to resolve dependency issues:
auto-dep --resolve
Force reinstall packages even if they're already installed:
auto-dep --force-reinstall
Command-Line Options
usage: auto-dep [-h] [--directory DIRECTORY] [--venv VENV] [--no-venv]
[--custom-mappings CUSTOM_MAPPINGS] [--verbose] [--resolve]
[--force-reinstall] [--no-instructions]
Auto Dependency Installer
optional arguments:
-h, --help show this help message and exit
--directory DIRECTORY, -d DIRECTORY
Directory to scan for Python files (default: current directory)
--venv VENV, -v VENV Virtual environment name/path (default: .venv)
--no-venv Skip virtual environment creation/activation
--custom-mappings CUSTOM_MAPPINGS, -m CUSTOM_MAPPINGS
Path to JSON file with custom module-to-package mappings
--verbose Enable verbose output
--resolve Attempt to resolve dependency issues
--force-reinstall Force reinstall of packages even if they are already installed
--no-instructions Don't print activation instructions after installation
Custom Mappings
You can provide a JSON file with custom module-to-package mappings:
{
"custom_module": "custom-package-name",
"private_pkg": "company-private-package"
}
The tool already includes common mappings like:
bs4→beautifulsoup4PIL→pillowcv2→opencv-pythonsklearn→scikit-learn
Use Cases
- Quick Prototyping: Start coding without worrying about dependencies
- Project Setup: Quickly set up development environments
- Onboarding: Help new team members get your project running
- Legacy Projects: Easily identify and install dependencies for older projects
Known Limitations
- Only top-level imports are detected; dynamic or conditional imports might be missed
- The tool assumes module names match package names (except for known mappings)
- Standard library modules are excluded but some edge cases might exist
Contributing
Contributions are welcome! Feel free to:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
Auto Dependency Installer is dual-licensed under the MIT License and the Apache License 2.0. You may choose either license.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file auto_dep_installer-0.2.tar.gz.
File metadata
- Download URL: auto_dep_installer-0.2.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20ef159d436b09ff7c9bbbcacee006a182041549922b24f8e48cc97898d9fe8e
|
|
| MD5 |
0d041c7eff2e5f465b03f1135c734b4f
|
|
| BLAKE2b-256 |
f281e6242179d4fa3a8394dffe598caa6c47cef92af3ce14c284b8f105bc3259
|
File details
Details for the file auto_dep_installer-0.2-py3-none-any.whl.
File metadata
- Download URL: auto_dep_installer-0.2-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fdc443ec1461598a3014fb7a9e34f0b42a53e321a03e2db01579c7a2ee995931
|
|
| MD5 |
b92b5a0c7253063be72144b8078813be
|
|
| BLAKE2b-256 |
ea5f3554a36285d41dc841a06d3bdcfcacfeecb3971b888c3fc3c6f5aaff90d6
|