[PATCH GPGME] python: Generate files into build directory

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH GPGME] python: Generate files into build directory

Alon Bar-Lev-3
* lang/python/setup.py.in: Generate files within BuildExtFirstHack
adjust build flags at this point instead of global.
* lang/python/Makefile.am: Remove logic of separate source directory per
python version in favor of build directory.
* lang/python/tests/run-tests.py: Adjust build directory location.
--

Generate files into build directory, leaving the source directory clean.
Use the same source directory for multiple python version build. Result
of 'prepare' target is a standard distutil layout that can be used
easily by downstream to build all python targets in-place.

Signed-off-by: Alon Bar-Lev <[hidden email]>
---
 lang/python/Makefile.am        | 79 +++++++++++++++---------------------------
 lang/python/setup.py.in        | 48 +++++++++++++++++++------
 lang/python/tests/run-tests.py |  1 -
 3 files changed, 64 insertions(+), 64 deletions(-)

diff --git a/lang/python/Makefile.am b/lang/python/Makefile.am
index a18a014..b9145f5 100644
--- a/lang/python/Makefile.am
+++ b/lang/python/Makefile.am
@@ -27,70 +27,45 @@ EXTRA_DIST = \
 
 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
-
 .PHONY: prepare
-prepare:
- test -n "$(PREPAREDIR)"
- $(MKDIR_P)              "$(PREPAREDIR)/gpg"
- cp -R $(COPY_FILES)     "$(PREPAREDIR)"
- cp setup.py             "$(PREPAREDIR)"
- cp gpg/version.py       "$(PREPAREDIR)/gpg"
- ln -sf "$(abs_top_srcdir)/src/data.h" "$(PREPAREDIR)"
- ln -sf "$(abs_top_builddir)/config.h" "$(PREPAREDIR)"
- cp -R $(COPY_FILES_GPG) "$(PREPAREDIR)/gpg"
+prepare: copystamp
 
 # For VPATH builds we need to copy some files because Python's
 # distutils are not VPATH-aware.
-copystamp: $(COPY_FILES) $(COPY_FILES_GPG)
- set -e ; for VERSION in $(PYTHON_VERSIONS); do \
-  $(MAKE) PREPAREDIR=python$${VERSION}-gpg prepare; \
- done
+copystamp:
+ ln -sf "$(abs_top_srcdir)/src/data.h" .
+ ln -sf "$(abs_top_builddir)/config.h" .
  touch $@
 
 all-local: copystamp
  set -e ; set $(PYTHONS); for VERSION in $(PYTHON_VERSIONS); do \
   PYTHON="$$1" ; shift ; \
-  cd python$${VERSION}-gpg && \
   CFLAGS="$(CFLAGS)" \
   abs_top_builddir="$(abs_top_builddir)" \
-    $$PYTHON setup.py build --verbose ; \
-  cd .. ; \
+    $$PYTHON setup.py build --verbose --build-base=python$${VERSION}-gpg ; \
  done
 
-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 && \
+ $(MKDIR_P) python$(PYTHON_VERSION)-gpg-dist
  CFLAGS="$(CFLAGS)" \
  abs_top_builddir="$(abs_top_builddir)" \
-  $(PYTHON) setup.py sdist --verbose
- gpg2 --detach-sign --armor python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz
+  $(PYTHON) setup.py sdist --verbose --dist-dir=python$(PYTHON_VERSION)-gpg-dist \
+ --manifest=python$(PYTHON_VERSION)-gpg-dist/MANIFEST
+ gpg2 --detach-sign --armor python$(PYTHON_VERSION)-gpg-dist/gpg-$(VERSION).tar.gz
 
 .PHONY: sdist
-sdist: python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz \
-       python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc
+sdist: python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc
 
 .PHONY: upload
-upload: python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz \
-        python$(PYTHON_VERSION)-gpg/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 = copystamp
+CLEANFILES = copystamp \
+ config.h \
+ data.h \
+ files.txt \
+ install_files.txt
 
 # Remove the rest.
 #
@@ -104,22 +79,22 @@ clean-local:
  done
 
 install-exec-local:
- rm -f install_files.txt
  set -e ; set $(PYTHONS); for VERSION in $(PYTHON_VERSIONS); do \
   PYTHON="$$1" ; shift ; \
