Skip to content

theand9/Conda-Module-Installer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Python Module Search and Install CLI

Why I Created This Tool

As a developer working across diverse environments, one of the biggest challenges I faced was installing Python packages from different Anaconda channels and running into frustrating dependency conflicts. I frequently had to switch between conda-forge, anaconda, and other channels, only to realize that some packages were missing or incompatible. The process of manually searching for modules, identifying the best channel, and dealing with installation conflicts felt unnecessarily cumbersome.

I wanted a tool that could:

  1. Automatically search for a Python module across channels.
  2. Identify the most reliable channel for the package.
  3. Provide a validated installation command.
  4. Handle the process efficiently while avoiding dependency conflicts.

And so, this CLI tool was born to streamline the workflow of searching and installing Python modules from Anaconda.


Features

  • Automated Search: Searches for the specified Python module across Anaconda channels (e.g., conda-forge, anaconda).
  • Channel Priority: Allows specifying a preferred channel or automatically selects the best one.
  • Validated Installation: Ensures the installation command is well-formed and safe before execution.
  • Retry Mechanism: Handles transient network issues with an exponential backoff strategy.
  • Dry Run Mode: Displays the installation command without executing it, so you can double-check before proceeding.

How It Works

  1. Search for the Module:
    • The tool searches Anaconda.org for the specified module and parses the available channels.
  2. Identify the Best Channel:
    • It prioritizes user-specified channels (if provided) or defaults to common ones like conda-forge and anaconda.
  3. Generate Installation Command:
    • It extracts the installation command directly from the module’s page.
  4. Execute the Command:
    • The tool validates the command and optionally runs it to install the module.

Usage

Command-Line Arguments

python script.py <module_name> [--channel <channel>] [--dry-run]

Examples

  1. Search and Install a Module

    python script.py pandas
  2. Specify a Preferred Channel

    python script.py pandas --channel conda-forge
  3. Dry Run Mode

    python script.py pandas --dry-run

Dependencies

The tool requires the following Python libraries:

  • requests
  • beautifulsoup4
  • typing-extensions

You can install them using:

pip install -r requirements.txt

How to Set Up

  1. Clone the Repository:

    git clone <repository-url>
    cd <repository-directory>
  2. Install Dependencies:

    pip install -r requirements.txt
  3. Run the Script:

    python script.py <module_name>

Challenges Overcome

During development, I encountered several issues that influenced the tool’s design:

  1. Dependency Conflicts:

    • Some modules worked well in one channel but conflicted with packages from others. This tool automatically prioritizes channels based on availability and user preferences to minimize conflicts.
  2. Timeouts and Unresponsive Servers:

    • Implemented a retry mechanism with exponential backoff to handle network issues gracefully.
  3. Validating Commands:

    • Added validation to ensure that only legitimate conda install commands are executed.

Future Improvements

  • Dynamic Channel Detection:

    • Fetch available channels dynamically from Anaconda’s API instead of using a predefined list.
  • Enhanced Conflict Resolution:

    • Automatically analyze and suggest solutions for dependency conflicts before installation.
  • GUI Integration:

    • Add a graphical interface for users less comfortable with the CLI.

I hope this tool saves you time and frustration as it has for me. Feel free to contribute or suggest improvements!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages