diff --git a/getreq b/getreq deleted file mode 100755 index 3ee156d..0000000 --- a/getreq +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -# Script to find Python imports and install them if necessary - -# Check for input argument -if [ "$#" -ne 1 ]; then - echo "Usage: $0 " - exit 1 -fi - -PYTHON_FILE="$1" - -# Extract import statements -IMPORTS=$(grep -E "^import |^from " "$PYTHON_FILE" | \ - awk '{print $2}' | cut -d. -f1 | sort | uniq) - -# Function to check and install packages -check_and_install() { - PACKAGE=$1 - # Check if the package is installed via pip - if pip list | grep -q "^$PACKAGE "; then - echo "$PACKAGE is already installed via pip." - # Check if the package is installed via conda - elif conda list | grep -q "^$PACKAGE "; then - echo "$PACKAGE is already installed via conda." - else - # Install the package using kip - echo "Installing $PACKAGE using kip..." - kip install "$PACKAGE" - fi -} - -# Iterate over imports and check/install them -for pkg in $IMPORTS; do - check_and_install $pkg -done - diff --git a/kip-simple b/kip-simple deleted file mode 100755 index 321ce4c..0000000 --- a/kip-simple +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -# Function to install a package -install_package() { - package=$1 - - if mamba list | grep -q "^$package\s"; then - echo "Package '$package' already installed by mamba." - elif pip list | grep -q "^$package\s"; then - echo "Package '$package' already installed by pip." - else - echo "Installing package '$package'." - mamba install -y -c conda-forge "$package" || pip install "$package" - fi -} - -# Function to process Python file for import statements -process_python_file() { - file_path=$1 - # Extracting module names from import statements, handling both 'import' and 'from ... import ...' - IMPORTS=$(grep -E "^import |^from " "$file_path" | \ - awk '{if($1=="from") print $2; else print $2}' | \ - cut -d. -f1 | sort | uniq) - - for package in $IMPORTS; do - echo "Processing $package from $file_path" - install_package $package - done -} - -# Check if any arguments were passed -if [ "$#" -lt 1 ]; then - echo "Usage: kip [ ...] or kip " - exit 1 -fi - -MAMBA_BASE=$(mamba info --base) -export PYTHONPATH="${PYTHONPATH}:${MAMBA_BASE}/${CONDA_DEFAULT_ENV}/lib/python" - -for arg in "$@"; do - # Check if the argument is a Python file - if [[ "$arg" == *.py ]]; then - if [ -f "$arg" ]; then - process_python_file "$arg" - else - echo "File $arg not found." - fi - else - install_package "$arg" - fi -done -