-  cd python$${VERSION}-gpg ; \
   abs_top_builddir="$(abs_top_builddir)" \
-  $$PYTHON setup.py install \
-  --prefix $(DESTDIR)$(prefix) \
+  $$PYTHON setup.py \
+  build \
+  --build-base=python$${VERSION}-gpg \
+  install \
+  --prefix "$(DESTDIR)$(prefix)" \
   --record files.txt \
   --verbose ; \
-  cat files.txt >> ../install_files.txt ; \
+  cat files.txt >> install_files.txt ; \
   rm files.txt ; \
-  cd .. ; \
  done
- $(MKDIR_P) $(DESTDIR)$(pythondir)/gpg
- mv install_files.txt $(DESTDIR)$(pythondir)/gpg
+ $(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
+ xargs < "$(DESTDIR)$(pythondir)/gpg/install_files.txt" -- rm -rf --
+ rm -rf -- "$(DESTDIR)$(pythondir)/gpg"
diff --git a/lang/python/setup.py.in b/lang/python/setup.py.in
index 8ddbf27..6692de6 100755
--- a/lang/python/setup.py.in
+++ b/lang/python/setup.py.in
@@ -21,6 +21,7 @@
 from distutils.core import setup, Extension
 import os, os.path, sys
 import glob
+import shutil
 import subprocess
 
 # Out-of-tree build of the gpg bindings.
@@ -89,14 +90,6 @@ if not os.path.exists(gpg_error_h):
         glob.glob(os.path.join(gpg_error_prefix, "include",
                                "*", "gpg-error.h"))[0]
 
-print("Building python gpg module using {} and {}.".format(gpgme_h, gpg_error_h))
-
-# Cleanup gpgme.h from deprecated functions and typedefs.
-subprocess.check_call([sys.executable, "gpgme-h-clean.py", gpgme_h],
-                      stdout=open("gpgme.h", "w"))
-subprocess.check_call([sys.executable, "gpgme-h-clean.py", gpg_error_h],
-                      stdout=open("errors.i", "w"))
-
 define_macros = []
 libs = getconfig('libs')
 
@@ -149,14 +142,47 @@ if uname_s.startswith("MINGW32"):
 # http://stackoverflow.com/questions/12491328/python-distutils-not-include-the-swig-generated-module
 from distutils.command.build import build
 class BuildExtFirstHack(build):
+
+    def _generate(self):
+        print("Building python gpg module using {} and {}.".format(gpgme_h, gpg_error_h))
+
+        # Cleanup gpgme.h from deprecated functions and typedefs.
+        # Keep timestamp to avoid rebuild
+        if not os.path.exists(self.build_base):
+            os.makedirs(self.build_base)
+
+        for src, dst in (
+            (gpgme_h, os.path.join(self.build_base, "gpgme.h")),
+            (gpg_error_h, os.path.join(self.build_base, "errors.i"))
+        ):
+            subprocess.check_call([sys.executable, "gpgme-h-clean.py", src],
+                                  stdout=open(dst, "w"))
+            shutil.copystat(src, dst)
+
+        # Copy due to http://bugs.python.org/issue2624
+        # Avoid creating in srcdir
+        shutil.copy2("gpgme.i", self.build_base)
+
     def run(self):
+        self._generate()
+
+        # Append generated files via build_base
+        if not os.path.exists(os.path.join(self.build_lib, "gpg")):
+            os.makedirs(os.path.join(self.build_lib, "gpg"))
+
+        swig_sources.append(os.path.join(self.build_base, 'gpgme.i'))
+        swig_opts.extend(['-I' + self.build_base, '-outdir', os.path.join(self.build_lib, 'gpg')])
+        include_dirs.append(self.build_base)
+
         self.run_command('build_ext')
         build.run(self)
 
 py3 = [] if sys.version_info.major < 3 else ['-py3']
-swige = Extension("gpg._gpgme", ["gpgme.i", "helpers.c"],
-                  swig_opts = ['-threads',
-                               '-outdir', 'gpg'] + py3 + extra_swig_opts,
+swig_sources = ['helpers.c']
+swig_opts = ['-threads'] + py3 + extra_swig_opts
+swige = Extension("gpg._gpgme",
+                  sources = swig_sources,
+                  swig_opts = swig_opts,
                   include_dirs = include_dirs,
                   define_macros = define_macros,
                   library_dirs = library_dirs,
diff --git a/lang/python/tests/run-tests.py b/lang/python/tests/run-tests.py
index 9e061d8..9e2fb78 100644
--- a/lang/python/tests/run-tests.py
+++ b/lang/python/tests/run-tests.py
@@ -71,7 +71,6 @@ for interpreter in args.interpreters:
 
     pattern = os.path.join(args.builddir, "..",
                            "python{0}-gpg".format(version),
-                           "build",
                            "lib*"+version)
     builddirs = glob.glob(pattern)
     if len(builddirs) == 0:
--
2.10.2


_______________________________________________
Gnupg-devel mailing list
[hidden email]
http://lists.gnupg.org/mailman/listinfo/gnupg-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH GPGME] python: Generate files into build directory

Justus Winter
Alon Bar-Lev <[hidden email]> writes:

> * lang/python/setup.py.in: Generate files within BuildExtFirstHack
> adjust build flags at this point instead of global.
> * lang/python/Makefile.am: Remove logic of separate source directory per
> python version in favor of build directory.
> * lang/python/tests/run-tests.py: Adjust build directory location.
> --
>
> Generate files into build directory, leaving the source directory clean.
> Use the same source directory for multiple python version build. Result
> of 'prepare' target is a standard distutil layout that can be used
> easily by downstream to build all python targets in-place.
Yes, this is very nice :).  I merged it.  Unfortunately it broke
out-of-tree builds and 'make distcheck'.  So I brought some of the
copying back, and did some cleanups.  I hope I didn't stomp over your
workflow again.


Thanks,
Justus

_______________________________________________
Gnupg-devel mailing list
[hidden email]
http://lists.gnupg.org/mailman/listinfo/gnupg-devel

signature.asc (497 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH GPGME] python: Generate files into build directory

Alon Bar-Lev-3
On 5 April 2017 at 17:46, Justus Winter <[hidden email]> wrote:
> Alon Bar-Lev <[hidden email]> writes:
> Yes, this is very nice :).  I merged it.  Unfortunately it broke
> out-of-tree builds and 'make distcheck'.  So I brought some of the
> copying back, and did some cleanups.  I hope I didn't stomp over your
> workflow again.

Hi,

Thanks!

Please consider to quote all
-$(srcdir) != .
-"$(srcdir)" != .

Maybe instead of copying back and forth, we can have gpg renamed to
gpg-src for example.
Then have a target like:

gpg:
    ln -s "$(srcdir)/gpg-src" gpg

This is unconditional and will probably work.
This will also remove the concern of srcdir in the setup.py as files
are always in builddir.

The problem is that the python tests never work for me, so make check
and make distcheck cannot be validated by me.

Alon

_______________________________________________
Gnupg-devel mailing list
[hidden email]
http://lists.gnupg.org/mailman/listinfo/gnupg-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH GPGME] python: Generate files into build directory

Alon Bar-Lev-3
On 5 April 2017 at 18:06, Alon Bar-Lev <[hidden email]> wrote:

> On 5 April 2017 at 17:46, Justus Winter <[hidden email]> wrote:
>> Alon Bar-Lev <[hidden email]> writes:
>> Yes, this is very nice :).  I merged it.  Unfortunately it broke
>> out-of-tree builds and 'make distcheck'.  So I brought some of the
>> copying back, and did some cleanups.  I hope I didn't stomp over your
>> workflow again.
>
> Hi,
>
> Thanks!
>
> Please consider to quote all
> -$(srcdir) != .
> -"$(srcdir)" != .
>
> Maybe instead of copying back and forth, we can have gpg renamed to
> gpg-src for example.
> Then have a target like:
>
> gpg:
>     ln -s "$(srcdir)/gpg-src" gpg
>
> This is unconditional and will probably work.
> This will also remove the concern of srcdir in the setup.py as files
> are always in builddir.
>
> The problem is that the python tests never work for me, so make check
> and make distcheck cannot be validated by me.

