1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
#!/usr/bin/env python
# $Id: setup.py,v 1.8 2008/11/24 21:44:30 belyi Exp $
# Module: installer
# COPYRIGHT #
# Copyright (C) 2004 Igor Belyi <belyi@users.sourceforge.net>
# Copyright (C) 2002 John Goerzen <jgoerzen@complete.org>
#
# 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
sys.path.append("pyme")
import version
def getconfig(what):
cmd = os.popen("sh -c 'gpgme-config --%s'" % what, "r")
confdata = cmd.read()
confdata = confdata.replace("\n", " ")
assert cmd.close() == None, "error getting GPG config"
confdata = confdata.replace(" ", " ")
return [x for x in confdata.split(' ') if x != '']
include_dirs = [os.getcwd()]
define_macros = [("_FILE_OFFSET_BITS", "64"), ("LARGEFILE_SOURCE", None)]
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 = [(len(x[1]), x[1], x[0]) for x in mnts]
tmplist.sort()
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 = "pygpgme",
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"
)
|