diff options
| author | Justus Winter <[email protected]> | 2016-05-11 09:42:00 +0000 | 
|---|---|---|
| committer | Justus Winter <[email protected]> | 2016-05-11 11:33:05 +0000 | 
| commit | a29babd07cf9f9625d2b5aa2eb6b7bc9d1828359 (patch) | |
| tree | 5d59f8ab48f2d2f3db1ef70dcb9ca760444635cc /lang/python | |
| parent | python: PEP8 fixes. (diff) | |
| download | gpgme-a29babd07cf9f9625d2b5aa2eb6b7bc9d1828359.tar.gz gpgme-a29babd07cf9f9625d2b5aa2eb6b7bc9d1828359.zip | |
python: Integrate into the build system.
* configure.ac: Make Python bindings configurable, add new Makefile.
* lang/python/Makefile.am: New file.
* lang/python/setup.py: Integrate into the build system.
* m4/ax_pkg_swig.m4: New file from the autoconf archive.
* m4/m4_ax_swig_python.m4: Likewise.
Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to '')
| -rw-r--r-- | lang/python/Makefile.am | 53 | ||||
| -rwxr-xr-x | lang/python/setup.py | 42 | 
2 files changed, 65 insertions, 30 deletions
| diff --git a/lang/python/Makefile.am b/lang/python/Makefile.am new file mode 100644 index 00000000..a1a2bc92 --- /dev/null +++ b/lang/python/Makefile.am @@ -0,0 +1,53 @@ +# 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 General Public License as published by +# the Free Software Foundation; either version 2 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.rst + +# Cleanup gpgme.h from deprecated functions and typedefs. +gpgme.h: ../../src/gpgme.h +	$(PYTHON) $(srcdir)/gpgme-h-clean.py $< >$@ + +# For VPATH builds we need to copy some files because Python's +# distutils are not VPATH-aware. +copystamp: $(srcdir)/pyme $(srcdir)/helpers.c $(srcdir)/helpers.h +	if test "$(srcdir)" != "$(builddir)" ; then cp -a $^ . ; fi +	touch $@ + +gpgme_wrap.c pyme/pygpgme.py: gpgme.i gpgme.h copystamp +	$(SWIG) -python -py3 $(SWIGOPT) \ +	  -o $(builddir)/gpgme_wrap.c -outdir $(builddir)/pyme \ +	  $< + +all-local: gpgme_wrap.c pyme/pygpgme.py copystamp +	$(PYTHON) $(srcdir)/setup.py build --verbose + +clean-local: +	rm -rf -- build gpgme.h gpgme_wrap.c pyme/pygpgme.py copystamp +	if test "$(srcdir)" != "$(builddir)" ; then \ +	  rm -rf pyme helpers.c helpers.h ; \ +	fi + +install-exec-local: +	$(PYTHON) $(srcdir)/setup.py install \ +	  --prefix $(DESTDIR)$(prefix) \ +	  --record $(DESTDIR)$(pythondir)/pyme/install_files.txt \ +	  --verbose + +uninstall-local: +	xargs <$(DESTDIR)$(pythondir)/pyme/install_files.txt -- rm -rf -- +	rm -rf -- $(DESTDIR)$(pythondir)/pyme diff --git a/lang/python/setup.py b/lang/python/setup.py index 562c08f4..f3d91431 100755 --- a/lang/python/setup.py +++ b/lang/python/setup.py @@ -22,31 +22,23 @@  #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA  # END OF COPYRIGHT # -  from distutils.core import setup, Extension -from distutils.command.build_ext import build_ext  import os, os.path, sys  import subprocess -sys.path.append("pyme") -import version +sys.path.insert(0, os.path.dirname(__file__)) +import pyme.version  def getconfig(what): -    try: -        process = subprocess.Popen(["gpgme-config", "--%s" % what], -                                   stdout=subprocess.PIPE) -        confdata = process.communicate()[0] -    except OSError as e: -         if e.errno == os.errno.ENOENT: -             raise RuntimeError("Could not call gpgme-config, perhaps install libgpgme-dev") -         else: -             raise +    confdata = subprocess.Popen(["../../src/gpgme-config", "--%s" % what], +                                stdout=subprocess.PIPE).communicate()[0]      return [x for x in confdata.decode('utf-8').split() if x != '']  include_dirs = [os.getcwd()]  define_macros = [] -library_dirs = [] +library_dirs = ["../../src/.libs"] # XXX uses libtool internals  libs = getconfig('libs') +  for item in getconfig('cflags'):      if item.startswith("-I"):          include_dirs.append(item[2:]) @@ -82,16 +74,6 @@ if uname_s.startswith("MINGW32"):                 library_dirs.append(os.path.join(tgt, item))                 break -try: -    subprocess.call("swig") -except OSError as e: -    if e.errno == os.errno.ENOENT: -        raise RuntimeError("Could not call swig, perhaps install swig.") -    else: -        raise - -subprocess.call(["make swig"], shell=True) -  swige = Extension("pyme._pygpgme", ["gpgme_wrap.c", "helpers.c"],                    include_dirs = include_dirs,                    define_macros = define_macros, @@ -99,15 +81,15 @@ swige = Extension("pyme._pygpgme", ["gpgme_wrap.c", "helpers.c"],                    extra_link_args = libs)  setup(name = "pyme", -      version = version.versionstr, -      description = version.description, -      author = version.author, -      author_email = version.author_email, -      url = version.homepage, +      version=pyme.version.versionstr, +      description=pyme.version.description, +      author=pyme.version.author, +      author_email=pyme.version.author_email, +      url=pyme.version.homepage,        ext_modules=[swige],        packages = ['pyme', 'pyme.constants', 'pyme.constants.data',                    'pyme.constants.keylist', 'pyme.constants.sig'], -      license = version.copyright + \ +      license=pyme.version.copyright + \                  ", Licensed under the GPL version 2 and the LGPL version 2.1"  ) | 
