Skip to content

Commit

Permalink
Upgrade the setup scripts to support multiple instances of miniconda … (
Browse files Browse the repository at this point in the history
e-mission#756)

* Upgrade the setup scripts to support multiple instances of miniconda at the same time

* Pull out the version dependency into a separate file

Create a new activate script
Use the version dependency in both setup and activate

* More refactoring of the activation code

- There is now a separate conda activation script to be called before we have
  set anything up
- Both the regular and test setup scripts call conda activate
- Setup conda is refactored again to read the expected version from the exports
  file instead having it be passed in.
    - Having it be passed in would require the version to be read in the workflow file and this seems like a cleaner solution
- Fix the check script to account for the changed arguments as well
  • Loading branch information
shankari authored Aug 2, 2020
1 parent 6425b1a commit ebb5cb8
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 21 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/osx-ubuntu-manual-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ jobs:
shell: bash -l {0}
run: |
source setup/setup_conda.sh ${{ matrix.PLATFORM }}
- name: Check whether the environment is setup properly
shell: bash -l {0}
run: |
source setup/activate_conda.sh
if [ ${{ matrix.PLATFORM }} == "Linux-x86_64" ]; then
echo "Linux install, going to check conda path"
which conda
Expand All @@ -47,19 +52,14 @@ jobs:
echo " since 'which conda' inexplicably returns with status code 1"
echo " only in the CI environment"
fi
- name: Check whether the CI environment variable is set
shell: bash -l {0}
run: |
source "$HOME/miniconda/etc/profile.d/conda.sh"
echo $CI
- name: Setup the emission environment
shell: bash -l {0}
run: |
conda --version
which conda
source "$HOME/miniconda/etc/profile.d/conda.sh"
source setup/activate_conda.sh
conda --version
source setup/setup.sh
echo "About to activate environment"
Expand All @@ -69,5 +69,5 @@ jobs:
- name: Teardown the emission environment
shell: bash -l {0}
run: |
source "$HOME/miniconda/etc/profile.d/conda.sh"
source setup/activate_conda.sh
source setup/teardown.sh
8 changes: 3 additions & 5 deletions .github/workflows/test-with-manual-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,27 @@ jobs:
shell: bash -l {0}
run: |
source setup/setup_conda.sh Linux-x86_64
which conda
- name: Check whether the CI environment variable is set
shell: bash -l {0}
run: |
source "$HOME/miniconda/etc/profile.d/conda.sh"
source setup/activate_conda.sh
echo $CI
- name: Setup the emission environment for testing
shell: bash -l {0}
run: |
conda --version
which conda
source "$HOME/miniconda/etc/profile.d/conda.sh"
source setup/activate_conda.sh
conda --version
source setup/setup_tests.sh
- name: Switch to emission and run the tests
shell: bash -l {0}
run: |
source "$HOME/miniconda/etc/profile.d/conda.sh"
source setup/activate_tests.sh
conda --version
conda activate emissiontest
./runAllTests.sh
- name: Teardown the test environment
Expand Down
2 changes: 2 additions & 0 deletions setup/activate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
source setup/activate_conda.sh
conda activate emission
6 changes: 6 additions & 0 deletions setup/activate_conda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
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
2 changes: 2 additions & 0 deletions setup/activate_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
source setup/activate_conda.sh
conda activate emissiontest
5 changes: 3 additions & 2 deletions setup/checks/check_for_conda.sh
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=4.5.12

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' 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

1 change: 1 addition & 0 deletions setup/export_versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export EXP_CONDA_VER=4.5.12
17 changes: 11 additions & 6 deletions setup/setup_conda.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
EXP_CONDA_VER=4.5.12
source setup/export_versions.sh

PLATFORM=$1
echo "Installing for platform $PLATFORM"
echo "Installing for version $EXP_CONDA_VER and platform $PLATFORM"

if [ -z $PLATFORM ]; then
if [[ -z $EXP_CONDA_VER || -z $PLATFORM ]]; then
echo "Usage: setup_conda.sh <platform>"
echo " Assumes that the EXP_CONDA_VER variable is set"
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
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-$EXP_CONDA_VER-$PLATFORM.sh;
bash miniconda.sh -b -p $HOME/miniconda
source "$HOME/miniconda/etc/profile.d/conda.sh"
bash miniconda.sh -b -p $INSTALL_PREFIX
source $SOURCE_SCRIPT
hash -r
conda config --set always_yes yes --set changeps1 no
conda config --set always_yes yes
# Useful for debugging any issues with conda
conda info -a
echo "Successfully installed at $INSTALL_PREFIX. Please activate with 'source setup/activateXXX.sh' in every terminal where you want to use conda"
fi
5 changes: 4 additions & 1 deletion setup/teardown_conda.sh
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
rm -rf $HOME/miniconda
EXP_CONDA_VER=$1
INSTALL_PREFIX=$HOME/miniconda-$EXP_CONDA_VER

rm -rf $INSTALL_PREFIX

0 comments on commit ebb5cb8

Please sign in to comment.