python: Fix build system integration.
authorJustus Winter <justus@g10code.com>
Wed, 15 Feb 2017 10:31:27 +0000 (11:31 +0100)
committerJustus Winter <justus@g10code.com>
Wed, 15 Feb 2017 15:36:30 +0000 (16:36 +0100)
* lang/python/Makefile.am (copystamp): Also copy the setup script, and
link the header files.
(all-local): Use local setup script.
(sdist): Fix Python source distribution creation.
(CLEANFILES): Remove now obsolete files.
(install-exec-local): Use local setup script.
* lang/python/setup.py.in: Adjust relative paths to in-tree files.

Fixes-commit: fe65a26ab584bd70fad45c7c4d44330e30a748a4
Signed-off-by: Justus Winter <justus@g10code.com>
lang/python/Makefile.am
lang/python/setup.py.in

index 908f622..2724d86 100644 (file)
@@ -46,47 +46,48 @@ COPY_FILES_GPG = \
 
 # 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
+copystamp: $(COPY_FILES) $(COPY_FILES_GPG)
+       for F in $(COPY_FILES) $(COPY_FILES_GPG) ; do if [ $$F -nt $@ ]; then echo $F ; fi ; done
        for VERSION in $(PYTHON_VERSIONS); do \
          $(MKDIR_P)              python$${VERSION}-gpg/gpg && \
          cp -R $(COPY_FILES)     python$${VERSION}-gpg && \
+         cp setup.py             python$${VERSION}-gpg && \
          cp gpg/version.py       python$${VERSION}-gpg/gpg && \
+         ln -sf "$(abs_top_srcdir)/src/data.h" python$${VERSION}-gpg && \
+         ln -sf "$(abs_top_builddir)/config.h" python$${VERSION}-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 ; \
+           $$PYTHON setup.py build --verbose ; \
          cd .. ; \
        done
 
-dist/gpg-$(VERSION).tar.gz dist/gpg-$(VERSION).tar.gz.asc: copystamp
+python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz \
+python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc: copystamp
+       cd python$(PYTHON_VERSION)-gpg && \
        CFLAGS="$(CFLAGS)" \
          $(PYTHON) setup.py sdist --verbose
-       gpg2 --detach-sign --armor dist/gpg-$(VERSION).tar.gz
+       gpg2 --detach-sign --armor python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz
 
 .PHONY: prepare
 prepare: copystamp
 
 .PHONY: sdist
-sdist: dist/gpg-$(VERSION).tar.gz dist/gpg-$(VERSION).tar.gz.asc
+sdist: python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz \
+       python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc
 
 .PHONY: upload
-upload: dist/gpg-$(VERSION).tar.gz dist/gpg-$(VERSION).tar.gz.asc
+upload: python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz \
+        python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc
        twine upload $^
 
-CLEANFILES = gpgme.h errors.i gpgme_wrap.c gpg/gpgme.py \
-         data.h config.h copystamp
+CLEANFILES = copystamp
 
 # Remove the rest.
 #
@@ -104,7 +105,7 @@ install-exec-local:
        set $(PYTHONS); for VERSION in $(PYTHON_VERSIONS); do \
          PYTHON="$$1" ; shift ; \
          cd python$${VERSION}-gpg && \
-         $$PYTHON ../setup.py install \
+         $$PYTHON setup.py install \
          --prefix $(DESTDIR)$(prefix) \
          --record files.txt \
          --verbose ; \
index 5b5d5be..e32237d 100755 (executable)
@@ -34,12 +34,12 @@ in_tree = False
 extra_swig_opts = []
 extra_macros = dict()
 
-if os.path.exists("../../src/gpgme-config"):
+if os.path.exists("../../../src/gpgme-config"):
     # In-tree build.
     in_tree = True
-    gpgme_config = ["../../src/gpgme-config"] + gpgme_config_flags
-    gpgme_h = "../../src/gpgme.h"
-    library_dirs = ["../../src/.libs"] # XXX uses libtool internals
+    gpgme_config = ["../../../src/gpgme-config"] + gpgme_config_flags
+    gpgme_h = "../../../src/gpgme.h"
+    library_dirs = ["../../../src/.libs"] # XXX uses libtool internals
     extra_macros.update(
         HAVE_CONFIG_H=1,
         HAVE_DATA_H=1,