python: Fix skipping tests if running with GnuPG < 2.1.12.
[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         gpgme-h-clean.py \
25         examples \
26         gpg
27
28 SUBDIRS = . tests
29
30 COPY_FILES = \
31         $(srcdir)/gpgme.i \
32         $(srcdir)/README \
33         $(srcdir)/MANIFEST.in \
34         $(srcdir)/gpgme-h-clean.py \
35         $(srcdir)/examples \
36         $(srcdir)/helpers.c $(srcdir)/helpers.h $(srcdir)/private.h
37
38 COPY_FILES_GPG = \
39         $(srcdir)/gpg/callbacks.py \
40         $(srcdir)/gpg/constants \
41         $(srcdir)/gpg/core.py \
42         $(srcdir)/gpg/errors.py \
43         $(srcdir)/gpg/__init__.py \
44         $(srcdir)/gpg/results.py \
45         $(srcdir)/gpg/util.py
46
47 .PHONY: prepare
48 prepare:
49         test -n "$(PREPAREDIR)"
50         $(MKDIR_P)              "$(PREPAREDIR)/gpg"
51         cp -R $(COPY_FILES)     "$(PREPAREDIR)"
52         cp setup.py             "$(PREPAREDIR)"
53         cp gpg/version.py       "$(PREPAREDIR)/gpg"
54         ln -sf "$(abs_top_srcdir)/src/data.h" "$(PREPAREDIR)"
55         ln -sf "$(abs_top_builddir)/config.h" "$(PREPAREDIR)"
56         cp -R $(COPY_FILES_GPG) "$(PREPAREDIR)/gpg"
57
58 # For VPATH builds we need to copy some files because Python's
59 # distutils are not VPATH-aware.
60 copystamp: $(COPY_FILES) $(COPY_FILES_GPG)
61         set -e ; for VERSION in $(PYTHON_VERSIONS); do \
62           $(MAKE) PREPAREDIR=python$${VERSION}-gpg prepare; \
63         done
64         touch $@
65
66 all-local: copystamp
67         set -e ; set $(PYTHONS); for VERSION in $(PYTHON_VERSIONS); do \
68           PYTHON="$$1" ; shift ; \
69           cd python$${VERSION}-gpg && \
70           CFLAGS="$(CFLAGS)" \
71           abs_top_builddir="$(abs_top_builddir)" \
72             $$PYTHON setup.py build --verbose ; \
73           cd .. ; \
74         done
75
76 python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz \
77 python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc: copystamp
78         cd python$(PYTHON_VERSION)-gpg && \
79         CFLAGS="$(CFLAGS)" \
80         abs_top_builddir="$(abs_top_builddir)" \
81           $(PYTHON) setup.py sdist --verbose
82         gpg2 --detach-sign --armor python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz
83
84 .PHONY: sdist
85 sdist: python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz \
86        python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc
87
88 .PHONY: upload
89 upload: python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz \
90         python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc
91         twine upload $^
92
93 CLEANFILES = copystamp
94
95 # Remove the rest.
96 #
97 # 'make distclean' clears the write bit, breaking rm -rf.  Fix the
98 # permissions.
99 clean-local:
100         rm -rf -- build
101         for VERSION in $(PYTHON_VERSIONS); do \
102           find python$${VERSION}-gpg -type d ! -perm -200 -exec chmod u+w {} ';' ; \
103           rm -rf -- python$${VERSION}-gpg ; \
104         done
105
106 install-exec-local:
107         rm -f install_files.txt
108         set -e ; set $(PYTHONS); for VERSION in $(PYTHON_VERSIONS); do \
109           PYTHON="$$1" ; shift ; \
110           cd python$${VERSION}-gpg ; \
111           abs_top_builddir="$(abs_top_builddir)" \
112           $$PYTHON setup.py install \
113           --prefix $(DESTDIR)$(prefix) \
114           --record files.txt \
115           --verbose ; \
116           cat files.txt >> ../install_files.txt ; \
117           rm files.txt ; \
118           cd .. ; \
119         done
120         $(MKDIR_P) $(DESTDIR)$(pythondir)/gpg
121         mv install_files.txt $(DESTDIR)$(pythondir)/gpg
122
123 uninstall-local:
124         xargs <$(DESTDIR)$(pythondir)/gpg/install_files.txt -- rm -rf --
125         rm -rf -- $(DESTDIR)$(pythondir)/gpg