[gpgme][PATCH] build: lang: python: cleanups

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

[gpgme][PATCH] build: lang: python: cleanups

Alon Bar-Lev-3
1. Make setup.py executable when generated.

2. Add prepare target to enable prepare the source tree without building
   anything. This is handy to enable standard distutils build outside of
   gpgme build system.

3. Treat data.h in similar manner as other VPATH issues, just copy it to
   the srcdir to simplify build, remove the CFLAGS requirement of
   distutils.

4. Add environment variable (binary_builddir) for setup to use alternate
   build directory so that for multiple targets same binaries may be
   used without rebuilding the C part.

The above does not alter the behavior of current build but supports the
following sequence:

$ mkdir common
$ cd common
$ ../configure --enable-languages=
$ make
$ cd ..
$ mkdir python
$ cd python
$ ../configure --enable-languages=
$ cd lang/python
$ make prepare
$ binary_builddir="../../../common" ./setup.py build
$ binary_builddir="../../../common" ./setup.py install

Notice the standard use of distutils which is required for package
manager to control the python selection and build process.

Signed-off-by: Alon Bar-Lev <[hidden email]>
---
 configure.ac            |  2 +-
 lang/python/Makefile.am | 11 ++++++-----
 lang/python/gpgme.i     |  2 +-
 lang/python/setup.py.in |  9 +++++----
 4 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4a29f2f..efa1f19 100644
--- a/configure.ac
+++ b/configure.ac
@@ -886,9 +886,9 @@ 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/setup.py
  lang/python/pyme/version.py
  lang/python/tests/Makefile])
+AC_CONFIG_FILES([lang/python/setup.py], [chmod a+x lang/python/setup.py])
 AC_OUTPUT
 
 echo "
diff --git a/lang/python/Makefile.am b/lang/python/Makefile.am
index 2271ce0..fb1eebf 100644
--- a/lang/python/Makefile.am
+++ b/lang/python/Makefile.am
@@ -51,17 +51,18 @@ copystamp: $(COPY_FILES) $(COPY_FILES_PYME)
   cp -R $(COPY_FILES) . ; \
   cp -R $(COPY_FILES_PYME) pyme ; \
  fi
+ cp "$(top_srcdir)/src/data.h" .
  touch $@
 
+prepare: copystamp
+
 all-local: copystamp
  for PYTHON in $(PYTHONS); do \
-  CFLAGS="$(CFLAGS) -I$(top_srcdir)" \
-    $$PYTHON setup.py build --verbose ; \
+  $$PYTHON setup.py build --verbose ; \
  done
 
 dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc: copystamp
- CFLAGS="$(CFLAGS) -I$(top_srcdir)" \
-  $(PYTHON) setup.py sdist --verbose
+ $(PYTHON) setup.py sdist --verbose
  gpg2 --detach-sign --armor dist/pyme3-$(VERSION).tar.gz
 
 .PHONY: sdist
@@ -72,7 +73,7 @@ upload: dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc
  twine upload $^
 
 CLEANFILES = gpgme.h errors.i gpgme_wrap.c pyme/gpgme.py \
-  copystamp
+  data.h copystamp
 
 # Remove the rest.
 #
diff --git a/lang/python/gpgme.i b/lang/python/gpgme.i
index 84addae..ac666f4 100644
--- a/lang/python/gpgme.i
+++ b/lang/python/gpgme.i
@@ -183,7 +183,7 @@
    representation of struct gpgme_data for an very efficient check if
    the buffer has been modified.  */
 %{
-#include "src/data.h" /* For struct gpgme_data.  */
+#include "data.h" /* For struct gpgme_data.  */
 %}
 #endif
 
diff --git a/lang/python/setup.py.in b/lang/python/setup.py.in
index 31892c1..ce06758 100755
--- a/lang/python/setup.py.in
+++ b/lang/python/setup.py.in
@@ -32,13 +32,14 @@ library_dirs = []
 in_tree = False
 extra_swig_opts = []
 extra_macros = dict()
+binary_builddir=os.environ.get('binary_builddir', '../..')
 
-if os.path.exists("../../src/gpgme-config"):
+if os.path.exists(os.path.join(binary_builddir, "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 = [os.path.join(binary_builddir, "src/gpgme-config")] + gpgme_config_flags
+    gpgme_h = os.path.join(binary_builddir, "src/gpgme.h")
+    library_dirs = [os.path.join(binary_builddir, "src/.libs")] # XXX uses libtool internals
     extra_macros.update(
         HAVE_DATA_H=1,
         IN_TREE_BUILD=1,
--
2.7.3


_______________________________________________
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

[gpgme][PATCH] build: lang: python: cleanups

Alon Bar-Lev-3
1. Make setup.py executable when generated.

2. Add prepare target to enable prepare the source tree without building
   anything. This is handy to enable standard distutils build outside of
   gpgme build system.

3. Treat data.h in similar manner as other VPATH issues, just symlink it
   to the srcdir to simplify build, remove the CFLAGS requirement of
   distutils.

The above does not alter the behavior of current build but supports the
following sequence:

$ mkdir build
$ cd build
$ ../configure --enable-languages=
$ make
$ cd lang/python
$ make prepare
$ ./setup.py build
$ ./setup.py install

Notice the standard use of distutils which is required for package
manager to control the python selection and build process.

Signed-off-by: Alon Bar-Lev <[hidden email]>
---
 configure.ac            |  2 +-
 lang/python/Makefile.am | 16 ++++++++++------
 lang/python/gpgme.i     |  2 +-
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4a29f2f..efa1f19 100644
--- a/configure.ac
+++ b/configure.ac
@@ -886,9 +886,9 @@ 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/setup.py
  lang/python/pyme/version.py
  lang/python/tests/Makefile])
+AC_CONFIG_FILES([lang/python/setup.py], [chmod a+x lang/python/setup.py])
 AC_OUTPUT
 
 echo "
diff --git a/lang/python/Makefile.am b/lang/python/Makefile.am
index 2271ce0..9866f53 100644
--- a/lang/python/Makefile.am
+++ b/lang/python/Makefile.am
@@ -46,24 +46,28 @@ COPY_FILES_PYME = \
 
 # For VPATH builds we need to copy some files because Python's
 # distutils are not VPATH-aware.
-copystamp: $(COPY_FILES) $(COPY_FILES_PYME)
+copystamp: $(COPY_FILES) $(COPY_FILES_PYME) data.h
  if test "$(srcdir)" != "$(builddir)" ; then \
   cp -R $(COPY_FILES) . ; \
   cp -R $(COPY_FILES_PYME) pyme ; \
  fi
  touch $@
 
+data.h:
+ ln -s "$(top_srcdir)/src/data.h"
+
 all-local: copystamp
  for PYTHON in $(PYTHONS); do \
-  CFLAGS="$(CFLAGS) -I$(top_srcdir)" \
-    $$PYTHON setup.py build --verbose ; \
+  $$PYTHON setup.py build --verbose ; \
  done
 
 dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc: copystamp
- CFLAGS="$(CFLAGS) -I$(top_srcdir)" \
-  $(PYTHON) setup.py sdist --verbose
+ $(PYTHON) setup.py sdist --verbose
  gpg2 --detach-sign --armor dist/pyme3-$(VERSION).tar.gz
 
+.PHONY: prepare
+prepare: copystamp
+
 .PHONY: sdist
 sdist: dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc
 
@@ -72,7 +76,7 @@ upload: dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc
  twine upload $^
 
 CLEANFILES = gpgme.h errors.i gpgme_wrap.c pyme/gpgme.py \
-  copystamp
+  data.h copystamp
 
 # Remove the rest.
 #
diff --git a/lang/python/gpgme.i b/lang/python/gpgme.i
index 84addae..ac666f4 100644
--- a/lang/python/gpgme.i
+++ b/lang/python/gpgme.i
@@ -183,7 +183,7 @@
    representation of struct gpgme_data for an very efficient check if
    the buffer has been modified.  */
 %{
-#include "src/data.h" /* For struct gpgme_data.  */
+#include "data.h" /* For struct gpgme_data.  */
 %}
 #endif
 
--
2.7.3


_______________________________________________
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: [gpgme][PATCH] build: lang: python: cleanups

Justus Winter
In reply to this post by Alon Bar-Lev-3
Hello,

thanks for the patch.

Alon Bar-Lev <[hidden email]> writes:
> 1. Make setup.py executable when generated.

Please fix one issue per patch, that makes it way easier to review and
partially apply.

> 2. Add prepare target to enable prepare the source tree without building
>    anything. This is handy to enable standard distutils build outside of
>    gpgme build system.

That is a good idea indeed.

> 3. Treat data.h in similar manner as other VPATH issues, just copy it to
>    the srcdir to simplify build, remove the CFLAGS requirement of
>    distutils.

No.  Including data.h a hack, and the proper solution is to create a
proper API so that we don't need the layout of struct gpgme_data.  Also,
we don't relay the CFLAGS merely to locate data.h, we also like to
compile the glue code with the very same CFLAGS.

> 4. Add environment variable (binary_builddir) for setup to use alternate
>    build directory so that for multiple targets same binaries may be
>    used without rebuilding the C part.

I guess we could do that, yes.


Thanks,
Justus

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

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

[gpgme PATCH 1/3] build: python: setup.py should be executable

Alon Bar-Lev-3
Signed-off-by: Alon Bar-Lev <[hidden email]>
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 4a29f2f..efa1f19 100644
--- a/configure.ac
+++ b/configure.ac
@@ -886,9 +886,9 @@ 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/setup.py
  lang/python/pyme/version.py
  lang/python/tests/Makefile])
