gpgme/lang/python/Makefile.am
Justus Winter fe65a26ab5
python: Use one copy of the source tree per Python version.
* lang/python/Makefile.am (copystamp): Create one copy per Python
version.
(all-local): Adapt.
(clean-local): Likewise.
(install-exec-local): Likewise.
* lang/python/tests/run-tests.py: Likewise.
--

Currently, we use one copy of the Python module's source to build for
all Python versions.  This is problematic, because SWIG writes a
wrapper file into the source tree.  Currently, this file works with
both Python 2 and 3, but this is purely by chance.

Improve the situation by creating one copy per Python version so that
SWIG can write version-specific code into each copy.

Signed-off-by: Justus Winter <justus@g10code.com>
2017-02-13 16:44:53 +01:00

121 lines
3.3 KiB
Makefile

# Makefile.am for the Python bindings.
# Copyright (C) 2016 g10 Code GmbH
#
# This file is part of GPGME.
#
# GPGME is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of the
# License, or (at your option) any later version.
#
# GPGME is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
# Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, see <http://www.gnu.org/licenses/>.
EXTRA_DIST = \
README \
MANIFEST.in \
gpgme.i \
helpers.c helpers.h private.h \
gpgme-h-clean.py \
examples \
gpg
SUBDIRS = . tests
COPY_FILES = \
$(srcdir)/gpgme.i \
$(srcdir)/README \
$(srcdir)/MANIFEST.in \
$(srcdir)/gpgme-h-clean.py \
$(srcdir)/examples \
$(srcdir)/helpers.c $(srcdir)/helpers.h $(srcdir)/private.h
COPY_FILES_GPG = \
$(srcdir)/gpg/callbacks.py \
$(srcdir)/gpg/constants \
$(srcdir)/gpg/core.py \
$(srcdir)/gpg/errors.py \
$(srcdir)/gpg/__init__.py \
$(srcdir)/gpg/results.py \
$(srcdir)/gpg/util.py
# For VPATH builds we need to copy some files because Python's
# distutils are not VPATH-aware.
copystamp: $(COPY_FILES) $(COPY_FILES_GPG) data.h config.h
for VERSION in $(PYTHON_VERSIONS); do \
$(MKDIR_P) python$${VERSION}-gpg/gpg && \
cp -R $(COPY_FILES) python$${VERSION}-gpg && \
cp gpg/version.py python$${VERSION}-gpg/gpg && \
cp -R $(COPY_FILES_GPG) python$${VERSION}-gpg/gpg ; \
done
touch $@
data.h:
ln -s "$(top_srcdir)/src/data.h" .
config.h:
ln -s "$(top_builddir)/config.h" .
all-local: copystamp
set $(PYTHONS); for VERSION in $(PYTHON_VERSIONS); do \
PYTHON="$$1" ; shift ; \
cd python$${VERSION}-gpg && \
CFLAGS="$(CFLAGS)" \
$$PYTHON ../setup.py build --verbose ; \
cd .. ; \
done
dist/gpg-$(VERSION).tar.gz dist/gpg-$(VERSION).tar.gz.asc: copystamp
CFLAGS="$(CFLAGS)" \
$(PYTHON) setup.py sdist --verbose
gpg2 --detach-sign --armor dist/gpg-$(VERSION).tar.gz
.PHONY: prepare
prepare: copystamp
.PHONY: sdist
sdist: dist/gpg-$(VERSION).tar.gz dist/gpg-$(VERSION).tar.gz.asc
.PHONY: upload
upload: dist/gpg-$(VERSION).tar.gz dist/gpg-$(VERSION).tar.gz.asc
twine upload $^
CLEANFILES = gpgme.h errors.i gpgme_wrap.c gpg/gpgme.py \
data.h config.h copystamp
# Remove the rest.
#
# 'make distclean' clears the write bit, breaking rm -rf. Fix the
# permissions.
clean-local:
rm -rf -- build
for VERSION in $(PYTHON_VERSIONS); do \
find python$${VERSION}-gpg -type d ! -perm -200 -exec chmod u+w {} ';' ; \
rm -rf -- python$${VERSION}-gpg ; \
done
install-exec-local:
rm -f install_files.txt
set $(PYTHONS); for VERSION in $(PYTHON_VERSIONS); do \
PYTHON="$$1" ; shift ; \
cd python$${VERSION}-gpg && \
$$PYTHON ../setup.py install \
--prefix $(DESTDIR)$(prefix) \
--record files.txt \
--verbose ; \
cat files.txt >> ../install_files.txt ; \
rm files.txt ; \
cd .. ; \
done
$(MKDIR_P) $(DESTDIR)$(pythondir)/gpg
mv install_files.txt $(DESTDIR)$(pythondir)/gpg
uninstall-local:
xargs <$(DESTDIR)$(pythondir)/gpg/install_files.txt -- rm -rf --
rm -rf -- $(DESTDIR)$(pythondir)/gpg