-
Notifications
You must be signed in to change notification settings - Fork 14
improved bash scripting for conda setup #72
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 all commits
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 |
|---|---|---|
|
|
@@ -73,6 +73,9 @@ docs/_build/ | |
| # PyBuilder | ||
| target/ | ||
|
|
||
| # Conda | ||
| miniconda.sh | ||
|
|
||
| # Jupyter Notebook | ||
| .ipynb_checkpoints | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| source setup/export_versions.sh | ||
|
|
||
| INSTALL_PREFIX=$HOME/miniconda-$EXP_CONDA_VER | ||
| SOURCE_SCRIPT="$HOME/miniconda-$EXP_CONDA_VER/etc/profile.d/conda.sh" | ||
|
|
||
| source $SOURCE_SCRIPT | ||
| conda activate emissioneval |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,10 @@ | ||
| source setup/export_versions.sh | ||
| CURR_CONDA_VER=`conda --version | cut -d " " -f 2` | ||
| EXP_CONDA_VER=23.1.0 | ||
|
|
||
| if [ $CURR_CONDA_VER == $EXP_CONDA_VER ]; then | ||
| if [[ $CURR_CONDA_VER == $EXP_CONDA_VER ]]; then | ||
| echo "For conda, found $CURR_CONDA_VER, expected $EXP_CONDA_VER, all is good!" | ||
| else | ||
| echo "For conda, found $CURR_CONDA_VER, expected $EXP_CONDA_VER, run 'bash setup/setup_conda.sh $EXP_CONDA_VER <platform>' to get the correct version" | ||
| echo "For conda, found $CURR_CONDA_VER, expected $EXP_CONDA_VER, run 'bash setup/setup_conda.sh <platform>' to get the correct version" | ||
| echo "Or install manually after downloading from https://repo.anaconda.com/miniconda/" | ||
| fi | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export EXP_CONDA_VER=23.1.0 | ||
| export EXP_CONDA_VER_SUFFIX=1 | ||
| export EXP_LIBMAMBA_VER=1.0.0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,10 +5,7 @@ | |
| # - on OSX: /Users/<user>/miniconda3/bin/conda | ||
| # - on Windows: C:/Users/<user>/Miniconda3/Scripts/conda | ||
|
|
||
| set -e | ||
|
|
||
| source setup/checks/check_for_conda.sh | ||
|
|
||
| conda create -n emissioneval | ||
| echo "Installing using conda now" | ||
| conda env update --name emissioneval --file setup/environment.yml | ||
| conda activate emissioneval | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed that you no longer activate right after the setup here. But then I noticed that you do set this up as part of the new I am merging this now to unblock @KG2468, but note that you need to update the README to match |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,48 @@ | ||
| EXP_CONDA_VER=$1 | ||
| PLATFORM=$2 | ||
| echo "Installing for version $EXP_CONDA_VER and platform $PLATFORM" | ||
| if [[ ! -f setup/export_versions.sh ]]; then | ||
| echo "Error: setup/export_versions.sh file is missing. Please ensure it exists before running this script." | ||
| exit 1 | ||
| fi | ||
|
|
||
| source setup/export_versions.sh | ||
| if [[ $? -ne 0 ]]; then | ||
| echo "Error: Failed to source setup/export_versions.sh. Please check the file for errors." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ -z $EXP_CONDA_VER ]]; then | ||
| echo "Error: Requires the EXP_CONDA_VER variable to be set" | ||
| echo "Please check the 'export_versions.sh' script and ensure that it works" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ -z $EXP_CONDA_VER || -z $PLATFORM ]]; then | ||
| echo "Usage: setup_conda.sh <version> <platform>" | ||
| echo " Platform options are Linux-x86_64, MacOSX-x86_64" | ||
| echo " For Windows, manually download and install https://repo.anaconda.com/miniconda/Miniconda3-$EXP_CONDA_VER-Windows-x86_64.exe" | ||
| else | ||
| PLATFORM=$1 | ||
| INSTALL_PREFIX=$2 | ||
|
|
||
| if [[ -z $PLATFORM ]]; then | ||
| echo "Usage: setup_conda.sh <platform> [install_prefix]" | ||
| echo " Platform options are Linux-x86_64, MacOSX-x86_64, MacOSX-arm64" | ||
| WINDOWS_INSTALLER_URL="https://repo.anaconda.com/miniconda/Miniconda3-py39_$EXP_CONDA_VER-$EXP_CONDA_VER_SUFFIX-Windows-x86_64.exe" | ||
| echo " For Windows, manually download and install $WINDOWS_INSTALLER_URL" | ||
| exit 2 | ||
| fi | ||
|
|
||
| if [[ -z $INSTALL_PREFIX ]]; then | ||
| INSTALL_PREFIX=$HOME/miniconda-$EXP_CONDA_VER | ||
| SOURCE_SCRIPT="$HOME/miniconda-$EXP_CONDA_VER/etc/profile.d/conda.sh" | ||
|
|
||
| curl -o miniconda.sh -L https://repo.continuum.io/miniconda/Miniconda3-py39_$EXP_CONDA_VER-1-$PLATFORM.sh; | ||
| bash miniconda.sh -b -p $INSTALL_PREFIX | ||
| source $SOURCE_SCRIPT | ||
| hash -r | ||
| conda config --set always_yes yes --set changeps1 no | ||
| # Useful for debugging any issues with conda | ||
| conda info -a | ||
| echo "Successfully installed at $INSTALL_PREFIX. Please run 'source $SOURCE_SCRIPT' in every terminal where you want to use conda" | ||
| fi | ||
| SOURCE_SCRIPT="$INSTALL_PREFIX/etc/profile.d/conda.sh" | ||
|
|
||
| echo "Installing for version $EXP_CONDA_VER and platform $PLATFORM at $INSTALL_PREFIX" | ||
| curl -o miniconda.sh -L https://repo.anaconda.com/miniconda/Miniconda3-py39_$EXP_CONDA_VER-$EXP_CONDA_VER_SUFFIX-$PLATFORM.sh | ||
| bash miniconda.sh -b -p $INSTALL_PREFIX | ||
| source $SOURCE_SCRIPT | ||
| hash -r | ||
| conda config --set auto_update_conda false | ||
| conda install conda-libmamba-solver=$EXP_CONDA_VER libmamba=$EXP_LIBMAMBA_VER | ||
| conda config --set solver libmamba | ||
| conda config --set always_yes yes | ||
| # Useful for debugging any issues with conda | ||
| conda info -a | ||
| echo "Successfully installed at $INSTALL_PREFIX" | ||
| echo "Please initalize with '$HOME/miniconda-23.1.0/bin/conda init <shell-name>' (bash, zsh, etc.) and restart your terminal" | ||
| echo "Please run 'source setup/setup.sh' to set up the necessary conda environment" | ||
| echo "Please activate with 'source setup/activate_conda.sh' in every terminal where you want to use conda" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1 @@ | ||
| conda activate base | ||
| conda env remove --name emissioneval | ||
| conda deactivate && conda env remove --name emissioneval |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,4 @@ | ||
| EXP_CONDA_VER=$1 | ||
| INSTALL_PREFIX=$HOME/miniconda-$EXP_CONDA_VER | ||
|
|
||
| if [ -z $EXP_CONDA_VER ]; then | ||
| echo "Usage: teardown_conda.sh <version>" | ||
| else | ||
| INSTALL_PREFIX=$HOME/miniconda-$EXP_CONDA_VER | ||
| rm -rf $INSTALL_PREFIX | ||
| fi | ||
| rm -rf $INSTALL_PREFIX |
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.
glad to see that you excluded this!