- 
                Notifications
    
You must be signed in to change notification settings  - Fork 121
 
Dependency installer for macOS, Debian/Ubuntu, and RedHat/CentOS #1017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Closed
      
      
            Aadharsh-Rajkumar
  wants to merge
  5
  commits into
  MFlowCode:master
from
Aadharsh-Rajkumar:ci-build-script
  
      
      
   
      
    
  
     Closed
                    Changes from 2 commits
      Commits
    
    
            Show all changes
          
          
            5 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      ad9ef4c
              
                dependency installer for macOS, Debian/Ubuntu, and RedHat/CentOS
              
              
                Aadharsh-Rajkumar da1dc11
              
                dependency installer for macOS, Debian/Ubuntu, and RedHat/CentOS
              
              
                Aadharsh-Rajkumar 0cd21cd
              
                Add dependency installation script and integrate into CI workflow
              
              
                Aadharsh-Rajkumar aa497c8
              
                Add .gitattributes to enforce LF line endings
              
              
                Aadharsh-Rajkumar a09cb0e
              
                undid past commit, added boost compile check and secure OneAPI keys, …
              
              
                Aadharsh-Rajkumar File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,101 @@ | ||||||||||||||||||||||||||||||
| #!/bin/bash | ||||||||||||||||||||||||||||||
| # A solution for consolidating dependency installation commands for different operating systems (for macOS, Debian/Ubuntu, RedHat/CentOS) | ||||||||||||||||||||||||||||||
| # Allows minimal repetition in command installations in multiple CI workflow files. | ||||||||||||||||||||||||||||||
| # CI logs on which commands are being run. | ||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||
| # Instructions: | ||||||||||||||||||||||||||||||
| # 1. Run this command: chmod +x ./scripts/install_dependencies.sh | ||||||||||||||||||||||||||||||
| # 2. Run the installer: ./scripts/install_dependencies.sh | ||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||
| set -x | ||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||
| OS="$(uname -s)" | ||||||||||||||||||||||||||||||
| echo "Installing dependencies for $OS OS" | ||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||
| # macOS | ||||||||||||||||||||||||||||||
| if [[ "$OSTYPE" == "darwin"* ]]; then | ||||||||||||||||||||||||||||||
| # Use Homebrew for macOS package management | ||||||||||||||||||||||||||||||
| echo "Detected macOS." | ||||||||||||||||||||||||||||||
| export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH" | ||||||||||||||||||||||||||||||
| brew update | ||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||
| # Packages to install | ||||||||||||||||||||||||||||||
| declare -A packages | ||||||||||||||||||||||||||||||
| packages=( | ||||||||||||||||||||||||||||||
| ["cmake"]="cmake" | ||||||||||||||||||||||||||||||
| ["gcc"]="gcc" | ||||||||||||||||||||||||||||||
| ["python3"]="[email protected]" | ||||||||||||||||||||||||||||||
| ["boost"]="boost" | ||||||||||||||||||||||||||||||
| ["protobuf"]="protobuf" | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||
| # Install missing packages | ||||||||||||||||||||||||||||||
| for exe in "${!packages[@]}"; do | ||||||||||||||||||||||||||||||
| formula="${packages[$exe]}" | ||||||||||||||||||||||||||||||
| if ! command -v "$exe" >/dev/null 2>&1; then | ||||||||||||||||||||||||||||||
| echo "Installing $formula..." | ||||||||||||||||||||||||||||||
| brew install --verbose "$formula" | ||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||
| echo "$exe already installed" | ||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||
| # Verification | ||||||||||||||||||||||||||||||
| echo "Verifying installations..." | ||||||||||||||||||||||||||||||
| which cmake; cmake --version | ||||||||||||||||||||||||||||||
| which gcc; gcc --version | ||||||||||||||||||||||||||||||
| which python3; python3 --version | ||||||||||||||||||||||||||||||
| brew list boost || echo "boost not found" | ||||||||||||||||||||||||||||||
| brew list protobuf || echo "protobuf not found" | ||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||
| echo "macOS dependencies installed successfully." | ||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||
| # Debian/Ubuntu | ||||||||||||||||||||||||||||||
| elif [[ -f /etc/debian_version ]]; then | ||||||||||||||||||||||||||||||
| echo "Detected Debian/Ubuntu" | ||||||||||||||||||||||||||||||
| sudo apt-get update -y | ||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||
| # Install all required packages (this time with openmpi and fftw) | ||||||||||||||||||||||||||||||
| pkgs="tar wget make cmake gcc g++ python3 python3-dev openmpi-bin libopenmpi-dev fftw3 libfftw3-dev protobuf-compiler libboost-all-dev" | ||||||||||||||||||||||||||||||
| sudo apt-get install -y $pkgs | ||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||
| # Verification | ||||||||||||||||||||||||||||||
| echo "Verifying installations..." | ||||||||||||||||||||||||||||||
| cmake --version || echo "cmake not found" | ||||||||||||||||||||||||||||||
| gcc --version || echo "gcc not found" | ||||||||||||||||||||||||||||||
| python3 --version || echo "python3 not found" | ||||||||||||||||||||||||||||||
| mpirun --version || echo "mpirun not found" | ||||||||||||||||||||||||||||||
| ldconfig -p | grep -q libfftw3 || echo "FFTW library not found" | ||||||||||||||||||||||||||||||
                
       | 
||||||||||||||||||||||||||||||
| # Verification | |
| echo "Verifying installations..." | |
| cmake --version || echo "cmake not found" | |
| gcc --version || echo "gcc not found" | |
| python3 --version || echo "python3 not found" | |
| mpirun --version || echo "mpirun not found" | |
| ldconfig -p | grep -q libfftw3 || echo "FFTW library not found" | |
| # Verification | |
| echo "Verifying installations..." | |
| if ! cmake --version; then echo "cmake not found"; fi | |
| if ! gcc --version; then echo "gcc not found"; fi | |
| if ! python3 --version; then echo "python3 not found"; fi | |
| if ! mpirun --version; then echo "mpirun not found"; fi | |
| if ! ldconfig -p | grep -q libfftw3; then echo "FFTW library not found"; fi | 
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Suggestion: Modify the macOS package check to use
brew listinstead ofcommand -v. This correctly detects installed Homebrew libraries likeboostandprotobuf, preventing unnecessary reinstallations. [possible issue, importance: 8]