Skip to content

Commit c8105c8

Browse files
committed
Implement native Debian packaging (control files are part of the source repo) with Makefile to simplify the release procedure.
1 parent 17c93d1 commit c8105c8

File tree

12 files changed

+421
-43
lines changed

12 files changed

+421
-43
lines changed

Makefile

+176
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# vim: set noet sw=4 ts=4 fileencoding=utf-8:
2+
3+
# External utilities
4+
PYTHON=python
5+
PIP=pip
6+
PYTEST=py.test
7+
COVERAGE=coverage
8+
PYFLAGS=
9+
DEST_DIR=/
10+
11+
# Horrid hack to ensure setuptools is installed in our python environment. This
12+
# is necessary with Python 3.3's venvs which don't install it by default.
13+
ifeq ($(shell python -c "import setuptools" 2>&1),)
14+
SETUPTOOLS:=
15+
else
16+
SETUPTOOLS:=$(shell wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | $(PYTHON))
17+
endif
18+
19+
# Calculate the base names of the distribution, the location of all source,
20+
# documentation, packaging, icon, and executable script files
21+
NAME:=$(shell $(PYTHON) $(PYFLAGS) setup.py --name)
22+
VER:=$(shell $(PYTHON) $(PYFLAGS) setup.py --version)
23+
ifeq ($(shell lsb_release -si),Ubuntu)
24+
DEB_SUFFIX:=ubuntu1
25+
else
26+
DEB_SUFFIX:=
27+
endif
28+
DEB_ARCH:=$(shell dpkg --print-architecture)
29+
PYVER:=$(shell $(PYTHON) $(PYFLAGS) -c "import sys; print('py%d.%d' % sys.version_info[:2])")
30+
PY_SOURCES:=$(shell \
31+
$(PYTHON) $(PYFLAGS) setup.py egg_info >/dev/null 2>&1 && \
32+
grep -v "\.egg-info" $(NAME).egg-info/SOURCES.txt)
33+
DEB_SOURCES:=debian/changelog \
34+
debian/control \
35+
debian/copyright \
36+
debian/rules \
37+
debian/docs \
38+
$(wildcard debian/*.init) \
39+
$(wildcard debian/*.default) \
40+
$(wildcard debian/*.manpages) \
41+
$(wildcard debian/*.docs) \
42+
$(wildcard debian/*.doc-base) \
43+
$(wildcard debian/*.desktop)
44+
DOC_SOURCES:=
45+
SUBDIRS:=
46+
47+
# Calculate the name of all outputs
48+
DIST_EGG=dist/$(NAME)-$(VER)-$(PYVER).egg
49+
DIST_TAR=dist/$(NAME)-$(VER).tar.gz
50+
DIST_ZIP=dist/$(NAME)-$(VER).zip
51+
DIST_DEB=dist/python-$(NAME)_$(VER)-1$(DEB_SUFFIX)_all.deb \
52+
dist/python3-$(NAME)_$(VER)-1$(DEB_SUFFIX)_all.deb \
53+
dist/python-$(NAME)-docs_$(VER)-1$(DEB_SUFFIX)_all.deb \
54+
dist/$(NAME)_$(VER)-1$(DEB_SUFFIX)_$(DEB_ARCH).changes
55+
DIST_DSC=dist/$(NAME)_$(VER)-1$(DEB_SUFFIX).tar.gz \
56+
dist/$(NAME)_$(VER)-1$(DEB_SUFFIX).dsc \
57+
dist/$(NAME)_$(VER)-1$(DEB_SUFFIX)_source.changes
58+
MAN_PAGES=
59+
60+
61+
# Default target
62+
all:
63+
@echo "make install - Install on local system"
64+
@echo "make develop - Install symlinks for development"
65+
@echo "make test - Run tests"
66+
@echo "make doc - Generate HTML and PDF documentation"
67+
@echo "make source - Create source package"
68+
@echo "make egg - Generate a PyPI egg package"
69+
@echo "make zip - Generate a source zip package"
70+
@echo "make tar - Generate a source tar package"
71+
@echo "make deb - Generate Debian packages"
72+
@echo "make dist - Generate all packages"
73+
@echo "make clean - Get rid of all generated files"
74+
@echo "make release - Create and tag a new release"
75+
@echo "make upload - Upload the new release to repositories"
76+
77+
install: $(SUBDIRS)
78+
$(PYTHON) $(PYFLAGS) setup.py install --root $(DEST_DIR)
79+
80+
doc: $(DOC_SOURCES)
81+
$(MAKE) -C docs clean
82+
$(MAKE) -C docs html
83+
$(MAKE) -C docs latexpdf
84+
85+
source: $(DIST_TAR) $(DIST_ZIP)
86+
87+
egg: $(DIST_EGG)
88+
89+
zip: $(DIST_ZIP)
90+
91+
tar: $(DIST_TAR)
92+
93+
deb: $(DIST_DEB) $(DIST_DSC)
94+
95+
dist: $(DIST_EGG) $(DIST_DEB) $(DIST_DSC) $(DIST_TAR) $(DIST_ZIP)
96+
97+
develop: tags
98+
@# These have to be done separately to avoid a cockup...
99+
$(PIP) install -U setuptools
100+
$(PIP) install -U pip
101+
$(PIP) install -e .
102+
103+
test:
104+
$(COVERAGE) run -m $(PYTEST) tests -v
105+
$(COVERAGE) report --rcfile coverage.cfg
106+
107+
clean:
108+
$(PYTHON) $(PYFLAGS) setup.py clean
109+
$(MAKE) -f $(CURDIR)/debian/rules clean
110+
$(MAKE) -C docs clean
111+
rm -fr build/ dist/ $(NAME).egg-info/ tags
112+
for dir in $(SUBDIRS); do \
113+
$(MAKE) -C $$dir clean; \
114+
done
115+
find $(CURDIR) -name "*.pyc" -delete
116+
117+
tags: $(PY_SOURCES)
118+
ctags -R --exclude="build/*" --exclude="debian/*" --exclude="docs/*" --languages="Python"
119+
120+
$(SUBDIRS):
121+
$(MAKE) -C $@
122+
123+
$(MAN_PAGES): $(DOC_SOURCES)
124+
$(PYTHON) $(PYFLAGS) setup.py build_sphinx -b man
125+
mkdir -p man/
126+
cp build/sphinx/man/*.[0-9] man/
127+
128+
$(DIST_TAR): $(PY_SOURCES) $(SUBDIRS)
129+
$(PYTHON) $(PYFLAGS) setup.py sdist --formats gztar
130+
131+
$(DIST_ZIP): $(PY_SOURCES) $(SUBDIRS)
132+
$(PYTHON) $(PYFLAGS) setup.py sdist --formats zip
133+
134+
$(DIST_EGG): $(PY_SOURCES) $(SUBDIRS)
135+
$(PYTHON) $(PYFLAGS) setup.py bdist_egg
136+
137+
$(DIST_DEB): $(PY_SOURCES) $(SUBDIRS) $(DEB_SOURCES) $(MAN_PAGES)
138+
# build the binary package in the parent directory then rename it to
139+
# project_version.orig.tar.gz
140+
$(PYTHON) $(PYFLAGS) setup.py sdist --dist-dir=../
141+
rename -f 's/$(NAME)-(.*)\.tar\.gz/$(NAME)_$$1\.orig\.tar\.gz/' ../*
142+
debuild -b -i -I -Idist -Ibuild -Idocs/_build -Icoverage -I__pycache__ -I.coverage -Itags -I*.pyc -I*.vim -I*.xcf -rfakeroot
143+
mkdir -p dist/
144+
for f in $(DIST_DEB); do cp ../$${f##*/} dist/; done
145+
146+
$(DIST_DSC): $(PY_SOURCES) $(SUBDIRS) $(DEB_SOURCES) $(MAN_PAGES)
147+
# build the source package in the parent directory then rename it to
148+
# project_version.orig.tar.gz
149+
$(PYTHON) $(PYFLAGS) setup.py sdist --dist-dir=../
150+
rename -f 's/$(NAME)-(.*)\.tar\.gz/$(NAME)_$$1\.orig\.tar\.gz/' ../*
151+
debuild -S -i -I -Idist -Ibuild -Idocs/_build -Icoverage -I__pycache__ -I.coverage -Itags -I*.pyc -I*.vim -I*.xcf -rfakeroot
152+
mkdir -p dist/
153+
for f in $(DIST_DSC); do cp ../$${f##*/} dist/; done
154+
155+
release: $(PY_SOURCES) $(DOC_SOURCES) $(DEB_SOURCES)
156+
$(MAKE) clean
157+
# ensure there are no current uncommitted changes
158+
test -z "$(shell git status --porcelain)"
159+
# update the debian changelog with new release information
160+
dch --newversion $(VER)-1$(DEB_SUFFIX) --controlmaint
161+
# commit the changes and add a new tag
162+
git commit debian/changelog -m "Updated changelog for release $(VER)"
163+
git tag -s release-$(VER) -m "Release $(VER)"
164+
# update the package's registration on PyPI (in case any metadata's changed)
165+
$(PYTHON) $(PYFLAGS) setup.py register
166+
167+
upload: $(PY_SOURCES) $(DOC_SOURCES) $(DIST_DEB) $(DIST_DSC)
168+
# build a source archive and upload to PyPI
169+
$(PYTHON) $(PYFLAGS) setup.py sdist upload
170+
# build the deb source archive and upload to Raspbian
171+
dput raspberrypi dist/$(NAME)_$(VER)-1$(DEB_SUFFIX)_source.changes
172+
dput raspberrypi dist/$(NAME)_$(VER)-1$(DEB_SUFFIX)_$(DEB_ARCH).changes
173+
git push --tags
174+
175+
.PHONY: all install develop test doc source egg zip tar deb dist clean tags release upload $(SUBDIRS)
176+

