Python bindings examples: PEP8 conpliance
[gpgme.git] / lang / python / Makefile.am
1 # Makefile.am for the Python bindings.
2 # Copyright (C) 2016 g10 Code GmbH
3 #
4 # This file is part of GPGME.
5 #
6 # GPGME is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU Lesser General Public License as
8 # published by the Free Software Foundation; either version 2.1 of the
9 # License, or (at your option) any later version.
10 #
11 # GPGME is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
14 # Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this program; if not, see <http://www.gnu.org/licenses/>.
18
19 EXTRA_DIST = \
20         README \
21         MANIFEST.in \
22         gpgme.i \
23         helpers.c helpers.h private.h \
24         examples \
25         src
26
27 SUBDIRS = . tests
28
29 .PHONY: prepare
30 prepare: copystamp
31
32 # For VPATH builds we need to copy some files because Python's
33 # distutils are not VPATH-aware.
34 copystamp:
35         ln -sf "$(top_srcdir)/src/data.h" .
36         ln -sf "$(top_builddir)/config.h" .
37         ln -sf "$(srcdir)/src" gpg
38         touch $@
39
40 all-local: copystamp
41         set -e ; for PYTHON in $(PYTHONS); do \
42           CPP="$(CPP)" \
43           CFLAGS="$(CFLAGS)" \
44           srcdir="$(srcdir)" \
45           top_builddir="$(top_builddir)" \
46             $$PYTHON setup.py build --verbose --build-base="$$(basename "$${PYTHON}")-gpg" ; \
47         done
48
49 python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc: copystamp
50         $(MKDIR_P) python$(PYTHON_VERSION)-gpg-dist
51         CPP="$(CPP)" \
52         CFLAGS="$(CFLAGS)" \
53         srcdir="$(srcdir)" \
54         top_builddir="$(top_builddir)" \
55           $(PYTHON) setup.py sdist --verbose --dist-dir=python$(PYTHON_VERSION)-gpg-dist \
56                 --manifest=python$(PYTHON_VERSION)-gpg-dist/MANIFEST
57         gpg2 --detach-sign --armor python$(PYTHON_VERSION)-gpg-dist/gpg-$(VERSION).tar.gz
58
59 .PHONY: sdist
60 sdist:  python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc
61
62 .PHONY: upload
63 upload: python$(PYTHON_VERSION)-gpg-dist/gpg-$(VERSION).tar.gz \
64         python$(PYTHON_VERSION)-gpg-dist/gpg-$(VERSION).tar.gz.asc
65         twine upload $^
66
67 CLEANFILES = copystamp \
68         config.h \
69         data.h \
70         gpg
71
72 # Remove the rest.
73 #
74 # 'make distclean' clears the write bit, breaking rm -rf.  Fix the
75 # permissions.
76 clean-local:
77         rm -rf -- build
78         for PYTHON in $(PYTHONS); do \
79           find "$$(basename "$${PYTHON}")-gpg" -type d ! -perm -200 -exec chmod u+w {} ';' ; \
80           rm -rf -- "$$(basename "$${PYTHON}")-gpg" ; \
81         done
82
83 install-exec-local:
84         set -e ; for PYTHON in $(PYTHONS); do \
85           CPP="$(CPP)" \
86           CFLAGS="$(CFLAGS)" \
87           srcdir="$(srcdir)" \
88           top_builddir="$(top_builddir)" \
89           $$PYTHON setup.py \
90           build \
91           --build-base="$$(basename "$${PYTHON}")-gpg" \
92           install \
93           --prefix "$(DESTDIR)$(prefix)" \
94           --verbose ; \
95         done
96
97 uninstall-local:
98         set -x; GV=$$(echo $(VERSION) | tr - _); for PYTHON in $(PYTHONS); do \
99           PLATLIB="$(prefix)/$$("$${PYTHON}" -c 'import sysconfig, os; print(os.path.relpath(sysconfig.get_path("platlib", scheme="posix_prefix"), sysconfig.get_config_var("prefix")))')" ; \
100           rm -rf -- "$(DESTDIR)$${PLATLIB}/gpg" \
101                 "$(DESTDIR)$${PLATLIB}"/gpg-$$GV-py*.egg-info ; \
102         done