-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathMakefile
executable file
·171 lines (147 loc) · 5.15 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
###############################################################################
# Rest Internal Makefile
#
# Author:
#
# Support:
#
# Version:
# v1.0.0
#
# Date:
# May 2017
#
# About This File:
# This script will build the Rest package for distribution in PyPI server
#
# Requirements:
# 1. Module name is the same as package name.
# 2. setup.py file is stored within the module folder
###############################################################################
# Variables
PKG_NAME = rest.connector
BUILDDIR = $(shell pwd)/__build__
PYTHON = python3
TESTCMD = $(PYTHON) -m unittest discover tests
DISTDIR = $(BUILDDIR)/dist
DEPENDENCIES = f5-icontrol-rest requests_mock requests dict2xml ciscoisesdk
.PHONY: clean package distribute distribute_staging distribute_staging_external\
develop undevelop populate_dist_dir help docs pubdocs tests
help:
@echo "Please use 'make <target>' where <target> is one of"
@echo ""
@echo "package : Build the package"
@echo "test : Test the package"
@echo "distribute : Distribute the package to PyPi server"
@echo "distribute_staging : Distribute the package to staging area"
@echo "distribute_staging_external : Distribute the package to external staging area"
@echo "clean : Remove build artifacts"
@echo "develop : Build and install development package"
@echo "undevelop : Uninstall development package"
@echo "docs : Build Sphinx documentation for this package"
@echo "distribute_docs : Publish the Sphinx documentation to the official cisco-shared web server for all to see"
docs:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Building $(PKG_NAME) documentation"
@echo ""
@cd docs; make html
@echo "Completed building docs for preview."
@echo ""
@echo "Done."
@echo ""
pubdocs:
@echo "Not implemented yet."
test:
@$(TESTCMD)
package:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Building $(PKG_NAME) distributable: $@"
@echo ""
@mkdir -p $(DISTDIR)
# NOTE : Only specify --universal if the package works for both py2 and py3
# https://packaging.python.org/en/latest/distributing.html#universal-wheels
@$(PYTHON) setup.py bdist_wheel --dist-dir=$(DISTDIR)
@$(PYTHON) setup.py sdist --dist-dir=$(DISTDIR)
@echo ""
@echo "Completed building: $@"
@echo ""
@echo "Done."
@echo ""
develop:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Building and installing $(PKG_NAME) development distributable: $@"
@echo ""
@pip uninstall -y rest.connector || true
@pip install $(DEPENDENCIES)
@$(PYTHON) setup.py develop --no-deps -q
@echo ""
@echo "Completed building and installing: $@"
@echo ""
@echo "Done."
@echo ""
undevelop:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Uninstalling $(PKG_NAME) development distributable: $@"
@echo ""
@./setup.py develop --no-deps -q --uninstall
@echo ""
@echo "Completed uninstalling: $@"
@echo ""
@echo "Done."
@echo ""
clean:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Removing make directory: $(BUILDDIR)"
@rm -rf $(BUILDDIR)
@echo ""
@echo "Removing build artifacts ..."
@./setup.py clean
@echo ""
@echo "Done."
@echo ""
distribute:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Copying all distributable to $(PROD_PKGS)"
@test -d $(DISTDIR) || { echo "Nothing to distribute! Exiting..."; exit 1; }
@ssh -q $(PROD_USER) 'test -e $(PROD_PKGS)/$(PKG_NAME) || mkdir $(PROD_PKGS)/$(PKG_NAME)'
@scp $(DISTDIR)/* $(PROD_USER):$(PROD_PKGS)/$(PKG_NAME)/
@echo ""
@echo "Done."
@echo ""
distribute_staging:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Copying all distributable to $(STAGING_PKGS)"
@test -d $(DISTDIR) || { echo "Nothing to distribute! Exiting..."; exit 1; }
@ssh -q $(PROD_USER) 'test -e $(STAGING_PKGS)/$(PKG_NAME) || mkdir $(STAGING_PKGS)/$(PKG_NAME)'
@scp $(DISTDIR)/* $(PROD_USER):$(STAGING_PKGS)/$(PKG_NAME)/
@echo ""
@echo "Done."
@echo ""
distribute_staging_external:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Copying all distributable to $(STAGING_EXT_PKGS)"
@test -d $(DISTDIR) || { echo "Nothing to distribute! Exiting..."; exit 1; }
@ssh -q $(PROD_USER) 'test -e $(STAGING_EXT_PKGS)/$(PKG_NAME) || mkdir $(STAGING_EXT_PKGS)/$(PKG_NAME)'
@scp $(DISTDIR)/* $(PROD_USER):$(STAGING_EXT_PKGS)/$(PKG_NAME)/
@echo ""
@echo "Done."
@echo ""
changelogs:
@echo ""
@echo "--------------------------------------------------------------------"
@echo "Generating changelog file"
@echo ""
@$(PYTHON) -c "from ciscodistutils.make_changelog import main; main('./docs/changelog/undistributed', './docs/changelog/undistributed.rst')"
@echo "rest.connector changelog created..."
@echo ""
@echo "Done."
@echo ""