From 2b960177a81076ed77894677079cc7e1b9d14ff6 Mon Sep 17 00:00:00 2001 From: Utsav-pal <159793156+Utsav-pal@users.noreply.github.com> Date: Mon, 27 Jan 2025 19:04:25 +0530 Subject: [PATCH] Update install-eSim.sh 1.Replaced the use of python3-distutils with python3-setuptools as an alternative, ensuring robust dependency management. 2.Added checks for python3-venv and included its installation if not already present. 3.Introduced pipx for installing Python packages in isolated environments to avoid conflicts. 4.Enhanced the script to prompt for a custom virtual environment path, with a default option of ~/myenv. 5.Automated virtual environment creation and ensured the installation of necessary Python packages (Watchdog, Hdlparse, Makerchip, and SandPiper Saas) within it. 6.Added improved error handling and messages for better usability. These changes aim to streamline the installation process and enhance its reliability. --- Ubuntu/install-eSim.sh | 95 ++++++++++++++++++++++++++++-------------- 1 file changed, 64 insertions(+), 31 deletions(-) diff --git a/Ubuntu/install-eSim.sh b/Ubuntu/install-eSim.sh index 0d36709d..9606e7e2 100755 --- a/Ubuntu/install-eSim.sh +++ b/Ubuntu/install-eSim.sh @@ -123,31 +123,20 @@ function installKicad } + function installDependency { set +e # Temporary disable exit on error trap "" ERR # Do not trap on error of any command - # Update apt repository - echo "Updating apt index files..................." + # Update apt repository + echo "Updating apt index files..................." sudo apt-get update set -e # Re-enable exit on error trap error_exit ERR - echo "Instaling virtualenv......................." - sudo apt install python3-virtualenv - - echo "Creating virtual environment to isolate packages " - virtualenv $config_dir/env - - echo "Starting the virtual env..................." - source $config_dir/env/bin/activate - - echo "Upgrading Pip.............................." - pip install --upgrade pip - echo "Installing Xterm..........................." sudo apt-get install -y xterm @@ -159,38 +148,82 @@ function installDependency echo "Installing Matplotlib......................" sudo apt-get install -y python3-matplotlib + + echo "Attempting to install python3-setuptools as an alternative to distutils..." + if sudo apt-get install -y python3-setuptools; then + echo "python3-setuptools installed successfully." + else + echo "Failed to install python3-setuptools." + echo "Please check your package sources or consult your system administrator." + fi + - echo "Installing Distutils......................." - sudo apt-get install -y python3-distutils # Install NgVeri Depedencies echo "Installing Pip3............................" sudo apt install -y python3-pip + + # Check if python3-venv is installed, and install if necessary + echo "Checking for python3-venv package..." + if ! dpkg -l | grep -q python3-venv; then + echo "python3-venv not found, installing..." + sudo apt install -y python3-venv + fi + + # Install pipx + echo "Installing pipx............................." + sudo apt install -y pipx + + # Ensure pipx is in PATH + echo "Ensuring pipx is in PATH..." + pipx ensurepath + + # Reload the shell configuration (to ensure PATH is updated) + source ~/.bashrc + + # Prompt user for custom virtual environment location, default to ~/myenv + echo "Enter the desired path for the virtual environment (default: ~/myenv to use default press ENTER): " + read -r VENV_PATH + VENV_PATH=${VENV_PATH:-"$HOME/myenv"} # Default to $HOME/myenv if empty input + + # Check if virtual environment directory already exists + if [ -d "$VENV_PATH" ]; then + echo "Removing existing virtual environment at $VENV_PATH..." + rm -rf $VENV_PATH + fi + # Create a new virtual environment + echo "Creating a new virtual environment at $VENV_PATH..." + python3 -m venv $VENV_PATH + + # Check if the virtual environment was created successfully + if [ ! -f "$VENV_PATH/bin/activate" ]; then + echo "Failed to create virtual environment at $VENV_PATH." + exit 1 + fi + + # Activate the virtual environment + echo "Activating virtual environment..." + source $VENV_PATH/bin/activate + + # Install packages using pipx echo "Installing Watchdog........................" - pip3 install watchdog + pip install watchdog echo "Installing Hdlparse........................" - pip3 install --upgrade https://github.com/hdl/pyhdlparser/tarball/master + pip install https://github.com/hdl/pyhdlparser/tarball/master echo "Installing Makerchip......................." - pip3 install makerchip-app + pip install makerchip-app echo "Installing SandPiper Saas.................." - pip3 install sandpiper-saas - - - echo "Installing Hdlparse......................" - pip3 install hdlparse - - echo "Installing matplotlib................" - pip3 install matplotlib - - echo "Installing PyQt5............." - pip3 install PyQt5 + pip install sandpiper-saas + + echo "alll dependecy install" + + } - function copyKicadLibrary {