-
Notifications
You must be signed in to change notification settings - Fork 121
/
Makefile
195 lines (175 loc) · 6.09 KB
/
Makefile
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
SHELL = bash
OK_MSG = \x1b[32m ✔\x1b[0m
FAIL_MSG = \x1b[31m ✖\x1b[0m
YELLOW = \x1b[33m
BLUE = \x1b[36m
RED = \x1b[31m
RESET_COLOR = \x1b[0m
ifndef PIPELINEWISE_HOME
PIPELINEWISE_HOME = $(shell pwd)
endif
VENV_DIR = ${PIPELINEWISE_HOME}/.virtualenvs
start_time:=$(shell date +%s)
PIP_ARGS="[test]"
pw_connector=
define ALL_CONNECTORS
tap-github\
tap-jira\
tap-kafka\
tap-mixpanel\
tap-mongodb\
tap-mysql\
tap-postgres\
tap-s3-csv\
tap-salesforce\
tap-slack\
tap-snowflake\
tap-twilio\
tap-zendesk\
target-s3-csv\
target-snowflake\
target-postgres\
transform-field
endef
define print_execute_time
$(eval end_time:=`date +%s`)
@echo
@echo "--------------------------------------------------------------------------"
@echo "$(1) installed successfully in $$(( $(end_time) - $(start_time) )) seconds"
@echo "--------------------------------------------------------------------------"
endef
define clean_connectors
echo -n "Cleaning previous installations in $(VENV_DIR)/$(1)..."
rm -rf $(VENV_DIR)/$(1)
@echo -e "$(OK_MSG)"
endef
define install_connectors
echo
echo "--------------------------------------------------------------------------"
echo "Installing $1 connector..."
echo "--------------------------------------------------------------------------"
if [[ ! -d singer-connectors/$1 ]]; then\
echo "ERROR: Directory not exists and does not look like a valid singer connector: singer-connectors: singer-connectors/$1";\
exit 1;\
fi
$(call make_connector,$1,singer-connectors/$1/)
endef
define make_connector
echo -e -n "$(RED)";
echo " | WARNING. The license of some connectors are different than the default PipelineWise license.";
echo " | Abort this installation if you do not wish to accept";
echo;
@echo -e -n "$(YELLOW)"
@echo -n "Making Virtual Environment for $(1) in $(VENV_DIR)..."
@python3 -m venv $(VENV_DIR)/$(1)
@source $(VENV_DIR)/$(1)/bin/activate
@echo -e "$(OK_MSG)"
@echo -e -n "$(YELLOW)"
@$(VENV_DIR)/$(1)/bin/python3 -m pip install --upgrade pip setuptools wheel
@echo -e "$(RESET_COLOR)"
@echo -n "Python setup tools updated..."
@echo -e "$(OK_MSG)"
@echo -e -n "$(YELLOW)"
@test ! -s $(2)pre_requirements.txt ||\
($(VENV_DIR)/$(1)/bin/python3 -m pip install --use-pep517 --upgrade -r $(2)pre_requirements.txt\
&& echo -e "$(RESET_COLOR)"\
&& echo -n "Pre requirements installed..."\
&& echo -e "$(OK_MSG)")
@echo -e -n "$(YELLOW)"
@test ! -s $(2)requirements.txt ||\
($(VENV_DIR)/$(1)/bin/python3 -m pip install --use-pep517 --upgrade -r $(2)requirements.txt\
&& echo -e "$(RESET_COLOR)"\
&& echo -n "Requirements installed..."\
&& echo -e "$(OK_MSG)")
@echo -e -n "$(RESET_COLOR)"
@test ! -s $(2)setup.py ||\
(echo "Installing the package..."\
&& echo -e "$(YELLOW)"\
&& $(VENV_DIR)/$(1)/bin/python3 -m pip install --use-pep517 --upgrade -e $(2)\
&& echo -e "$(RESET_COLOR)"\
&& echo -n "Package installation completed..."\
&& echo -e "$(OK_MSG)")
@echo -e "$(RESET_COLOR)"
endef
define make_pipelinewise
@echo -e -n "$(YELLOW)"
@echo -n "Making Virtual Environment for $(1) in $(VENV_DIR)..."
@python3 -m venv $(VENV_DIR)/$(1)
@source $(VENV_DIR)/$(1)/bin/activate
@echo -e "$(OK_MSG)"
@echo -e -n "$(YELLOW)"
@$(VENV_DIR)/$(1)/bin/python3 -m pip install --upgrade pip setuptools wheel
@echo -e "$(RESET_COLOR)"
@echo -n "Python setup tools updated..."
@echo -e "$(OK_MSG)"
@echo -e -n "$(YELLOW)"
@echo "Installing the package..."
@echo -e "$(YELLOW)"
@$(VENV_DIR)/$(1)/bin/python3 -m pip install --use-pep517 --upgrade -e $(2)$(PIP_ARGS)
@echo -e "$(RESET_COLOR)"
@echo -n "Package installation completed..."
@echo -e "$(OK_MSG)"
@echo -e "$(RESET_COLOR)"
endef
help: .check_gettext .pw_logo
@echo
@echo " Targets"
@echo " ======="
@echo " pipelinewise Install the main PipelineWise component"
@echo " pipelinewise_no_test_extras Install the main Pipelinewise component without test extras"
@echo
@echo " all_connectors Install all connectors"
@echo " connectors -e pw_connector=connector1,connector2,... Install specific connector(s)"
@echo
@echo " list_all_connectors Show a list of all connectors"
@echo
@echo " Options"
@echo " ======="
@echo " -e pw_connector=connector1,connector2,... Define a list of connectors for installing or cleaning"
@echo
@echo " To start CLI"
@echo " ============"
@echo " $$ source $(VENV_DIR)/pipelinewise/bin/activate"
@echo " $$ export PIPELINEWISE_HOME=$(PIPELINEWISE_HOME)"
@echo " $$ pipelinewise status"
@echo
@echo "--------------------------------------------------------------------------"
pipelinewise: .check_gettext .pw_logo
$(call make_pipelinewise,pipelinewise,.)
$(call print_execute_time,PipelineWise)
pipelinewise_no_test_extras: .set_pip_args pipelinewise
connectors:
ifeq ($(pw_connector),)
@echo "use -e pw_connector=connector1,connector2,...."
@exit 1
endif
$(eval space:= )
$(eval space+= )
$(eval comma:=,)
$(eval connectors_list:=$(subst $(comma),$(space),$(pw_connector)))
@$(foreach var,$(connectors_list), $(call install_connectors,$(var));)
$(call print_execute_time,Connectors)
all_connectors:
@echo "Installing all connectors..."
@$(foreach var,$(ALL_CONNECTORS), $(call install_connectors,$(var));)
$(call print_execute_time,All connectors)
list_all_connectors:
@echo
@echo " ========================"
@echo " Available All Connectors"
@echo " ========================"
@$(foreach var,$(ALL_CONNECTORS), $(call print_list_of_connectors,$(var));)
@echo " ----------------------------"
.pw_logo:
@echo -e "$(BLUE)"
@(CURRENT_YEAR=$(shell date +"%Y") envsubst < motd)
@echo -e "$(RESET_COLOR)"
.check_gettext:
@echo -n "Checking gettext..."
@if ! ENVSUBST_LOC="$$(type -p "envsubst")" || [[ -z ENVSUBST_LOC ]]; then\
echo -e "$(FAIL_MSG)" &&\
echo "envsubst not found but it is required to run this script. Try to install gettext or gettext-base package" && exit 1;\
fi
@echo -e "$(OK_MSG)"
.set_pip_args:
$(eval PIP_ARGS:="")