From 5713e28d6ff2fcd0e35a73291e1999654dabe27f Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Mon, 7 Aug 2023 12:03:32 -0500 Subject: [PATCH] add --py-ver option to install.sh --- README.md | 1 + install.sh | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/README.md b/README.md index ac64fc0..07c68bb 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ In most cases, running `./install.sh` should be sufficient to install all packag - `--git-ssh`: Use SSH-based URL to clone mirgecom. - `--debug`: Show debugging output of this script (set -x). - `--skip-clone`: Skip cloning mirgecom, assume it will be manually copied to the selected installation prefix. +- `--py-ver=VERSION`: Replace the Python version specified in the conda environment file with `VERSION` (e.g., `--py-ver=3.10`). - `--help`: Print this help text. ## Testing the installation diff --git a/install.sh b/install.sh index 767873e..80fd96b 100755 --- a/install.sh +++ b/install.sh @@ -59,6 +59,8 @@ opt_git_ssh=0 # Skip cloning mirgecom opt_skip_clone=0 +opt_py_ver= + while [[ $# -gt 0 ]]; do arg=$1 shift @@ -110,6 +112,10 @@ while [[ $# -gt 0 ]]; do --skip-clone) opt_skip_clone=1 ;; + --py-ver=*) + # Install this python version instead of the version specified in the conda env file. + opt_py_ver=${arg#*=} + ;; --help) usage exit 0 @@ -159,6 +165,13 @@ echo "==== Create $env_name conda environment" [[ -z $conda_env_file ]] && conda_env_file="$mcsrc/conda-env.yml" +if [[ -n $opt_py_ver ]]; then + echo "=== Overriding Python version with $opt_py_ver" + sed -i.bak "s,- python=3[0-9\.]*,- python=$opt_py_ver," "$conda_env_file" +fi + +cat "$conda_env_file" + mamba env create --name "$env_name" --force --file="$conda_env_file" # Avoid a 'frankenconda' env that uses Python from the base env.