forked from transferwise/pipelinewise
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·228 lines (195 loc) · 6.53 KB
/
install.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#!/bin/bash
# Exit script on first error
set -e
# Capture start_time
start_time=`date +%s`
# Source directory defined as location of install.sh
SRC_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# Install pipelinewise venvs in the present working directory
PIPELINEWISE_HOME=$(pwd)
VENV_DIR=${PIPELINEWISE_HOME}/.virtualenvs
check_license() {
python3 -m pip install pip-licenses
echo
echo "Checking license..."
PKG_NAME=`pip-licenses | grep "$1[[:space:]]" | awk '{print $1}'`
PKG_VERSION=`pip-licenses | grep "$1[[:space:]]" | awk '{print $2}'`
PKG_LICENSE=`pip-licenses --from mixed | grep "$1[[:space:]]" | awk '{for (i=1; i<=NF-2; i++) $i = $(i+2); NF-=2; print}'`
# Any License Agreement that is not Apache Software License (2.0) has to be accepted
MAIN_LICENSE="Apache Software License"
if [[ $PKG_LICENSE != $MAIN_LICENSE && $PKG_LICENSE != 'UNKNOWN' ]]; then
echo
echo " | $PKG_NAME ($PKG_VERSION) is licensed under $PKG_LICENSE"
echo " |"
echo " | WARNING. The license of this connector is different than the default PipelineWise license ($MAIN_LICENSE)."
if [[ $ACCEPT_LICENSES != "YES" ]]; then
echo " | You need to accept the connector's license agreement to proceed."
echo " |"
read -r -p " | Do you accept the [$PKG_LICENSE] license agreement of $PKG_NAME connector? [y/N] " response
case "$response" in
[yY][eE][sS]|[yY])
;;
*)
echo
echo "EXIT. License agreement not accepted"
exit 1
;;
esac
else
echo " | You automatically accepted this license agreement by running this script with --acceptlicenses option."
fi
fi
}
clean_virtualenvs() {
echo "Cleaning previous installations in $VENV_DIR"
rm -rf $VENV_DIR
}
make_virtualenv() {
echo "Making Virtual Environment for [$1] in $VENV_DIR"
python3 -m venv $VENV_DIR/$1
source $VENV_DIR/$1/bin/activate
python3 -m pip install --upgrade pip setuptools
if [ -f "requirements.txt" ]; then
python3 -m pip install -r requirements.txt
fi
if [ -f "setup.py" ]; then
PIP_ARGS=
if [[ ! $NO_TEST_EXTRAS == "YES" ]]; then
PIP_ARGS=$PIP_ARGS"[test]"
fi
python3 -m pip install -e .$PIP_ARGS
fi
echo ""
echo "===== Checking dependencies for conflict ..."
python3 -m pip check && echo "No conflicts" || exit 1
check_license $1
deactivate
}
install_connector() {
echo
echo "--------------------------------------------------------------------------"
echo "Installing $1 connector..."
echo "--------------------------------------------------------------------------"
CONNECTOR_DIR=$SRC_DIR/singer-connectors/$1
if [[ ! -d $CONNECTOR_DIR ]]; then
echo "ERROR: Directory not exists and does not look like a valid singer connector: $CONNECTOR_DIR"
exit 1
fi
cd $CONNECTOR_DIR
make_virtualenv $1
}
print_installed_connectors() {
cd $SRC_DIR
echo
echo "--------------------------------------------------------------------------"
echo "Installed components:"
echo "--------------------------------------------------------------------------"
echo
echo "Component Version"
echo "-------------------- -------"
for i in `ls $VENV_DIR`; do
source $VENV_DIR/$i/bin/activate
VERSION=`python3 -m pip list | grep "$i[[:space:]]" | awk '{print $2}'`
printf "%-20s %s\n" $i "$VERSION"
done
if [[ $CONNECTORS != "all" ]]; then
echo
echo "WARNING: Not every singer connector installed. If you are missing something use the --connectors=...,... argument"
echo " with an explicit list of required connectors or use the --connectors=all to install every available"
echo " connector"
fi
}
# Parse command line arguments
for arg in "$@"; do
case $arg in
# Auto accept license agreemnets. Useful if PipelineWise installed by an automated script
--acceptlicenses)
ACCEPT_LICENSES="YES"
;;
# Do not print usage information at the end of the install
--nousage)
NO_USAGE="YES"
;;
# Install with test requirements that allows running tests
--notestextras)
NO_TEST_EXTRAS="YES"
;;
# Install extra connectors
--connectors=*)
CONNECTORS="${arg#*=}"
shift
;;
# Clean previous installation
--clean)
clean_virtualenvs
exit 0
;;
*)
echo "Invalid argument: $arg"
exit 1
;;
esac
done
# Welcome message
cat $SRC_DIR/motd
# Install PipelineWise core components
cd $SRC_DIR
make_virtualenv pipelinewise
# Set default and extra singer connectors
DEFAULT_CONNECTORS=(
tap-jira
tap-kafka
tap-mysql
tap-postgres
tap-s3-csv
tap-salesforce
tap-snowflake
tap-zendesk
target-s3-csv
target-snowflake
target-redshift
transform-field
)
EXTRA_CONNECTORS=(
tap-adwords
tap-oracle
target-postgres
)
# Install only the default connectors if --connectors argument not passed
if [[ -z $CONNECTORS ]]; then
for i in ${DEFAULT_CONNECTORS[@]}; do
install_connector $i
done
# Install every avaliable connectors if --connectors=all passed
elif [[ $CONNECTORS == "all" ]]; then
for i in ${DEFAULT_CONNECTORS[@]}; do
install_connector $i
done
for i in ${EXTRA_CONNECTORS[@]}; do
install_connector $i
done
# Install the selected connectors if --connectors argument passed
elif [[ ! -z $CONNECTORS ]]; then
OLDIFS=$IFS
IFS=,
for connector in $CONNECTORS; do
install_connector $connector
done
IFS=$OLDIFS
fi
# Capture end_time
end_time=`date +%s`
echo
echo "--------------------------------------------------------------------------"
echo "PipelineWise installed successfully in $((end_time-start_time)) seconds"
echo "--------------------------------------------------------------------------"
print_installed_connectors
if [[ $NO_USAGE != "YES" ]]; then
echo
echo "To start CLI:"
echo " $ source $VENV_DIR/pipelinewise/bin/activate"
echo " $ export PIPELINEWISE_HOME=$PIPELINEWISE_HOME"
echo " $ pipelinewise status"
echo
echo "--------------------------------------------------------------------------"
fi