I will try to produce this patch.

_______________________________________________
Gnupg-devel mailing list
[hidden email]
http://lists.gnupg.org/mailman/listinfo/gnupg-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH GPGME] python: simplify build, some fixups

Alon Bar-Lev-3
* lang/python/gpg/version.py.in: Rename to lang/python/version.py.in.
configure.ac: Generate version.py.in in lang/python
* lang/python/MANIFEST.in: Include version.py explicitly.
* lang/python/gpg: Rename to gpg-src
* lang/python/Makefile.am: Do not copy source files, do not use absolute
directories, support lib64 in uninstall, clean also dist directory, use
symlink for gpg src.
* lang/python/setup.py.in: Use builddir, copy sources into builddir,
copy version.py into module.
--

Simplify build to symlink the gpg sources into builddir instead of
copying. This requires handling of version.py as generated file.

In addition apply some cleanups: Drop the absolution pathes, clean the
dist directory as well, support lib64 for sitelib at uninstall.

Signed-off-by: Alon Bar-Lev <[hidden email]>
---
 configure.ac                                       |  2 +-
 lang/python/MANIFEST.in                            |  1 +
 lang/python/Makefile.am                            | 38 +++++++---------------
 lang/python/{gpg => gpg-src}/__init__.py           |  0
 lang/python/{gpg => gpg-src}/callbacks.py          |  0
 lang/python/{gpg => gpg-src}/constants/__init__.py |  0
 lang/python/{gpg => gpg-src}/constants/create.py   |  0
 .../{gpg => gpg-src}/constants/data/__init__.py    |  0
 .../{gpg => gpg-src}/constants/data/encoding.py    |  0
 lang/python/{gpg => gpg-src}/constants/event.py    |  0
 lang/python/{gpg => gpg-src}/constants/import.py   |  0
 .../{gpg => gpg-src}/constants/keylist/__init__.py |  0
 .../{gpg => gpg-src}/constants/keylist/mode.py     |  0
 lang/python/{gpg => gpg-src}/constants/keysign.py  |  0
 lang/python/{gpg => gpg-src}/constants/md.py       |  0
 lang/python/{gpg => gpg-src}/constants/pk.py       |  0
 lang/python/{gpg => gpg-src}/constants/protocol.py |  0
 .../{gpg => gpg-src}/constants/sig/__init__.py     |  0
 lang/python/{gpg => gpg-src}/constants/sig/mode.py |  0
 .../{gpg => gpg-src}/constants/sig/notation.py     |  0
 lang/python/{gpg => gpg-src}/constants/sigsum.py   |  0
 lang/python/{gpg => gpg-src}/constants/status.py   |  0
 .../{gpg => gpg-src}/constants/tofu/__init__.py    |  0
 .../{gpg => gpg-src}/constants/tofu/policy.py      |  0
 lang/python/{gpg => gpg-src}/constants/validity.py |  0
 lang/python/{gpg => gpg-src}/core.py               |  0
 lang/python/{gpg => gpg-src}/errors.py             |  0
 lang/python/{gpg => gpg-src}/results.py            |  0
 lang/python/{gpg => gpg-src}/util.py               |  0
 lang/python/setup.py.in                            | 23 ++++++-------
 lang/python/{gpg => }/version.py.in                |  0
 31 files changed, 24 insertions(+), 40 deletions(-)
 rename lang/python/{gpg => gpg-src}/__init__.py (100%)
 rename lang/python/{gpg => gpg-src}/callbacks.py (100%)
 rename lang/python/{gpg => gpg-src}/constants/__init__.py (100%)
 rename lang/python/{gpg => gpg-src}/constants/create.py (100%)
 rename lang/python/{gpg => gpg-src}/constants/data/__init__.py (100%)
 rename lang/python/{gpg => gpg-src}/constants/data/encoding.py (100%)
 rename lang/python/{gpg => gpg-src}/constants/event.py (100%)
 rename lang/python/{gpg => gpg-src}/constants/import.py (100%)
 rename lang/python/{gpg => gpg-src}/constants/keylist/__init__.py (100%)
 rename lang/python/{gpg => gpg-src}/constants/keylist/mode.py (100%)
 rename lang/python/{gpg => gpg-src}/constants/keysign.py (100%)
 rename lang/python/{gpg => gpg-src}/constants/md.py (100%)
 rename lang/python/{gpg => gpg-src}/constants/pk.py (100%)
 rename lang/python/{gpg => gpg-src}/constants/protocol.py (100%)
 rename lang/python/{gpg => gpg-src}/constants/sig/__init__.py (100%)
 rename lang/python/{gpg => gpg-src}/constants/sig/mode.py (100%)
 rename lang/python/{gpg => gpg-src}/constants/sig/notation.py (100%)
 rename lang/python/{gpg => gpg-src}/constants/sigsum.py (100%)
 rename lang/python/{gpg => gpg-src}/constants/status.py (100%)
 rename lang/python/{gpg => gpg-src}/constants/tofu/__init__.py (100%)
 rename lang/python/{gpg => gpg-src}/constants/tofu/policy.py (100%)
 rename lang/python/{gpg => gpg-src}/constants/validity.py (100%)
 rename lang/python/{gpg => gpg-src}/core.py (100%)
 rename lang/python/{gpg => gpg-src}/errors.py (100%)
 rename lang/python/{gpg => gpg-src}/results.py (100%)
 rename lang/python/{gpg => gpg-src}/util.py (100%)
 rename lang/python/{gpg => }/version.py.in (100%)

