-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathset-env.sh
executable file
·71 lines (59 loc) · 1.87 KB
/
set-env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# get name of the environment by current folder
env_name=${PWD##*/}
# try to activate environment
source activate $env_name > /dev/null 2>&1
# get return code of activation
OUT=$?
# Add R channel
conda config --add channels r > /dev/null 2>&1
# create environment if it does not exist or create is supplied
# this install packages as well
if [[ ($OUT -eq 1) || ($1 == "create") || ($1 == "install") ]]; then
conda env create -n $env_name -f .environment.yml
if [ $? -ne 0 ]; then return; fi
fi
# update packages
if [[ $1 == "update" ]]; then
conda update --all
if [ $? -ne 0 ]; then return; fi
if [ -f requirements.txt ]; then
# Update all pip packages
source activate $env_name >> /dev/null 2>&1
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
fi
# Update requirement files
picky --update
fi
# check the return code of operations
OUT=$?
if [[ ! ($OUT -eq 1) ]]; then
source activate $env_name
# set alias for waf
alias waf="python waf.py -j3"
# Set the default Waf configuration to 'bld'.
export WAFLOCK=.lock-wafbld
# Disable Cudasim
export NUMBA_ENABLE_CUDASIM=0
# Change the Waf configuration for debug mode (adjust as it fits your project).
while [[ $# > 0 ]]
do
key="$1"
case $key in
-d|--debug-cuda)
export WAFLOCK=.lock-wafbld_debug_cuda
export NUMBA_ENABLE_CUDASIM=1
echo -e "\n\n\nUsing debug-cuda setting.\n\nSlooooooow, only use for testing.\n\n\n"
shift
;;
-c|--check-env-via-picky)
picky
;;
*)
echo "Unkown option: " $key
shift
;;
esac
shift
done
fi