README.rst

+11-10
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ Example usage for lighting up an LED::
3838
from gpiozero import LED
3939

4040
led = LED(2)
41-
4241
led.on()
4342

4443
Documentation
@@ -55,7 +54,8 @@ This project is being developed on `GitHub`_. Join in:
5554
* Help design the `API`_
5655
* Contribute to the code
5756

58-
Alternatively, email suggestions and feedback to [email protected] or add to the `Google Doc`_.
57+
Alternatively, email suggestions and feedback to [email protected] or add to
58+
the `Google Doc`_.
5959

6060
Contributors
6161
============
@@ -65,11 +65,12 @@ Contributors
6565
- `Martin O'Hanlon`_
6666

6767

68-
.. _`pythonhosted.org/gpiozero`: http://pythonhosted.org/gpiozero
69-
.. _`GitHub`: https://github.com/RPi-Distro/python-gpiozero
70-
.. _`Issues`: https://github.com/RPi-Distro/python-gpiozero/issues
71-
.. _`API`: https://github.com/RPi-Distro/python-gpiozero/issues/7
72-
.. _`Google Doc`: https://docs.google.com/document/d/1EbbVjdgXbKVPFlgH_pEEtPZ0zOZVSPHT4sQNW88Am7w/edit?usp=sharing
73-
.. _`Ben Nuttall`: https://github.com/bennuttall
74-
.. _`Dave Jones`: https://github.com/waveform80
75-
.. _`Martin O'Hanlon`: https://github.com/martinohanlon
68+
.. _pythonhosted.org/gpiozero: http://pythonhosted.org/gpiozero
69+
.. _GitHub: https://github.com/RPi-Distro/python-gpiozero
70+
.. _Issues: https://github.com/RPi-Distro/python-gpiozero/issues
71+
.. _API: https://github.com/RPi-Distro/python-gpiozero/issues/7
72+
.. _Google Doc: https://docs.google.com/document/d/1EbbVjdgXbKVPFlgH_pEEtPZ0zOZVSPHT4sQNW88Am7w/edit?usp=sharing
73+
.. _Ben Nuttall: https://github.com/bennuttall
74+
.. _Dave Jones: https://github.com/waveform80
75+
.. _Martin O'Hanlon: https://github.com/martinohanlon
76+

