@@ -27,6 +27,7 @@ PYTHON=python
27
27
PIP =pip
28
28
PYTEST =py.test
29
29
COVERAGE =coverage
30
+ TWINE =twine
30
31
PYFLAGS =
31
32
DEST_DIR =/
32
33
@@ -41,16 +42,17 @@ endif
41
42
# Calculate the base names of the distribution, the location of all source,
42
43
# documentation, packaging, icon, and executable script files
43
44
NAME: =$(shell $(PYTHON ) $(PYFLAGS ) setup.py --name)
45
+ PKG_DIR: =$(subst -,_,$(NAME ) )
44
46
VER: =$(shell $(PYTHON ) $(PYFLAGS ) setup.py --version)
47
+ DEB_ARCH: =$(shell dpkg --print-architecture)
45
48
ifeq ($(shell lsb_release -si) ,Ubuntu)
46
- DEB_SUFFIX: =~ppa1
49
+ DEB_SUFFIX: =ubuntu1
47
50
else
48
51
DEB_SUFFIX: =
49
52
endif
50
- PYVER: =$(shell $(PYTHON ) $(PYFLAGS ) -c "import sys; print('py% d.% d' % sys.version_info[:2]) ")
51
53
PY_SOURCES: =$(shell \
52
54
$(PYTHON ) $(PYFLAGS ) setup.py egg_info >/dev/null 2>&1 && \
53
- grep -v "\.egg-info" $(NAME ) .egg-info/SOURCES.txt)
55
+ grep -v "\.egg-info" $(PKG_DIR ) .egg-info/SOURCES.txt)
54
56
DEB_SOURCES: =debian/changelog \
55
57
debian/control \
56
58
debian/copyright \
@@ -65,19 +67,28 @@ DEB_SOURCES:=debian/changelog \
65
67
DOC_SOURCES: =docs/conf.py \
66
68
$(wildcard docs/* .png) \
67
69
$(wildcard docs/* .svg) \
70
+ $(wildcard docs/* .dot) \
71
+ $(wildcard docs/* .mscgen) \
72
+ $(wildcard docs/* .gpi) \
68
73
$(wildcard docs/* .rst) \
69
74
$(wildcard docs/* .pdf)
75
+ SUBDIRS: =
70
76
71
77
# Calculate the name of all outputs
72
- DIST_EGG =dist/$(NAME ) -$(VER ) -$( PYVER ) .egg
78
+ DIST_WHEEL =dist/$(NAME ) -$(VER ) -py2.py3-none-any.whl
73
79
DIST_TAR =dist/$(NAME ) -$(VER ) .tar.gz
74
80
DIST_ZIP =dist/$(NAME ) -$(VER ) .zip
75
- DIST_DEB =dist/python-$(NAME ) _$(VER ) -1$(DEB_SUFFIX ) _all.deb \
76
- dist/python3-$(NAME ) _$(VER ) -1$(DEB_SUFFIX ) _all.deb \
77
- dist/python-$(NAME ) -docs_$(VER ) -1$(DEB_SUFFIX ) _all.deb
78
- DIST_DSC =dist/$(NAME ) _$(VER ) -1$(DEB_SUFFIX ) .tar.gz \
79
- dist/$(NAME ) _$(VER ) -1$(DEB_SUFFIX ) .dsc \
80
- dist/$(NAME ) _$(VER ) -1$(DEB_SUFFIX ) _source.changes
81
+ DIST_DEB =dist/python-$(NAME ) _$(VER )$(DEB_SUFFIX ) _all.deb \
82
+ dist/python3-$(NAME ) _$(VER )$(DEB_SUFFIX ) _all.deb \
83
+ dist/python-$(NAME ) -docs_$(VER )$(DEB_SUFFIX ) _all.deb \
84
+ dist/$(NAME ) _$(VER )$(DEB_SUFFIX ) _$(DEB_ARCH ) .build \
85
+ dist/$(NAME ) _$(VER )$(DEB_SUFFIX ) _$(DEB_ARCH ) .buildinfo \
86
+ dist/$(NAME ) _$(VER )$(DEB_SUFFIX ) _$(DEB_ARCH ) .changes
87
+ DIST_DSC =dist/$(NAME ) _$(VER )$(DEB_SUFFIX ) .tar.xz \
88
+ dist/$(NAME ) _$(VER )$(DEB_SUFFIX ) .dsc \
89
+ dist/$(NAME ) _$(VER )$(DEB_SUFFIX ) _source.build \
90
+ dist/$(NAME ) _$(VER )$(DEB_SUFFIX ) _source.buildinfo \
91
+ dist/$(NAME ) _$(VER )$(DEB_SUFFIX ) _source.changes
81
92
MAN_PAGES =
82
93
83
94
@@ -97,94 +108,96 @@ all:
97
108
@echo " make release - Create and tag a new release"
98
109
@echo " make upload - Upload the new release to repositories"
99
110
100
- install :
111
+ install : $( SUBDIRS )
101
112
$(PYTHON ) $(PYFLAGS ) setup.py install --root $(DEST_DIR )
102
113
103
114
doc : $(DOC_SOURCES )
104
- $(MAKE ) -C docs html latexpdf
115
+ $(MAKE ) -C docs clean
116
+ $(MAKE ) -C docs html
117
+ $(MAKE ) -C docs epub
118
+ $(MAKE ) -C docs latexpdf
105
119
106
120
source : $(DIST_TAR ) $(DIST_ZIP )
107
121
108
- egg : $(DIST_EGG )
122
+ wheel : $(DIST_WHEEL )
109
123
110
124
zip : $(DIST_ZIP )
111
125
112
126
tar : $(DIST_TAR )
113
127
114
128
deb : $(DIST_DEB ) $(DIST_DSC )
115
129
116
- dist : $(DIST_EGG ) $(DIST_DEB ) $(DIST_DSC ) $(DIST_TAR ) $(DIST_ZIP )
130
+ dist : $(DIST_WHEEL ) $(DIST_DEB ) $(DIST_DSC ) $(DIST_TAR ) $(DIST_ZIP )
117
131
118
132
develop : tags
133
+ @# These have to be done separately to avoid a cockup...
134
+ $(PIP ) install -U setuptools
135
+ $(PIP ) install -U pip
136
+ $(PIP ) install -U tox
137
+ $(PIP ) install virtualenv==13
119
138
$(PIP ) install -e .[doc,test]
120
139
121
140
test :
122
- $(COVERAGE ) run -m $(PYTEST ) tests -v
141
+ $(COVERAGE ) run --rcfile coverage.cfg - m $(PYTEST ) tests
123
142
$(COVERAGE ) report --rcfile coverage.cfg
124
143
125
144
clean :
126
- $(PYTHON ) $(PYFLAGS ) setup.py clean
127
- $(MAKE ) -f $(CURDIR ) /debian/rules clean
128
- $(MAKE ) -C docs clean
129
- rm -fr build/ dist/ $(NAME ) .egg-info/ tags
145
+ dh_clean
146
+ rm -fr dist/ $(NAME ) .egg-info/ tags
147
+ for dir in $( SUBDIRS) ; do \
148
+ $(MAKE ) -C $$ dir clean; \
149
+ done
130
150
find $(CURDIR ) -name " *.pyc" -delete
131
151
132
152
tags : $(PY_SOURCES )
133
153
ctags -R --exclude=" build/*" --exclude=" debian/*" --exclude=" docs/*" --languages=" Python"
134
154
135
- $(MAN_PAGES ) : $(DOC_SOURCES )
136
- $(MAKE ) -C docs man
137
- mkdir -p man/
138
- cp docs/_build/man/* .1 man/
155
+ $(SUBDIRS ) :
156
+ $(MAKE ) -C $@
139
157
140
- $(DIST_TAR ) : $(PY_SOURCES )
158
+ $(DIST_TAR ) : $(PY_SOURCES ) $( SUBDIRS )
141
159
$(PYTHON ) $(PYFLAGS ) setup.py sdist --formats gztar
142
160
143
- $(DIST_ZIP ) : $(PY_SOURCES )
161
+ $(DIST_ZIP ) : $(PY_SOURCES ) $( SUBDIRS )
144
162
$(PYTHON ) $(PYFLAGS ) setup.py sdist --formats zip
145
163
146
- $(DIST_EGG ) : $(PY_SOURCES )
147
- $(PYTHON ) $(PYFLAGS ) setup.py bdist_egg
164
+ $(DIST_WHEEL ) : $(PY_SOURCES ) $( SUBDIRS )
165
+ $(PYTHON ) $(PYFLAGS ) setup.py bdist_wheel --universal
148
166
149
- $(DIST_DEB ) : $(PY_SOURCES ) $(DEB_SOURCES ) $(MAN_PAGES )
167
+ $(DIST_DEB ) : $(PY_SOURCES ) $(SUBDIRS ) $(DEB_SOURCES )
150
168
# build the binary package in the parent directory then rename it to
151
169
# project_version.orig.tar.gz
152
170
$(PYTHON ) $(PYFLAGS ) setup.py sdist --dist-dir=../
153
171
rename -f ' s/$(NAME)-(.*)\.tar\.gz/$(NAME)_$$1\.orig\.tar\.gz/' ../*
154
- debuild -b -i -I -Idist -Ibuild -Idocs/_build -Icoverage -I__pycache__ -I.coverage -Itags -I * .pyc -I * .vim -I * .xcf -rfakeroot
172
+ debuild -b
155
173
mkdir -p dist/
156
174
for f in $( DIST_DEB) ; do cp ../$$ {f## */} dist/; done
157
175
158
- $(DIST_DSC ) : $(PY_SOURCES ) $(DEB_SOURCES ) $(MAN_PAGES )
176
+ $(DIST_DSC ) : $(PY_SOURCES ) $(SUBDIRS ) $(DEB_SOURCES )
159
177
# build the source package in the parent directory then rename it to
160
178
# project_version.orig.tar.gz
161
179
$(PYTHON ) $(PYFLAGS ) setup.py sdist --dist-dir=../
162
180
rename -f ' s/$(NAME)-(.*)\.tar\.gz/$(NAME)_$$1\.orig\.tar\.gz/' ../*
163
- debuild -S -i -I -Idist -Ibuild -Idocs/_build -Icoverage -I__pycache__ -I.coverage -Itags -I * .pyc -I * .vim -I * .xcf -rfakeroot
181
+ debuild -S
164
182
mkdir -p dist/
165
183
for f in $( DIST_DSC) ; do cp ../$$ {f## */} dist/; done
166
184
167
- release : $(PY_SOURCES ) $(DOC_SOURCES ) $(DEB_SOURCES )
185
+ changelog : $(PY_SOURCES ) $(DOC_SOURCES ) $(DEB_SOURCES )
168
186
$(MAKE ) clean
169
187
# ensure there are no current uncommitted changes
170
188
test -z " $( shell git status --porcelain) "
171
- # update the changelog with new release information
172
- dch --newversion $(VER ) -1$(DEB_SUFFIX ) --controlmaint
173
- # ensure all packages build successfully before committing
174
- $(MAKE ) dist
189
+ # update the debian changelog with new release information
190
+ dch --newversion $(VER )$(DEB_SUFFIX )
175
191
# commit the changes and add a new tag
176
192
git commit debian/changelog -m " Updated changelog for release $( VER) "
177
- git tag -s release-$(VER ) -m " Release $( VER) "
178
- # update the package's registration on PyPI (in case any metadata's changed)
179
- $(PYTHON ) $(PYFLAGS ) setup.py register
180
193
181
- upload : $(PY_SOURCES ) $(DOC_SOURCES ) $(DIST_DEB ) $(DIST_DSC )
182
- # build a source archive and upload to PyPI
183
- $(PYTHON ) $(PYFLAGS ) setup.py sdist upload
184
- # build the deb source archive and upload to the PPA
185
- dput waveform-ppa dist/$(NAME ) _$(VER ) -1$(DEB_SUFFIX ) _source.changes
194
+ release : $(DIST_DEB ) $(DIST_DSC ) $(DIST_TAR ) $(DIST_WHEEL )
195
+ git tag -s release-$(VER ) -m " Release $( VER) "
186
196
git push --tags
187
197
git push
198
+ # build a source archive and upload to PyPI
199
+ $(TWINE ) upload $(DIST_TAR ) $(DIST_WHEEL )
200
+ # build the deb source archive and upload to the PPA
201
+ dput waveform-ppa dist/$(NAME ) _$(VER )$(DEB_SUFFIX ) _source.changes
188
202
189
- .PHONY : all install develop test doc source egg zip tar deb dist clean tags release upload
190
-
203
+ .PHONY : all install develop test doc source wheel zip tar deb dist clean tags changelog release $(SUBDIRS )
0 commit comments