Skip to content

Commit

Permalink
use mktemp in conda-update script, refactor out into contrib and have…
Browse files Browse the repository at this point in the history
… post-merge and post-checkout call the script
  • Loading branch information
tomkinsc committed Sep 22, 2016
1 parent 966f608 commit f21eba9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 24 deletions.
25 changes: 1 addition & 24 deletions contrib/post-checkout
@@ -1,26 +1,3 @@
#!/bin/bash

function cmd_exists() {
if hash $@ 2> /dev/null ; then
return 0
else
return 1
fi
}

# if conda is available
if cmd_exists "conda"; then
# if a conda environment is active
if [ ! -z "$CONDA_DEFAULT_ENV" ]; then
# update the conda environment to install the requirements specified
if [ "$(uname)" == "Darwin" ]; then
# some conda packages dont exist on OSX
cat requirements-conda.txt | grep -v kraken > /tmp/requirements-conda.txt
else
# for linux, just use requirements-conda as-is
cp requirements-conda.txt /tmp/requirements-conda.txt
fi

conda install -y -c bioconda --file /tmp/requirements-conda.txt
fi
fi
./contrib/update-conda-env.sh
3 changes: 3 additions & 0 deletions contrib/post-merge
@@ -0,0 +1,3 @@
#!/bin/bash

./contrib/update-conda-env.sh
Empty file modified contrib/pre-commit 100644 → 100755
Empty file.
29 changes: 29 additions & 0 deletions contrib/update-conda-env.sh
@@ -0,0 +1,29 @@
#!/bin/bash

function cmd_exists() {
if hash $@ 2> /dev/null ; then
return 0
else
return 1
fi
}

requirements_file="$(mktemp -t requirements-conda.txt)"

# if conda is available
if cmd_exists "conda"; then
# if a conda environment is active
if [ ! -z "$CONDA_DEFAULT_ENV" ]; then
# update the conda environment to install the requirements specified
if [ "$(uname)" == "Darwin" ]; then
# some conda packages dont exist on OSX
cat requirements-conda.txt | grep -v kraken > "$requirements_file"
else
# for linux, just use requirements-conda as-is
cp requirements-conda.txt "$requirements_file"
fi

conda install -y -c bioconda --file "$requirements_file"
rm "$requirements_file"
fi
fi

0 comments on commit f21eba9

Please sign in to comment.