RELEASE.rst

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
=================
2+
Release Procedure
3+
=================
4+
5+
On your build Pi, perform the following steps:
6+
7+
1. Ensure you have a reliable Internet connection (preferably Ethernet).
8+
9+
2. Ensure you have the following Debian packages installed: ``devscripts, dput,
10+
python-all, python3-all, gnupg, build-essential, git, python-setuptools,
11+
python3-setuptools, python-rpi.gpio, python3-rpi.gpio``
12+
13+
3. Ensure you have a valid ``~/.pypirc`` configuration. For example::
14+
15+
[distutils]
16+
index-servers =
17+
pypi
18+
19+
[pypi]
20+
username:my_username
21+
password:my_long_password
22+
23+
4. Ensure you have a valid ``~/.dput.cf`` setup which includes the
24+
``[raspberrypi]`` target. For example::
25+
26+
[raspberrypi]
27+
fqdn = build-master.raspberrypi.org
28+
incoming = incoming
29+
login = incoming
30+
method = scp
31+
32+
5. Ensure you have a valid public/private key-pair defined for GNUPG.
33+
34+
6. In the ``python-gpiozero`` directory, run ``make release``. This will launch
35+
``dch`` to update the Debian changelog. Fill this out properly (ticket
36+
references!) and the release will be generated, tagged, signed, and
37+
registered with GitHub and PyPI.
38+
39+
.. note::
40+
41+
Although the release has been registered at this point, no packages
42+
have been generated or uploaded to any service.
43+
44+
7. Still in the ``python-gpiozero`` directory, run ``make upload``. This will
45+
generate the actual debian packages, upload them to Raspbian, and upload
46+
the source package to PyPI.
47+
48+
8. On GitHub, close any milestone associated with the release.
49+
50+
9. On ReadTheDocs, update the project configuration to build the new release,
51+
then set it to the default version for the project.

