-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
setup.csh
executable file
·101 lines (83 loc) · 3.55 KB
/
setup.csh
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
97
98
99
100
101
#!/bin/csh
# MIT License
# Copyright (c) 2021-2024, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory (subject to receipt of
# any required approvals from the U.S. Dept. of Energy), Shahzeb Siddiqui,
# and Vanessa Sochat. All rights reserved.
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
# Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# Get the name of the current shell
set shell_name = `ps -p $$ -o comm=`
# if shell is not csh or tcsh exit
if (`basename $shell_name` != "csh" && `basename $shell_name` != "tcsh") then
echo "Unsupported shell, please use 'csh' or 'tcsh' when sourcing this script"
exit 1
endif
# if BUILDTEST_ROOT not defined in current shell set, figure out directory path for
# sourced script (setup.csh) and set BUILDTEST_ROOT
if (! $?BUILDTEST_ROOT) then
# figure out a command to list open files (Linux)
if (-d /proc/$$/fd) then
set _open_fd = "ls -l /proc/$$/fd"
# for Mac
else
which lsof > /dev/null
if ($? == 0) then
set _open_fd = "lsof -p $$"
endif
endif
# filter list of open files
if ( $?_open_fd ) then
set _source_file = `$_open_fd | sed -e 's/^[^/]*//' | grep "/setup.csh"`
endif
# setup.csh is located in $BUILDTEST_ROOT
if ( $?_source_file ) then
setenv BUILDTEST_ROOT `dirname "$_source_file"`
endif
if (! $?BUILDTEST_ROOT) then
echo "Cannot set $BUILDTEST_ROOT based on path to setup.csh."
echo "Try setting BUILDTEST_ROOT to root of buildtest repo and try again."
exit 1
endif
endif
set python=python3
# install pip in user environment
curl https://bootstrap.pypa.io/get-pip.py | $python
set pip=pip3
if ( ! -x `which $pip` ) then
# If not found in PATH, check $HOME/.local/bin
if ( -x "$HOME/.local/bin/$pip" ) then
echo "$pip found in $HOME/.local/bin"
# Optionally, you can add $HOME/.local/bin to PATH
setenv PATH $HOME/.local/bin:$PATH
else
echo "cannot find program $pip. Please see the pip documentation: https://pip.pypa.io/en/stable/installation/ on how to install pip"
exit 1
endif
endif
$python -c "import buildtest.main" >& /dev/null
# if we unable to import buildtest.main module then install buildtest dependencies
if ( $status != 0 ) then
#$pip install -r ${BUILDTEST_ROOT}/requirements.txt >& /dev/null
$pip install "${BUILDTEST_ROOT}/." >& /dev/null
endif
set path=($path ${BUILDTEST_ROOT}/bin)
# add PYTHONPATH for buildtest to persist in shell environment
if (! $?PYTHONPATH ) then
setenv PYTHONPATH $BUILDTEST_ROOT
else
setenv PYTHONPATH ${PYTHONPATH}:$BUILDTEST_ROOT
endif