diff --git a/configure.ac b/configure.ac
index 7ab94e7..9974abb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -881,7 +881,7 @@ AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpgme.asd])
 AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([lang/qt/doc/Doxyfile])])
 AC_CONFIG_FILES(lang/qt/doc/Makefile)
 AC_CONFIG_FILES([lang/python/Makefile
- lang/python/gpg/version.py
+ lang/python/version.py
  lang/python/tests/Makefile])
 AC_CONFIG_FILES([lang/python/setup.py], [chmod a+x lang/python/setup.py])
 AC_OUTPUT
diff --git a/lang/python/MANIFEST.in b/lang/python/MANIFEST.in
index ff38172..c34e84a 100644
--- a/lang/python/MANIFEST.in
+++ b/lang/python/MANIFEST.in
@@ -1,4 +1,5 @@
 recursive-include examples *.py
 include gpgme.i
 include helpers.c helpers.h private.h
+include version.py
 recursive-include gpg *.py
diff --git a/lang/python/Makefile.am b/lang/python/Makefile.am
index 42beeee..0903c7b 100644
--- a/lang/python/Makefile.am
+++ b/lang/python/Makefile.am
@@ -22,28 +22,19 @@ EXTRA_DIST = \
  gpgme.i \
  helpers.c helpers.h private.h \
  examples \
