From f4ba16b31ea282d0787a40be3f37b951584143a1 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Tue, 10 May 2016 13:19:26 +0200 Subject: python: Rename bindings. -- Signed-off-by: Justus Winter --- lang/python/setup.py | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100755 lang/python/setup.py (limited to 'lang/python/setup.py') diff --git a/lang/python/setup.py b/lang/python/setup.py new file mode 100755 index 00000000..b0ed3b2c --- /dev/null +++ b/lang/python/setup.py @@ -0,0 +1,113 @@ +#!/usr/bin/env python3 + +# $Id$ + +# Module: installer +# COPYRIGHT # +# Copyright (C) 2004 Igor Belyi +# Copyright (C) 2002 John Goerzen +# +# This library 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. +# +# This library 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 library; if not, write to the Free Software +# 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 + +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 + return [x for x in confdata.decode('utf-8').split() if x != ''] + +include_dirs = [os.getcwd()] +define_macros = [] +library_dirs = [] +libs = getconfig('libs') +for item in getconfig('cflags'): + if item.startswith("-I"): + include_dirs.append(item[2:]) + elif item.startswith("-D"): + defitem = item[2:].split("=", 1) + if len(defitem)==2: + define_macros.append((defitem[0], defitem[1])) + else: + define_macros.append((defitem[0], None)) + +# Adjust include and library locations in case of win32 +uname_s = os.popen("uname -s").read() +if uname_s.startswith("MINGW32"): + mnts = [x.split()[0:3:2] for x in os.popen("mount").read().split("\n") if x] + tmplist = sorted([(len(x[1]), x[1], x[0]) for x in mnts]) + tmplist.reverse() + extra_dirs = [] + for item in include_dirs: + for ln, mnt, tgt in tmplist: + if item.startswith(mnt): + item = os.path.normpath(item[ln:]) + while item[0] == os.path.sep: + item = item[1:] + extra_dirs.append(os.path.join(tgt, item)) + break + include_dirs += extra_dirs + for item in [x[2:] for x in libs if x.startswith("-L")]: + for ln, mnt, tgt in tmplist: + if item.startswith(mnt): + item = os.path.normpath(item[ln:]) + while item[0] == os.path.sep: + item = item[1:] + 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, + library_dirs = library_dirs, + extra_link_args = libs) + +setup(name = "pyme", + version = version.versionstr, + description = version.description, + author = version.author, + author_email = version.author_email, + url = version.homepage, + ext_modules=[swige], + packages = ['pyme', 'pyme.constants', 'pyme.constants.data', + 'pyme.constants.keylist', 'pyme.constants.sig'], + license = version.copyright + \ + ", Licensed under the GPL version 2 and the LGPL version 2.1" +) + -- cgit v1.2.3 From aade53a12b9716997684b872bc2ac87229f73fb3 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Tue, 10 May 2016 13:30:30 +0200 Subject: python: Delete trailing whitespace. -- Signed-off-by: Justus Winter --- lang/python/setup.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lang/python/setup.py') diff --git a/lang/python/setup.py b/lang/python/setup.py index b0ed3b2c..562c08f4 100755 --- a/lang/python/setup.py +++ b/lang/python/setup.py @@ -60,7 +60,7 @@ for item in getconfig('cflags'): # Adjust include and library locations in case of win32 uname_s = os.popen("uname -s").read() if uname_s.startswith("MINGW32"): - mnts = [x.split()[0:3:2] for x in os.popen("mount").read().split("\n") if x] + mnts = [x.split()[0:3:2] for x in os.popen("mount").read().split("\n") if x] tmplist = sorted([(len(x[1]), x[1], x[0]) for x in mnts]) tmplist.reverse() extra_dirs = [] @@ -89,9 +89,9 @@ except OSError as e: 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, @@ -106,7 +106,7 @@ setup(name = "pyme", url = version.homepage, ext_modules=[swige], packages = ['pyme', 'pyme.constants', 'pyme.constants.data', - 'pyme.constants.keylist', 'pyme.constants.sig'], + 'pyme.constants.keylist', 'pyme.constants.sig'], license = version.copyright + \ ", Licensed under the GPL version 2 and the LGPL version 2.1" ) -- cgit v1.2.3 From a29babd07cf9f9625d2b5aa2eb6b7bc9d1828359 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Wed, 11 May 2016 11:42:00 +0200 Subject: 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 --- lang/python/setup.py | 42 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 30 deletions(-) (limited to 'lang/python/setup.py') 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" ) -- cgit v1.2.3