Skip to main content

Automatically install missing dependencies in your Python project

Project description

Auto Dependency Installer

PyPI version Python Versions License

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:

  1. Create a virtual environment named .venv in the current directory (if it doesn't exist)
  2. Activate the virtual environment
  3. Scan for Python files and detect imports
  4. 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:

  • bs4beautifulsoup4
  • PILpillow
  • cv2opencv-python
  • sklearnscikit-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:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

auto_dep_installer-0.2.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

auto_dep_installer-0.2-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

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

Hashes for auto_dep_installer-0.2.tar.gz
Algorithm Hash digest
SHA256 20ef159d436b09ff7c9bbbcacee006a182041549922b24f8e48cc97898d9fe8e
MD5 0d041c7eff2e5f465b03f1135c734b4f
BLAKE2b-256 f281e6242179d4fa3a8394dffe598caa6c47cef92af3ce14c284b8f105bc3259

See more details on using hashes here.

File details

Details for the file auto_dep_installer-0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for auto_dep_installer-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fdc443ec1461598a3014fb7a9e34f0b42a53e321a03e2db01579c7a2ee995931
MD5 b92b5a0c7253063be72144b8078813be
BLAKE2b-256 ea5f3554a36285d41dc841a06d3bdcfcacfeecb3971b888c3fc3c6f5aaff90d6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page