- gpg
+ gpg-src
 
 SUBDIRS = . tests
 
-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
-
 .PHONY: prepare
 prepare: copystamp
 
 # For VPATH builds we need to copy some files because Python's
 # distutils are not VPATH-aware.
 copystamp:
- ln -sf "$(abs_top_srcdir)/src/data.h" .
- ln -sf "$(abs_top_builddir)/config.h" .
- if test $(srcdir) != . ; then cp -R $(COPY_FILES_GPG) gpg ; fi
+ ln -sf "$(top_srcdir)/src/data.h" .
+ ln -sf "$(top_builddir)/config.h" .
+ ln -sf "$(srcdir)/gpg-src" gpg
  touch $@
 
 all-local: copystamp
@@ -51,7 +42,7 @@ all-local: copystamp
   PYTHON="$$1" ; shift ; \
   CFLAGS="$(CFLAGS)" \
   srcdir="$(srcdir)" \
-  abs_top_builddir="$(abs_top_builddir)" \
+  top_builddir="$(top_builddir)" \
     $$PYTHON setup.py build --verbose --build-base=python$${VERSION}-gpg ; \
  done
 
@@ -59,7 +50,7 @@ python$(PYTHON_VERSION)-gpg/dist/gpg-$(VERSION).tar.gz.asc: copystamp
  $(MKDIR_P) python$(PYTHON_VERSION)-gpg-dist
  CFLAGS="$(CFLAGS)" \
  srcdir="$(srcdir)" \