+AC_CONFIG_FILES([lang/python/setup.py], [chmod a+x lang/python/setup.py])
 AC_OUTPUT
 
 echo "
--
2.7.3


_______________________________________________
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

[gpgme PATCH 3/3] build: lang: python: move data.h, config.h to package

Alon Bar-Lev-3
to make it easy to build the subpackage using standard tools as
standalone without altering environment nor CFLAGS, symlink the
required artifacts from source tree into subpackage directory
when preparing sources.

although data.h should be put in public API, for now it is the simplest
solution that may be altered in future.

this is required for minimizing the chase of downstream packager to
apply upstream changes.

Signed-off-by: Alon Bar-Lev <[hidden email]>
---
 lang/python/Makefile.am | 15 ++++++++++-----
 lang/python/gpgme.i     |  2 +-
 lang/python/setup.py.in |  4 ----
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/lang/python/Makefile.am b/lang/python/Makefile.am
index ea37da9..9cb99c4 100644
--- a/lang/python/Makefile.am
+++ b/lang/python/Makefile.am
@@ -46,22 +46,27 @@ COPY_FILES_PYME = \
 
 # For VPATH builds we need to copy some files because Python's
 # distutils are not VPATH-aware.
-copystamp: $(COPY_FILES) $(COPY_FILES_PYME)
+copystamp: $(COPY_FILES) $(COPY_FILES_PYME) data.h config.h
  if test "$(srcdir)" != "$(builddir)" ; then \
   cp -R $(COPY_FILES) . ; \
   cp -R $(COPY_FILES_PYME) pyme ; \
  fi
  touch $@
 
+data.h:
+ ln -s "$(top_srcdir)/src/data.h"
+
+config.h:
+ ln -s "$(top_builddir)/config.h"
+
 all-local: copystamp
  for PYTHON in $(PYTHONS); do \
-  CFLAGS="$(CFLAGS) -I$(top_srcdir)" \
-  top_builddir="$(top_builddir)" \
+  CFLAGS="$(CFLAGS)" \
     $$PYTHON setup.py build --verbose ; \
  done
 
 dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc: copystamp
- CFLAGS="$(CFLAGS) -I$(top_srcdir)" \
+ CFLAGS="$(CFLAGS)" \
   $(PYTHON) setup.py sdist --verbose
  gpg2 --detach-sign --armor dist/pyme3-$(VERSION).tar.gz
 
@@ -76,7 +81,7 @@ upload: dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc
  twine upload $^
 
 CLEANFILES = gpgme.h errors.i gpgme_wrap.c pyme/gpgme.py \
-  copystamp
+  data.h config.h copystamp
 
 # Remove the rest.
 #
diff --git a/lang/python/gpgme.i b/lang/python/gpgme.i
index eaeb4f8..5d074aa 100644
--- a/lang/python/gpgme.i
+++ b/lang/python/gpgme.i
@@ -183,7 +183,7 @@
    representation of struct gpgme_data for an very efficient check if
    the buffer has been modified.  */
 %{
-#include "src/data.h" /* For struct gpgme_data.  */
+#include "data.h" /* For struct gpgme_data.  */
 %}
 #endif
 
diff --git a/lang/python/setup.py.in b/lang/python/setup.py.in
index 7af2d48..4c41673 100755
--- a/lang/python/setup.py.in
+++ b/lang/python/setup.py.in
@@ -39,10 +39,6 @@ if os.path.exists("../../src/gpgme-config"):
     in_tree = True
     gpgme_config = ["../../src/gpgme-config"] + gpgme_config_flags
     gpgme_h = "../../src/gpgme.h"
