diff options
author | Justus Winter <[email protected]> | 2016-06-09 10:38:50 +0000 |
---|---|---|
committer | Justus Winter <[email protected]> | 2016-06-16 12:07:41 +0000 |
commit | 7eef399d89d4c3877cb795ed5ba45ecb241e67be (patch) | |
tree | 288b45feafce4887c6b4153f0088da874e7c611e /lang/python/setup.py.in | |
parent | python: Fix exception leak. (diff) | |
download | gpgme-7eef399d89d4c3877cb795ed5ba45ecb241e67be.tar.gz gpgme-7eef399d89d4c3877cb795ed5ba45ecb241e67be.zip |
python: Get version information from the build system.
* configure.ac: Generate 'setup.py' and 'version.py'.
* lang/python/Makefile.am: Use generated setup script.
* lang/python/pyme/version.py: Turn it into a template, and get
version information from the build system. Also drop some variables.
* lang/python/setup.py: Likewise. This way we can avoid importing the
version module, which is frowned upon and actually caused a problem.
Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to 'lang/python/setup.py.in')
-rwxr-xr-x | lang/python/setup.py.in | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/lang/python/setup.py.in b/lang/python/setup.py.in new file mode 100755 index 00000000..9e6e0085 --- /dev/null +++ b/lang/python/setup.py.in @@ -0,0 +1,86 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2016 g10 Code GmbH +# Copyright (C) 2004 Igor Belyi <[email protected]> +# Copyright (C) 2002 John Goerzen <[email protected]> +# +# 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 + +from distutils.core import setup, Extension +import os, os.path, sys +import subprocess + +def getconfig(what): + 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 = ["../../src/.libs"] # XXX uses libtool internals +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 + +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@", + description='Python bindings for GPGME GnuPG cryptography library', + author='The GnuPG hackers', + author_email='[email protected]', + url='https://www.gnupg.org', + ext_modules=[swige], + packages = ['pyme', 'pyme.constants', 'pyme.constants.data', + 'pyme.constants.keylist', 'pyme.constants.sig'], + license="LGPL2.1+ (the library), GPL2+ (tests and examples)" +) |