- abs_top_builddir="$(abs_top_builddir)" \
+ top_builddir="$(top_builddir)" \
   $(PYTHON) setup.py sdist --verbose --dist-dir=python$(PYTHON_VERSION)-gpg-dist \
  --manifest=python$(PYTHON_VERSION)-gpg-dist/MANIFEST
  gpg2 --detach-sign --armor python$(PYTHON_VERSION)-gpg-dist/gpg-$(VERSION).tar.gz
@@ -75,6 +66,7 @@ upload: python$(PYTHON_VERSION)-gpg-dist/gpg-$(VERSION).tar.gz \
 CLEANFILES = copystamp \
  config.h \
  data.h \
+ gpg \
  files.txt \
  install_files.txt
 
@@ -84,22 +76,16 @@ CLEANFILES = copystamp \
 # permissions.
 clean-local:
  rm -rf -- build
- if test $(srcdir) != . ; then \
-  find gpg -type d ! -perm -200 -exec chmod u+w {} ';' ; \
-  for FILE in $(COPY_FILES_GPG); do \
-    rm -rf -- gpg/$$(basename $$FILE) ; \
-  done \
- fi
  for VERSION in $(PYTHON_VERSIONS); do \
-  find python$${VERSION}-gpg -type d ! -perm -200 -exec chmod u+w {} ';' ; \
-  rm -rf -- python$${VERSION}-gpg ; \
+  find python$${VERSION}-gpg* -type d ! -perm -200 -exec chmod u+w {} ';' ; \
+  rm -rf -- python$${VERSION}-gpg* ; \
  done
 
 install-exec-local:
  set -e ; set $(PYTHONS); for VERSION in $(PYTHON_VERSIONS); do \
   PYTHON="$$1" ; shift ; \
   srcdir="$(srcdir)" \
-  abs_top_builddir="$(abs_top_builddir)" \
+  top_builddir="$(top_builddir)" \
   $$PYTHON setup.py \
   build \
   --build-base=python$${VERSION}-gpg \
@@ -110,6 +96,6 @@ install-exec-local:
 
 uninstall-local:
  GV=$$(echo $(VERSION) | tr - _); for PV in $(PYTHON_VERSIONS); do \
-  rm -rf -- "$(DESTDIR)$(prefix)/lib/python$$PV/site-packages/gpg" \
-"$(DESTDIR)$(prefix)/lib/python$$PV/site-packages/gpg-$$GV-py$$PV.egg-info" ; \
+  rm -rf -- "$(DESTDIR)$(prefix)"/lib*/python$$PV/site-packages/gpg \
+"$(DESTDIR)$(prefix)"/lib*/python$$PV/site-packages/gpg-$$GV-py$$PV.egg-info ; \
  done