-    if 'top_builddir' in os.environ:
-        include_dirs.append(os.environ['top_builddir'])
-        # Make sure that SWIG finds config.h when processing gpgme.i.
-        extra_swig_opts.append("-I{0}".format(os.environ['top_builddir']))
     library_dirs = ["../../src/.libs"] # XXX uses libtool internals
     extra_macros.update(
         HAVE_CONFIG_H=1,
--
2.7.3


_______________________________________________
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

[gpgme PATCH 2/3] build: python: add prepare target

Alon Bar-Lev-3
In reply to this post by Alon Bar-Lev-3
this enables preparing the package using autoconf then build using
distutils as separate stage.

Signed-off-by: Alon Bar-Lev <[hidden email]>
---
 lang/python/Makefile.am | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lang/python/Makefile.am b/lang/python/Makefile.am
index 1d7aee8..ea37da9 100644
--- a/lang/python/Makefile.am
+++ b/lang/python/Makefile.am
@@ -65,6 +65,9 @@ dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc: copystamp
   $(PYTHON) setup.py sdist --verbose
  gpg2 --detach-sign --armor dist/pyme3-$(VERSION).tar.gz
 
+.PHONY: prepare
+prepare: copystamp
+
 .PHONY: sdist
 sdist: dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc
 
--
2.7.3


_______________________________________________
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: [gpgme PATCH 1/3] build: python: setup.py should be executable

Justus Winter
In reply to this post by Alon Bar-Lev-3
Alon Bar-Lev <[hidden email]> writes:

> Signed-off-by: Alon Bar-Lev <[hidden email]>
> ---
>  configure.ac | 2 +-

Thanks, I merged all the patches.  I did, however, amend the commit
messages.  Please at least make a habbit of looking how other commit
messages look like and try to make yours blend in.  Better yet, try to
find documentation on how the commit message should look like.  For the
GnuPG project, that documentation is in the gnupg repository,
doc/HACKING.

Justus

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

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

Re: [gpgme PATCH 1/3] build: python: setup.py should be executable

Werner Koch
On Fri, 30 Sep 2016 16:06, [hidden email] said:

> GnuPG project, that documentation is in the gnupg repository,
> doc/HACKING.

also found https://gnupg.org/faq/HACKING.html


--
Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.

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

attachment0 (167 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [gpgme PATCH 1/3] build: python: setup.py should be executable

Alon Bar-Lev-3
On 30 September 2016 at 17:26, Werner Koch <[hidden email]> wrote:
> On Fri, 30 Sep 2016 16:06, [hidden email] said:
>
>> GnuPG project, that documentation is in the gnupg repository,
>> doc/HACKING.
>
> also found https://gnupg.org/faq/HACKING.html
>

Guys, there is nothing wrong in you bit helping to perfect the work to
the exact method you like to have it for random contributions. The
important process is to understand the issue, agree on the solution
and provide close enough implementation. Yes, a quick note from you
and I would have fixed that as well, I waited first to see if there
are any farther comments about the method I introduced.

_______________________________________________
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: [gpgme PATCH 2/3] build: python: add prepare target

Alon Bar-Lev-3
In reply to this post by Alon Bar-Lev-3
Hi,

In gpgme-1.8 we added a "prepare" target to allow downstream packagers
to build python using their own python
wrappers skipping the custom autoconf/automake sequences.

The sequence was:
./configure
make
cd lang/python
make prepare
# run setup.py using standard distro distutils handling

In gpgme-1.9 this was broken as once again there is an assumption that
configure detects python versions and automake is capable of running
distutils, both are wrong assumptions.

It is OK that you try to improve the automake build/install of the
python module, however, please provide support for downstream to skip
this part without hacking/patching the package.

I will try to submit a patch to deal with this, please keep this
functionality intact.

Thanks!
Alon





On 29 September 2016 at 10:30, Alon Bar-Lev <[hidden email]> wrote:

> this enables preparing the package using autoconf then build using
> distutils as separate stage.
>
> Signed-off-by: Alon Bar-Lev <[hidden email]>
> ---
>  lang/python/Makefile.am | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/lang/python/Makefile.am b/lang/python/Makefile.am
> index 1d7aee8..ea37da9 100644
> --- a/lang/python/Makefile.am
> +++ b/lang/python/Makefile.am
> @@ -65,6 +65,9 @@ dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc: copystamp
>           $(PYTHON) setup.py sdist --verbose
>         gpg2 --detach-sign --armor dist/pyme3-$(VERSION).tar.gz
>
> +.PHONY: prepare
> +prepare: copystamp
> +
>  .PHONY: sdist
>  sdist: dist/pyme3-$(VERSION).tar.gz dist/pyme3-$(VERSION).tar.gz.asc
>
> --
> 2.7.3
>

_______________________________________________
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: [gpgme PATCH 2/3] build: python: add prepare target

Werner Koch
On Tue, 28 Mar 2017 19:45, [hidden email] said:

> I will try to submit a patch to deal with this, please keep this
> functionality intact.

Well we need a test for this to make sure it does not get lost.


Shalom-Salam,

   Werner

--
Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.

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

attachment0 (233 bytes) Download Attachment
Loading...