-
Notifications
You must be signed in to change notification settings - Fork 55
/
Makefile
350 lines (315 loc) · 12.5 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
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
################################################################################
# #
# Cisco Systems Proprietary Software #
# Not to be distributed without consent from Test Technology #
# Cisco Systems, Inc. #
# #
################################################################################
# Genie Libs Makefile
#
# Author:
# Siming Yuan ([email protected]) - CSG
# Jean-Benoit Aubin ([email protected]) - CSG
#
# Support:
#
# Version:
# v2.1
#
# Date:
# April 2018
#
# About This File:
# This script will build individual Genie libs modules into Python PyPI packages.
# Make sure all requirements are met before adding new package names to
# PACKAGES variable.
#
# Requirements:
# 1. Module name is the same as package name.
# 2. setup.py file is stored within the module folder
################################################################################
# Variables
BUILD_DIR = $(shell pwd)/__build__
DIST_DIR = $(BUILD_DIR)/dist
BUILD_CMD = python3 setup.py bdist_wheel --dist-dir=$(DIST_DIR)
TESTCMD = runAll
WATCHERS = [email protected]
HEADER = [Watchdog]
PYPIREPO = pypitest
PYTHON = python3
PYLINT_CMD = pylintAll
CYTHON_CMD = compileAll
# Development pkg requirements
RELATED_PKGS = genie.libs.health genie.libs.clean genie.libs.conf genie.libs.ops genie.libs.robot genie.libs.sdk
RELATED_PKGS += genie.libs.filetransferutils
# Adding pyasyncore pkg to fix pysnmp scripts for python 3.12
DEPENDENCIES = restview psutil Sphinx wheel asynctest 'pysnmp>=6.1.4,<6.2' pyasn1==0.4.8
DEPENDENCIES += sphinx-rtd-theme==1.1.0 pyftpdlib tftpy\<0.8.1 robotframework
DEPENDENCIES += Cython==3.0.0 requests ruamel.yaml grpcio protobuf jinja2
# Internal variables.
# (note - build examples & templates last because it will fail uploading to pypi
# due to duplicates, and we'll for now accept that error)
DEV_PKGS = develop-health develop-clean develop-conf develop-ops develop-robot develop-sdk develop-filetransferutils
UNDEV_PKGS = undevelop-health undevelop-clean undevelop-conf undevelop-ops undevelop-robot undevelop-sdk undevelop-filetransferutils
PYPI_PKGS = health-pkg clean-pkg conf-pkg ops-pkg robot-pkg sdk-pkg filetransferutils-pkg
ALL_PKGS = $(PYPI_PKGS)
.PHONY: help docs distribute_docs clean check devnet\
develop undevelop distribute distribute_staging distribute_staging_external\
test install_build_deps uninstall_build_deps $(ALL_PKGS) $(DEV_PKGS)
test install_build_deps uninstall_build_deps $(ALL_PKGS) $(DEV_PKGS)
$(UNDEV_PKGS)
help:
@echo "Please use 'make <target>' where <target> is one of"
@echo ""
@echo " --- common actions ---"
@echo ""
@echo " check check setup.py content"
@echo " clean remove the build directory ($(BUILD_DIR))"
@echo " help display this help"
@echo " test run all unittests in an efficient manner"
@echo " develop set all package to development mode"
@echo " undevelop unset the above development mode"
@echo " devnet Build DevNet package."
@echo " install_build_deps install pyats-distutils"
@echo " uninstall_build_deps remove pyats-distutils"
@echo " compile Compile all python modules to c"
@echo " coverage_all Run code coverage on all test files"
@echo " pylint_all Run python linter on all python modules"
@echo " json Build json files"
@echo " changelogs Build compiled changelog file"
@echo ""
@echo " --- build all targets ---"
@echo ""
@echo " all make all available pyATS packages"
@echo ""
@echo " --- build specific targets ---"
@echo ""
@echo " health-pkg build genie.libs.health package"
@echo " clean-pkg build genie.libs.clean package"
@echo " conf-pkg build genie.libs.conf package"
@echo " ops-pkg build genie.libs.ops package"
@echo " sdk-pkg build genie.libs.sdk package"
@echo " robot build genie.libs.robot package"
@echo " filetransferutils-pkg build genie.libs.filetransferutils package"
@echo ""
@echo " --- distributions to production environment ---"
@echo ""
@echo " distribute distribute built pkgs to production"
@echo " server"
@echo " distribute_staging distribute build pkgs to staging area"
@echo " distribute_staging_external distribute build pkgs to external"
@echo " staging area"
@echo ""
@echo " --- redirects ---"
@echo " docs create all documentation locally. This the same as"
@echo " running 'make docs' in ./docs/"
@echo " distribute_docs release local documentation to website. This is"
@echo " the same as running 'make distribute' in ./docs/"
@echo ""
@echo " --- build arguments ---"
@echo " DEVNET=true build for devnet style (cythonized, no ut)"
@echo " INCLUDE_TESTS=true build include unittests in cythonized pkgs"
compile:
@echo ""
@echo "Compiling to C code"
@echo --------------------------
@pip install cisco-distutils --upgrade || true
@$(CYTHON_CMD) --exclude *iosxe/ip_precedence/verify.py *iosxe/udp/get.py
@echo "Done Compiling"
@echo ""
@echo "Done."
@echo ""
coverage_all:
@echo ""
@echo "Running code coverage on all unittests"
@echo ---------------------------------------
@$(TESTCMD) --path tests/ --coverage --no-refresh
@echo ""
@echo "Done."
@echo ""
pylint_all:
@echo ""
@echo "Running Pylint on all modules"
@echo "-----------------------------"
@$(PYLINT_CMD)
@echo "Done linting"
@echo ""
@echo "Done."
@echo ""
devnet: all
@echo "Completed building DevNet packages"
@echo ""
install_build_deps:
@pip install --upgrade pip setuptools wheel
uninstall_build_deps:
@echo "nothing to do"
dependencies:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Installing development dependencies"
@pip install $(DEPENDENCIES)
@echo "Done."
@echo ""
docs:
@echo "No documentation to build for genie.libs"
clean:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Removing make directory: $(BUILD_DIR)"
@rm -rf $(BUILD_DIR)
@$(foreach dir,$(ALL_PKGS),(cd pkgs/$(dir) && python3 setup.py clean) &&) :
@echo "Removing *.pyc *.c and __pycache__/ files"
@find . -type f -name "*.pyc" | xargs rm -vrf
@find . -type f -name "*.c" | xargs rm -vrf
@find . -type d -name "__pycache__" | xargs rm -vrf
@find . -type d -name "build" | xargs rm -vrf
@echo ""
@echo "Done."
@echo ""
develop:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Installing development dependencies"
# workaround for Polaris SDK
@if [ $BINOS_ATESTS ]; \
then pip install $(DEPENDENCIES) --ignore-installed docutils; \
else pip install $(DEPENDENCIES); \
fi
@pip uninstall -y $(RELATED_PKGS) || true
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Setting up development environment"
@$(foreach dir,$(ALL_PKGS),(cd pkgs/$(dir) && python3 setup.py develop --no-deps -q) &&) :
@echo ""
@echo "Done."
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Development environment has been setup."
@echo -e "\e[1;33mWarning: Do make json to generate json files to acccess the genie features!!!\e[0m"
@echo "--------------------------------------------------------------------"
undevelop:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Removing development environment"
@$(foreach dir,$(ALL_PKGS),(cd pkgs/$(dir) && python3 setup.py develop -q --no-deps --uninstall) &&) :
@echo ""
@echo "Done."
@echo ""
$(DEV_PKGS):
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Setting up development environment"
@pip uninstall -y $(subst develop-,,genie.libs.$@) || true
@cd $(subst develop-,,pkgs/$@-pkg) && python setup.py develop -q --no-deps
@echo ""
@echo "Done."
@echo ""
$(UNDEV_PKGS):
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Removing development environment"
@cd $(subst undevelop-,,pkgs/$@-pkg) && python setup.py develop -q --no-deps --uninstall
@echo ""
@echo "Done."
@echo ""
distribute:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Copying all distributable to $(PROD_PKGS)"
@test -d $(DIST_DIR) || { echo "Nothing to distribute! Exiting..."; exit 1; }
@echo "Organizing distributable into folders"
@organize_dist --dist $(DIST_DIR)
@rsync -rtlv --progress $(DIST_DIR)/* $(PROD_USER):$(PROD_PKGS)
@echo ""
@echo "Done."
@echo ""
distribute_staging:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Copying all distributable to $(STAGING_PKGS)"
@test -d $(DIST_DIR) || { echo "Nothing to distribute! Exiting..."; exit 1; }
@echo "Organizing distributable into folders"
@organize_dist --dist $(DIST_DIR)
@rsync -rtlv --progress $(DIST_DIR)/* $(PROD_USER):$(STAGING_PKGS)
@echo ""
@echo "Done."
@echo ""
distribute_staging_external:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Copying all distributable to $(STAGING_EXT_PKGS)"
@test -d $(DIST_DIR) || { echo "Nothing to distribute! Exiting..."; exit 1; }
@echo "Organizing distributable into folders"
@organize_dist --dist $(DIST_DIR)
@rsync -rtlv --progress $(DIST_DIR)/* $(PROD_USER):$(STAGING_EXT_PKGS)
@echo ""
@echo "Done."
@echo ""
all: $(ALL_PKGS)
@echo ""
@echo "Done."
@echo ""
package: $(ALL_PKGS)
@echo ""
@echo "Done."
@echo ""
$(ALL_PKGS):
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Building pyATS distributable: $@"
@echo ""
cd pkgs/$@/; $(BUILD_CMD)
@echo "Completed building: $@"
@echo ""
@echo "Done."
@echo ""
test:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Running all unit tests..."
@echo ""
@$(TESTCMD) --path tests/
@echo "Completed unit testing"
@echo ""
@echo "Done."
@echo ""
check:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Checking setup.py consistency..."
@echo ""
@$(foreach dir,$(ALL_PKGS),(cd pkgs/$(dir) && python3 setup.py check) &&) :
@echo "Done."
@echo ""
json:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Generating libs json file"
@echo ""
@python3 -W ignore::SyntaxWarning -c "from genie.json.make_json import make_genielibs; make_genielibs()"
@echo ""
@echo "Done."
@echo ""
changelogs:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Generating changelog file"
@echo ""
@python3 -c "from ciscodistutils.make_changelog import main; main('./pkgs/clean-pkg/changelog/undistributed', './pkgs/clean-pkg/changelog/undistributed.rst')"
@echo "clean-pkg changelog done..."
@python3 -c "from ciscodistutils.make_changelog import main; main('./pkgs/health-pkg/changelog/undistributed', './pkgs/health-pkg/changelog/undistributed.rst')"
@echo "health-pkg changelog done..."
@python3 -c "from ciscodistutils.make_changelog import main; main('./pkgs/conf-pkg/changelog/undistributed', './pkgs/conf-pkg/changelog/undistributed.rst')"
@echo "conf-pkg changelog done..."
@python3 -c "from ciscodistutils.make_changelog import main; main('./pkgs/filetransferutils-pkg/changelog/undistributed', './pkgs/filetransferutils-pkg/changelog/undistributed.rst')"
@echo "filetransferutils-pkg changelog done..."
@python3 -c "from ciscodistutils.make_changelog import main; main('./pkgs/ops-pkg/changelog/undistributed', './pkgs/ops-pkg/changelog/undistributed.rst')"
@echo "ops-pkg changelog done..."
@python3 -c "from ciscodistutils.make_changelog import main; main('./pkgs/robot-pkg/changelog/undistributed', './pkgs/robot-pkg/changelog/undistributed.rst')"
@echo "robot-pkg changelog done..."
@python3 -c "from ciscodistutils.make_changelog import main; main('./pkgs/sdk-pkg/changelog/undistributed', './pkgs/sdk-pkg/changelog/undistributed.rst')"
@echo "sdk-pkg changelog done..."
@echo ""
@echo "Done."
@echo ""