diff --git a/lang/python/gpg/__init__.py b/lang/python/gpg-src/__init__.py
similarity index 100%
rename from lang/python/gpg/__init__.py
rename to lang/python/gpg-src/__init__.py
diff --git a/lang/python/gpg/callbacks.py b/lang/python/gpg-src/callbacks.py
similarity index 100%
rename from lang/python/gpg/callbacks.py
rename to lang/python/gpg-src/callbacks.py
diff --git a/lang/python/gpg/constants/__init__.py b/lang/python/gpg-src/constants/__init__.py
similarity index 100%
rename from lang/python/gpg/constants/__init__.py
rename to lang/python/gpg-src/constants/__init__.py
diff --git a/lang/python/gpg/constants/create.py b/lang/python/gpg-src/constants/create.py
similarity index 100%
rename from lang/python/gpg/constants/create.py
rename to lang/python/gpg-src/constants/create.py
diff --git a/lang/python/gpg/constants/data/__init__.py b/lang/python/gpg-src/constants/data/__init__.py
similarity index 100%
rename from lang/python/gpg/constants/data/__init__.py
rename to lang/python/gpg-src/constants/data/__init__.py
diff --git a/lang/python/gpg/constants/data/encoding.py b/lang/python/gpg-src/constants/data/encoding.py
similarity index 100%
rename from lang/python/gpg/constants/data/encoding.py
rename to lang/python/gpg-src/constants/data/encoding.py
diff --git a/lang/python/gpg/constants/event.py b/lang/python/gpg-src/constants/event.py
similarity index 100%
rename from lang/python/gpg/constants/event.py
rename to lang/python/gpg-src/constants/event.py
diff --git a/lang/python/gpg/constants/import.py b/lang/python/gpg-src/constants/import.py
similarity index 100%
rename from lang/python/gpg/constants/import.py
rename to lang/python/gpg-src/constants/import.py
diff --git a/lang/python/gpg/constants/keylist/__init__.py b/lang/python/gpg-src/constants/keylist/__init__.py
similarity index 100%
rename from lang/python/gpg/constants/keylist/__init__.py
rename to lang/python/gpg-src/constants/keylist/__init__.py
diff --git a/lang/python/gpg/constants/keylist/mode.py b/lang/python/gpg-src/constants/keylist/mode.py
similarity index 100%
rename from lang/python/gpg/constants/keylist/mode.py
rename to lang/python/gpg-src/constants/keylist/mode.py
diff --git a/lang/python/gpg/constants/keysign.py b/lang/python/gpg-src/constants/keysign.py
similarity index 100%
rename from lang/python/gpg/constants/keysign.py
rename to lang/python/gpg-src/constants/keysign.py
diff --git a/lang/python/gpg/constants/md.py b/lang/python/gpg-src/constants/md.py
similarity index 100%
rename from lang/python/gpg/constants/md.py
rename to lang/python/gpg-src/constants/md.py
diff --git a/lang/python/gpg/constants/pk.py b/lang/python/gpg-src/constants/pk.py
similarity index 100%
rename from lang/python/gpg/constants/pk.py
rename to lang/python/gpg-src/constants/pk.py
diff --git a/lang/python/gpg/constants/protocol.py b/lang/python/gpg-src/constants/protocol.py
similarity index 100%
rename from lang/python/gpg/constants/protocol.py
rename to lang/python/gpg-src/constants/protocol.py
diff --git a/lang/python/gpg/constants/sig/__init__.py b/lang/python/gpg-src/constants/sig/__init__.py
similarity index 100%
rename from lang/python/gpg/constants/sig/__init__.py
rename to lang/python/gpg-src/constants/sig/__init__.py
diff --git a/lang/python/gpg/constants/sig/mode.py b/lang/python/gpg-src/constants/sig/mode.py
similarity index 100%
rename from lang/python/gpg/constants/sig/mode.py
rename to lang/python/gpg-src/constants/sig/mode.py
diff --git a/lang/python/gpg/constants/sig/notation.py b/lang/python/gpg-src/constants/sig/notation.py
similarity index 100%
rename from lang/python/gpg/constants/sig/notation.py
rename to lang/python/gpg-src/constants/sig/notation.py
diff --git a/lang/python/gpg/constants/sigsum.py b/lang/python/gpg-src/constants/sigsum.py
similarity index 100%
rename from lang/python/gpg/constants/sigsum.py
rename to lang/python/gpg-src/constants/sigsum.py
diff --git a/lang/python/gpg/constants/status.py b/lang/python/gpg-src/constants/status.py
similarity index 100%
rename from lang/python/gpg/constants/status.py
rename to lang/python/gpg-src/constants/status.py
diff --git a/lang/python/gpg/constants/tofu/__init__.py b/lang/python/gpg-src/constants/tofu/__init__.py
similarity index 100%
rename from lang/python/gpg/constants/tofu/__init__.py
rename to lang/python/gpg-src/constants/tofu/__init__.py
diff --git a/lang/python/gpg/constants/tofu/policy.py b/lang/python/gpg-src/constants/tofu/policy.py
similarity index 100%
rename from lang/python/gpg/constants/tofu/policy.py
rename to lang/python/gpg-src/constants/tofu/policy.py
diff --git a/lang/python/gpg/constants/validity.py b/lang/python/gpg-src/constants/validity.py
similarity index 100%
rename from lang/python/gpg/constants/validity.py
rename to lang/python/gpg-src/constants/validity.py
diff --git a/lang/python/gpg/core.py b/lang/python/gpg-src/core.py
similarity index 100%
rename from lang/python/gpg/core.py
rename to lang/python/gpg-src/core.py
diff --git a/lang/python/gpg/errors.py b/lang/python/gpg-src/errors.py
similarity index 100%
rename from lang/python/gpg/errors.py
rename to lang/python/gpg-src/errors.py
diff --git a/lang/python/gpg/results.py b/lang/python/gpg-src/results.py
similarity index 100%
rename from lang/python/gpg/results.py
rename to lang/python/gpg-src/results.py
diff --git a/lang/python/gpg/util.py b/lang/python/gpg-src/util.py
similarity index 100%
rename from lang/python/gpg/util.py
rename to lang/python/gpg-src/util.py
diff --git a/lang/python/setup.py.in b/lang/python/setup.py.in
index 2114aaf..5d94c70 100755
--- a/lang/python/setup.py.in
+++ b/lang/python/setup.py.in
@@ -38,18 +38,17 @@ gpgme_config = ["gpgme-config"] + gpgme_config_flags
 gpgme_h = ""
 include_dirs = [os.getcwd()]
 library_dirs = []
