forked from phac-nml/slurm-rest-api
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
96 lines (81 loc) · 2.88 KB
/
build.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
# Script arguments
while [ $# -gt 0 ]; do
case "$1" in
--help)
help=1
;;
--pyslurm_version=*)
pyslurm_version="${1#*=}"
;;
--pyslurm_arguments=*)
pyslurm_arguments="${1#*=}"
;;
*)
echo "** Invalid Argument **"
exit 1
esac
shift
done
# Display help and exit
if [ "$help" ]
then
echo "Slurm-rest-api build.sh"
echo "Usage:"
echo " bash build.sh [option]=[param] [option]=[param] ..."
echo "options:"
echo " --help Shows this help page."
echo " --pyslurm_version Use a specific version of pyslurm. Defaults to use the pypi version 17.11.0 via pip"
echo " --pyslurm_arguments PySlurm build arguments for installation. See github.com/Pyslurm/pyslurm for more information on available arguments. --pyslurm_version must be set to use additional pyslurm arguments."
echo ""
echo "example: Build for slurm version 18.08.0 by using 18.08.0 and"
echo ' bash build.sh --pyslurm_version="18.08.0"'
echo ""
exit 0
fi
# Clean up from any previous build
echo "Removing conda environment if it exists"
conda env remove --prefix env --yes
# rc=$?; if [[ $rc != 0 ]]; then echo "error: slurm-rest-api could not create a conda environment. Do you have conda installed?"; exit $rc; fi
echo "Removing pyslurm install if exists in directory"
rm -rf pyslurm-install/
# Setup a fresh environment to install into
echo "Creating conda environment"
conda create --prefix env python=2.7 --yes
rc=$?; if [[ $rc != 0 ]]; then echo "error: slurm-rest-api could not create a conda environment. Do you have conda installed?"; exit $rc; fi
echo "Activating conda environment"
source activate env/
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
echo ""
if [ "$pyslurm_version" ]; then
echo "Downloading conda dependencies"
conda install git mysql cython --yes
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
echo ""
echo "Downloading pyslurm"
mkdir pyslurm-install
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
cd pyslurm-install
git clone https://github.com/PySlurm/pyslurm.git
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
cd pyslurm
git checkout $pyslurm_version
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
python setup.py build $pyslurm_arguments
rc=$?; if [[ $rc != 0 ]]; then echo "error: slurm-rest-api failed to build pyslurm."; exit $rc; fi
pip install .
rc=$?; if [[ $rc != 0 ]]; then echo "error: slurm-rest-api failed to install pyslurm"; exit $rc; fi
cd ..
cd ..
else
echo "Downloading conda dependencies"
# Installing it this way might be broken, needs further testing.
# It might need to import gcc and/or cython
conda install mysql --yes
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
fi
echo ""
echo "Installing slurm-rest-api via pip"
pip install -e .
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
echo "Slurm-rest-api successfully installed!"