forked from easybuilders/easybuild-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eb
executable file
·96 lines (81 loc) · 3.22 KB
/
eb
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
##
# Copyright 2009-2020 Ghent University
#
# This file is part of EasyBuild,
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
# with support of Ghent University (http://ugent.be/hpc),
# the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be),
# Flemish Research Foundation (FWO) (http://www.fwo.be/en)
# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en).
#
# https://github.com/easybuilders/easybuild
#
# EasyBuild is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation v2.
#
# EasyBuild is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with EasyBuild. If not, see <http://www.gnu.org/licenses/>.
##
# EasyBuild main script
# check Python version and run easybuild.main script
# @author: Stijn De Weirdt (Ghent University)
# @author: Dries Verdegem (Ghent University)
# @author: Kenneth Hoste (Ghent University)
# @author: Pieter De Baets (Ghent University)
# @author: Jens Timmerman (Ghent University)
# Python 2.6+ or 3.5+ required
REQ_MIN_PY2VER=6
REQ_MIN_PY3VER=5
function verbose() {
if [ ! -z ${EB_VERBOSE} ]; then echo ">> $1"; fi
}
PYTHON=
for python_cmd in ${EB_PYTHON} 'python' 'python3' 'python2'; do
verbose "Considering '$python_cmd'..."
command -v $python_cmd &> /dev/null
if [ $? -eq 0 ]; then
# make sure Python version being used is compatible
pyver=`$python_cmd -V 2>&1 | cut -f2 -d' '`
pyver_maj=`echo $pyver | cut -f1 -d'.'`
pyver_min=`echo $pyver | cut -f2 -d'.'`
if [ $pyver_maj -eq 2 ] && [ $pyver_min -ge $REQ_MIN_PY2VER ]; then
verbose "'$python_cmd' version: $pyver, which matches Python 2 version requirement (>= 2.$REQ_MIN_PY2VER)"
PYTHON=$python_cmd
break
elif [ $pyver_maj -eq 3 ] && [ $pyver_min -ge $REQ_MIN_PY3VER ]; then
verbose "'$python_cmd' version: $pyver, which matches Python 3 version requirement (>= 3.$REQ_MIN_PY3VER)"
PYTHON=$python_cmd
break
fi
else
verbose "No '$python_cmd' found in \$PATH, skipping..."
fi
done
if [ -z $PYTHON ]; then
echo -n "ERROR: No compatible 'python' command found via \$PATH " >&2
echo "(EasyBuild requires Python 2.${REQ_MIN_PY2VER}+ or 3.${REQ_MIN_PY3VER}+)" >&2
exit 1
else
verbose "Selected Python command: $python_cmd (`which $python_cmd`)"
fi
# enable optimization, unless $PYTHONOPTIMIZE is defined (use "export PYTHONOPTIMIZE=0" to disable optimization)
if [ -z $PYTHONOPTIMIZE ]
then
# instruct Python to turn on basic optimizations (equivalent to using 'python -O')
export PYTHONOPTIMIZE=1
fi
if [ -z $FANCYLOGGER_IGNORE_MPI4PY ]
then
# avoid that fancylogger tries to import mpi4py to determine MPI rank
export FANCYLOGGER_IGNORE_MPI4PY=1
fi
export EB_SCRIPT_PATH=$0
verbose "$PYTHON -m easybuild.main `echo \"$@\"`"
$PYTHON -m easybuild.main "$@"