-
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
Changes from 4 commits
ad9ef4c
da1dc11
0cd21cd
aa497c8
a09cb0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| /tests/**/* linguist-generated=true | ||
| /toolchain/mechanisms/* linguist-generated=true | ||
| *.fpp text eol=lf | ||
| *.f90 text eol=lf | ||
| *.sh text eol=lf | ||
| /tests/**/* linguist-generated=true | ||
| /toolchain/mechanisms/* linguist-generated=true |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,153 @@ | ||||||||||||||||||||||||||||||||||
| #!/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 | ||||||||||||||||||||||||||||||||||
| export DEBIAN_FRONTEND=noninteractive | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| OS="$(uname -s)" | ||||||||||||||||||||||||||||||||||
| echo "Installing dependencies for $OS OS" | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| if command -v sudo >/dev/null 2>&1; then | ||||||||||||||||||||||||||||||||||
| SUDO="sudo" | ||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||
| SUDO="" | ||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # 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." | ||||||||||||||||||||||||||||||||||
| # macOS | ||||||||||||||||||||||||||||||||||
| if [[ "$OSTYPE" == "darwin"* ]]; then | ||||||||||||||||||||||||||||||||||
| echo "Detected macOS." | ||||||||||||||||||||||||||||||||||
| export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH" | ||||||||||||||||||||||||||||||||||
| brew update | ||||||||||||||||||||||||||||||||||
| brew upgrade || true | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Install required packages (mirrors workflow setup) | ||||||||||||||||||||||||||||||||||
| pkgs=(coreutils python fftw hdf5 gcc@15 boost open-mpi lapack cmake protobuf) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| for pkg in "${pkgs[@]}"; do | ||||||||||||||||||||||||||||||||||
| if ! brew list "$pkg" >/dev/null 2>&1; then | ||||||||||||||||||||||||||||||||||
| echo "Installing $pkg..." | ||||||||||||||||||||||||||||||||||
| brew install "$pkg" || brew reinstall "$pkg" | ||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||
| echo "$pkg already installed." | ||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Fix potential linking issues for Homebrew-installed libraries | ||||||||||||||||||||||||||||||||||
| brew link --overwrite python || true | ||||||||||||||||||||||||||||||||||
| brew link --overwrite boost || true | ||||||||||||||||||||||||||||||||||
| brew link --overwrite hdf5 || true | ||||||||||||||||||||||||||||||||||
| brew link --overwrite cmake || true | ||||||||||||||||||||||||||||||||||
| brew link --overwrite protobuf || true | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Environment setup | ||||||||||||||||||||||||||||||||||
| echo "FC=gfortran-15" >> "$GITHUB_ENV" | ||||||||||||||||||||||||||||||||||
| echo "BOOST_INCLUDE=/opt/homebrew/include/" >> "$GITHUB_ENV" | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| echo "macOS dependencies installed successfully." | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Debian/Ubuntu | ||||||||||||||||||||||||||||||||||
| elif [[ -f /etc/debian_version ]]; then | ||||||||||||||||||||||||||||||||||
| echo "Detected Debian/Ubuntu" | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Install all required packages (this time with openmpi and fftw) | ||||||||||||||||||||||||||||||||||
| if [[ "${CI_INTEL:-false}" == "true" ]]; then | ||||||||||||||||||||||||||||||||||
| echo "Intel OneAPI environment detected. Installing Intel compilers and MPI..." | ||||||||||||||||||||||||||||||||||
| wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | ||||||||||||||||||||||||||||||||||
| $SUDO apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
| $SUDO apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | |
| $SUDO install -m 0644 GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB /etc/apt/keyrings/intel-archive-keyring.gpg | |
| echo "deb [signed-by=/etc/apt/keyrings/intel-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | $SUDO tee /etc/apt/sources.list.d/oneapi.list > /dev/null |
Outdated
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: Correct the method for persisting environment variables from setvars.sh in the GitHub Actions environment. Instead of dumping all variables with printenv, capture and append only the variables modified by the script to $GITHUB_ENV. [possible issue, importance: 10]
| source /opt/intel/oneapi/setvars.sh | |
| if [[ -n "${GITHUB_ENV:-}" ]]; then | |
| echo "source /opt/intel/oneapi/setvars.sh" >> "$GITHUB_ENV" | |
| fi | |
| printenv >> "$GITHUB_ENV" | |
| # Create a temporary file to store the environment before sourcing | |
| env > /tmp/env_before | |
| # Source the Intel script to set variables for the current shell | |
| source /opt/intel/oneapi/setvars.sh | |
| # Compare the environment before and after, and append only the new/changed variables to GITHUB_ENV | |
| if [[ -n "${GITHUB_ENV:-}" ]]; then | |
| diff --unchanged-line-format="" --old-line-format="" --new-line-format="%L" <(sort /tmp/env_before) <(env | sort) >> "$GITHUB_ENV" | |
| fi | |
| rm /tmp/env_before |
Outdated
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: Add missing development packages (-devel) to the yum installation list for RedHat/CentOS. The current list lacks headers and libraries for openmpi, fftw, protobuf, and python3, which are required for compilation. [possible issue, importance: 9]
| pkgs="tar wget make cmake3 gcc gcc-c++ python3 openmpi fftw protobuf boost-devel" | |
| $SUDO yum install -y $pkgs | |
| pkgs="tar wget make cmake3 gcc gcc-c++ python3-devel openmpi openmpi-devel fftw fftw-devel protobuf protobuf-devel boost-devel" | |
| $SUDO yum install -y $pkgs |
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.
High-level Suggestion
The
dependency_checkexecutable should be removed from the mainCMakeLists.txtbecause it is only used for CI. Instead, the dependency verification should be handled directly within theinstall_dependencies.shscript. [High-level, importance: 8]Solution Walkthrough:
Before:
After: