@@ -27,6 +27,7 @@ PYTHON=python
2727PIP =pip
2828PYTEST =py.test
2929COVERAGE =coverage
30+ TWINE =twine
3031PYFLAGS =
3132DEST_DIR =/
3233
@@ -41,16 +42,17 @@ endif
4142# Calculate the base names of the distribution, the location of all source,
4243# documentation, packaging, icon, and executable script files
4344NAME: =$(shell $(PYTHON ) $(PYFLAGS ) setup.py --name)
45+ PKG_DIR: =$(subst -,_,$(NAME ) )
4446VER: =$(shell $(PYTHON ) $(PYFLAGS ) setup.py --version)
47+ DEB_ARCH: =$(shell dpkg --print-architecture)
4548ifeq ($(shell lsb_release -si) ,Ubuntu)
46- DEB_SUFFIX: =~ppa1
49+ DEB_SUFFIX: =ubuntu1
4750else
4851DEB_SUFFIX: =
4952endif
50- PYVER: =$(shell $(PYTHON ) $(PYFLAGS ) -c "import sys; print('py% d.% d' % sys.version_info[:2]) ")
5153PY_SOURCES: =$(shell \
5254 $(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)
5456DEB_SOURCES: =debian/changelog \
5557 debian/control \
5658 debian/copyright \
@@ -65,19 +67,28 @@ DEB_SOURCES:=debian/changelog \
6567DOC_SOURCES: =docs/conf.py \
6668 $(wildcard docs/* .png) \
6769 $(wildcard docs/* .svg) \
70+ $(wildcard docs/* .dot) \
71+ $(wildcard docs/* .mscgen) \
72+ $(wildcard docs/* .gpi) \
6873 $(wildcard docs/* .rst) \
6974 $(wildcard docs/* .pdf)
75+ SUBDIRS: =
7076
7177# 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
7379DIST_TAR =dist/$(NAME ) -$(VER ) .tar.gz
7480DIST_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
8192MAN_PAGES =
8293
8394
@@ -97,94 +108,96 @@ all:
97108 @echo " make release - Create and tag a new release"
98109 @echo " make upload - Upload the new release to repositories"
99110
100- install :
111+ install : $( SUBDIRS )
101112 $(PYTHON ) $(PYFLAGS ) setup.py install --root $(DEST_DIR )
102113
103114doc : $(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
105119
106120source : $(DIST_TAR ) $(DIST_ZIP )
107121
108- egg : $(DIST_EGG )
122+ wheel : $(DIST_WHEEL )
109123
110124zip : $(DIST_ZIP )
111125
112126tar : $(DIST_TAR )
113127
114128deb : $(DIST_DEB ) $(DIST_DSC )
115129
116- dist : $(DIST_EGG ) $(DIST_DEB ) $(DIST_DSC ) $(DIST_TAR ) $(DIST_ZIP )
130+ dist : $(DIST_WHEEL ) $(DIST_DEB ) $(DIST_DSC ) $(DIST_TAR ) $(DIST_ZIP )
117131
118132develop : 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
119138 $(PIP ) install -e .[doc,test]
120139
121140test :
122- $(COVERAGE ) run -m $(PYTEST ) tests -v
141+ $(COVERAGE ) run --rcfile coverage.cfg - m $(PYTEST ) tests
123142 $(COVERAGE ) report --rcfile coverage.cfg
124143
125144clean :
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
130150 find $(CURDIR ) -name " *.pyc" -delete
131151
132152tags : $(PY_SOURCES )
133153 ctags -R --exclude=" build/*" --exclude=" debian/*" --exclude=" docs/*" --languages=" Python"
134154
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 $@
139157
140- $(DIST_TAR ) : $(PY_SOURCES )
158+ $(DIST_TAR ) : $(PY_SOURCES ) $( SUBDIRS )
141159 $(PYTHON ) $(PYFLAGS ) setup.py sdist --formats gztar
142160
143- $(DIST_ZIP ) : $(PY_SOURCES )
161+ $(DIST_ZIP ) : $(PY_SOURCES ) $( SUBDIRS )
144162 $(PYTHON ) $(PYFLAGS ) setup.py sdist --formats zip
145163
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
148166
149- $(DIST_DEB ) : $(PY_SOURCES ) $(DEB_SOURCES ) $(MAN_PAGES )
167+ $(DIST_DEB ) : $(PY_SOURCES ) $(SUBDIRS ) $(DEB_SOURCES )
150168 # build the binary package in the parent directory then rename it to
151169 # project_version.orig.tar.gz
152170 $(PYTHON ) $(PYFLAGS ) setup.py sdist --dist-dir=../
153171 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
155173 mkdir -p dist/
156174 for f in $( DIST_DEB) ; do cp ../$$ {f## */} dist/; done
157175
158- $(DIST_DSC ) : $(PY_SOURCES ) $(DEB_SOURCES ) $(MAN_PAGES )
176+ $(DIST_DSC ) : $(PY_SOURCES ) $(SUBDIRS ) $(DEB_SOURCES )
159177 # build the source package in the parent directory then rename it to
160178 # project_version.orig.tar.gz
161179 $(PYTHON ) $(PYFLAGS ) setup.py sdist --dist-dir=../
162180 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
164182 mkdir -p dist/
165183 for f in $( DIST_DSC) ; do cp ../$$ {f## */} dist/; done
166184
167- release : $(PY_SOURCES ) $(DOC_SOURCES ) $(DEB_SOURCES )
185+ changelog : $(PY_SOURCES ) $(DOC_SOURCES ) $(DEB_SOURCES )
168186 $(MAKE ) clean
169187 # ensure there are no current uncommitted changes
170188 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 )
175191 # commit the changes and add a new tag
176192 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
180193
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) "
186196 git push --tags
187197 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
188202
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