-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkenv.sh
executable file
·66 lines (53 loc) · 1.13 KB
/
mkenv.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
#!/usr/bin/env bash
set -e
usage() {
cat <<EOF
Usage:
./mkenv.sh [ARGS]
Required arguments -- One and only one of the following:
--name | -n
Name of the environment. Will be installed into
\`\`<conda_installation_dir>/envs/<name>\`\` unless
otherwise specified in \`\`.condarc\`\`.
--prefix | -p
Prefix (directory) for the environment. Will be
installed into the specified directory.
Optional arguments:
--help | -h
Print out usage details.
EOF
}
if [[ "$#" -eq 0 ]]; then
printf "ERROR: Too few arguments passed.\n\n"
usage
exit 1
fi
while [[ "$1" != "" ]]; do
case "$1" in
--help|-h)
usage
exit 0
;;
--name|-n)
shift
NAME="$1"
;;
--prefix|-p)
shift
PREFIX="$1"
;;
*)
printf "ERROR: Unrecognized argument: \"${1}\". Exiting.\n\n"
usage
exit 1
;;
esac
shift
done
if [[ -z "${NAME}" ]]; then
ARGS=( --prefix "${PREFIX}" )
else
ARGS=( --name "${NAME}" )
fi
CMD=$(command -v mamba > /dev/null && echo mamba || echo conda)
"${CMD}" env create --file environment.yaml "${ARGS[@]}"