debian/changelog

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
gpiozero (0.6.0-1) stable; urgency=medium
2+
3+
* Raspbian packaging (#44)
4+
* PWM functionality including variable level RGB LEDs (#40)
5+
* Ability to recreate GPIO device objects (#38)
6+
7+
-- Ben Nuttall <[email protected]> Mon, 05 Oct 2015 22:21:48 +0100
8+

debian/compat

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8

debian/control

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Source: gpiozero
2+
Maintainer: Ben Nuttall <[email protected]>
3+
Homepage: http://github.com/RPi-Distro/python-gpiozero
4+
Section: python
5+
Priority: extra
6+
Build-Depends: debhelper (>= 8), python-all (>= 2.7), python-setuptools, python3-all, python3-setuptools
7+
Standards-Version: 3.9.3
8+
X-Python-Version: >= 2.7
9+
X-Python3-Version: >= 3.2
10+
11+
Package: python-gpiozero
12+
Architecture: all
13+
Depends: ${misc:Depends}, ${python:Depends}, python-rpi.gpio, python-w1thermsensor, python-spidev
14+
Description: Simple API for controlling devices attached to the GPIO pins.
15+
gpiozero builds on RPi.GPIO to provide a set of classes designed to simplify
16+
interaction with devices connected to the GPIO pins, from simple buttons and
17+
LEDs, up to various add-on boards. The API tries to adhere closely to Python's
18+
idioms and naming conventions.
19+
.
20+
This is the Python 2 version of the package.
21+
22+
Package: python3-gpiozero
23+
Architecture: all
24+
Depends: ${misc:Depends}, ${python3:Depends}, python3-rpi.gpio, python3-w1thermsensor, python3-spidev
25+
Description: Simple API for controlling devices attached to the GPIO pins.
26+
gpiozero builds on RPi.GPIO to provide a set of classes designed to simplify
27+
interaction with devices connected to the GPIO pins, from simple buttons and
28+
LEDs, up to various add-on boards. The API tries to adhere closely to Python's
29+
idioms and naming conventions.
30+
.
31+
This is the Python 3 version of the package.
32+

debian/copyright

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Format: http://dep.debian.net/deps/dep5
2+
Upstream-Name: gpiozero
3+
Source: https://github.com/RPi-Distro/python-gpiozero
4+
5+
Files: *
6+
Copyright: 2015 Ben Nuttall <[email protected]>
7+
License: BSD-3-Clause
8+
9+
License: BSD-3-Clause
10+
Redistribution and use in source and binary forms, with or without
11+
modification, are permitted provided that the following conditions are met:
12+
.
13+
* Redistributions of source code must retain the above copyright
14+
notice, this list of conditions and the following disclaimer.
15+
* Redistributions in binary form must reproduce the above copyright
16+
notice, this list of conditions and the following disclaimer in the
17+
documentation and/or other materials provided with the distribution.
18+
* Neither the name of the copyright holder nor the
19+
names of its contributors may be used to endorse or promote products
20+
derived from this software without specific prior written permission.
21+
.
22+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
26+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
POSSIBILITY OF SUCH DAMAGE.
33+

debian/docs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
README.rst

debian/rules

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/make -f
2+
# -*- makefile -*-
3+
4+
#export DH_VERBOSE=1
5+
export DH_OPTIONS
6+
7+
%:
8+
dh $@ --with python2,python3 --buildsystem=python_distutils
9+
10+
override_dh_auto_install:
11+
python setup.py install --root debian/python-picraft --install-layout=deb
12+
python3 setup.py install --root debian/python3-picraft --install-layout=deb
13+
14+
#override_dh_auto_test:
15+
# # Don't run the tests!
16+
17+
#override_dh_installdocs:
18+
# python setup.py build_sphinx -b html
19+
# dh_installdocs
20+

debian/source/format

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0 (native)

debian/source/options

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
extend-diff-ignore = "(^|/)(Makefile|setup\.cfg)$"
2+
extend-diff-ignore = "(^|/)(docs/.*)$"
3+
extend-diff-ignore = "(^|/)(build/sphinx/doctrees/.*)$"

0 commit comments

Comments
 (0)