-vpath_build = os.environ.get('srcdir', '.') != '.'
 in_tree = False
 extra_swig_opts = []
 extra_macros = dict()
 
-abs_top_builddir = os.environ.get("abs_top_builddir")
-if abs_top_builddir:
+top_builddir = os.environ.get("top_builddir")
+if top_builddir:
     # In-tree build.
     in_tree = True
-    gpgme_config = [os.path.join(abs_top_builddir, "src/gpgme-config")] + gpgme_config_flags
-    gpgme_h = os.path.join(abs_top_builddir, "src/gpgme.h")
-    library_dirs = [os.path.join(abs_top_builddir, "src/.libs")] # XXX uses libtool internals
+    gpgme_config = [os.path.join(top_builddir, "src/gpgme-config")] + gpgme_config_flags
+    gpgme_h = os.path.join(top_builddir, "src/gpgme.h")
+    library_dirs = [os.path.join(top_builddir, "src/.libs")] # XXX uses libtool internals
     extra_macros.update(
         HAVE_CONFIG_H=1,
         HAVE_DATA_H=1,
@@ -210,23 +209,21 @@ class BuildExtFirstHack(build):
         # Copy due to http://bugs.python.org/issue2624
         # Avoid creating in srcdir
         for source, target in ((in_srcdir(n), in_build_base(n))
-                               for n in ('gpgme.i', 'helpers.c')):
+                               for n in ('gpgme.i', 'helpers.c', 'private.h', 'helpers.h')):
             if not up_to_date(source, target):
                 shutil.copy2(source, target)
 
-    def run(self):
-        self._generate()
-
         # Append generated files via build_base
         if not os.path.exists(os.path.join(self.build_lib, "gpg")):
             os.makedirs(os.path.join(self.build_lib, "gpg"))
+        shutil.copy2("version.py", os.path.join(self.build_lib, "gpg"))
+
+    def run(self):
+        self._generate()
 
         swig_sources.append(os.path.join(self.build_base, 'gpgme.i'))
         swig_opts.extend(['-I' + self.build_base,
-                          '-I' + in_srcdir('.'),
                           '-outdir', os.path.join(self.build_lib, 'gpg')])
-        if vpath_build:
-            include_dirs.append(in_srcdir('.'))
         include_dirs.append(self.build_base)
 
         self.run_command('build_ext')
diff --git a/lang/python/gpg/version.py.in b/lang/python/version.py.in
similarity index 100%
rename from lang/python/gpg/version.py.in
rename to lang/python/version.py.in
--
2.10.2


_______________________________________________
Gnupg-devel mailing list
[hidden email]
http://lists.gnupg.org/mailman/listinfo/gnupg-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH GPGME] python: simplify build, some fixups

Justus Winter
Alon Bar-Lev <[hidden email]> writes:

> * lang/python/gpg/version.py.in: Rename to lang/python/version.py.in.
> configure.ac: Generate version.py.in in lang/python
> * lang/python/MANIFEST.in: Include version.py explicitly.
> * lang/python/gpg: Rename to gpg-src

I changed 'gpg-src' to 'src' because the other bindings also have their
sources in 'src'.

Merged, many thanks!


Justus

_______________________________________________
Gnupg-devel mailing list
[hidden email]
http://lists.gnupg.org/mailman/listinfo/gnupg-devel

signature.asc (497 bytes) Download Attachment
Loading...