2016-09-14 08:51:49 +00:00
|
|
|
#!/usr/bin/env python
|
2015-05-05 17:09:44 +00:00
|
|
|
|
2018-08-18 08:19:16 +00:00
|
|
|
# Copyright (C) 2016-2018 g10 Code GmbH
|
2017-04-03 13:44:14 +00:00
|
|
|
# Copyright (C) 2004,2008 Igor Belyi <belyi@users.sourceforge.net>
|
2015-05-05 17:09:44 +00:00
|
|
|
# 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
|
|
|
|
|
2024-05-29 13:17:58 +00:00
|
|
|
try:
|
|
|
|
from setuptools import setup, Extension
|
|
|
|
from setuptools.command.build import build
|
|
|
|
except ImportError:
|
|
|
|
from distutils.core import setup, Extension
|
|
|
|
from distutils.command.build import build
|
2018-08-18 08:19:16 +00:00
|
|
|
|
2016-07-11 14:38:37 +00:00
|
|
|
import glob
|
2018-08-18 08:19:16 +00:00
|
|
|
import os
|
|
|
|
import os.path
|
2017-04-03 13:44:14 +00:00
|
|
|
import re
|
2017-04-01 23:29:52 +00:00
|
|
|
import shutil
|
2015-05-05 17:09:44 +00:00
|
|
|
import subprocess
|
2018-08-18 08:19:16 +00:00
|
|
|
import sys
|
2015-05-05 17:09:44 +00:00
|
|
|
|
2016-10-28 20:45:49 +00:00
|
|
|
# Out-of-tree build of the gpg bindings.
|
2018-11-30 20:45:50 +00:00
|
|
|
gpgme_h = ''
|
2016-09-26 09:35:40 +00:00
|
|
|
include_dirs = [os.getcwd()]
|
2016-07-11 14:38:37 +00:00
|
|
|
library_dirs = []
|
|
|
|
|
2018-11-30 20:45:50 +00:00
|
|
|
if hasattr(subprocess, 'DEVNULL'):
|
2016-09-12 14:18:31 +00:00
|
|
|
devnull = subprocess.DEVNULL
|
|
|
|
else:
|
2018-11-30 20:45:50 +00:00
|
|
|
devnull = open(os.devnull, 'w')
|
2016-09-12 14:18:31 +00:00
|
|
|
|
2016-07-11 14:38:37 +00:00
|
|
|
|
2022-09-15 04:46:23 +00:00
|
|
|
version = version_raw = "@VERSION@"
|
2016-07-11 14:38:37 +00:00
|
|
|
if '-' in version:
|
|
|
|
version = version.split('-')[0]
|
|
|
|
major, minor, patch = map(int, version.split('.'))
|
|
|
|
|
2016-11-09 12:56:00 +00:00
|
|
|
if not (major > 1 or (major == 1 and minor >= 7)):
|
|
|
|
sys.exit('Need at least GPGME version 1.7, found {}.'.format(version_raw))
|
2016-07-11 14:38:37 +00:00
|
|
|
|
2015-05-05 17:09:44 +00:00
|
|
|
define_macros = []
|
build,python: Separate Python bindings from gpgme
* configure.ac: Remove "python" from available_languages and from
default_languages.
Remove checks for SWIG and available Python versions.
Remove substitution of PYTHONS.
Remove generation of files in lang/python.
* lang/Makefile.am (DIST_SUBDIRS): Remove python.
* lang/python/.gitignore, lang/python/AUTHORS, lang/python/COPYING,
lang/python/COPYING.LESSER, lang/python/ChangeLog, lang/python/INSTALL,
lang/python/NEWS, lang/python/autogen.rc, lang/python/autogen.sh,
lang/python/configure.ac: New.
* lang/python/Makefile.am (EXTRA_DIST): Add autogen.sh, autogen.rc.
copystamp: Remove symbolic linking of gpgme's internal data.h header
and of gpgme's config.h file.
CLEANFILES: Remove cleaning of config.h and data.h.
(RELEASE_ARCHIVE_SUFFIX, ACLOCAL_AMFLAGS, dist-hook, distcheck-hook,
.PHONY, gen_start_date, gen-ChangeLog, RELEASE_NAME, release,
sign-release): New (copied from top-level Makefile.am).
* lang/python/build-aux/compile, lang/python/build-aux/config.guess,
lang/python/build-aux/config.sub, lang/python/build-aux/depcomp,
lang/python/build-aux/install-sh,
lang/python/build-aux/libtool-patch.sed,
lang/python/build-aux/ltmain.sh, lang/python/build-aux/missing: New.
* m4/ax_pkg_swig.m4: Move to...
* lang/python/m4/ax_pkg_swig.m4: ...here.
* m4/ax_python_devel.m4: Move to...
* lang/python/m4/ax_python_devel.m4: ...here.
* m4/python.m4: Move to...
* lang/python/m4/python.m4: ...here.
* lang/python/m4/gpg-error.m4, lang/python/m4/gpgme.m4,
lang/python/m4/libassuan.m4, lang/python/m4/libtool.m4,
lang/python/m4/ltoptions.m4, lang/python/m4/ltsugar.m4,
lang/python/m4/ltversion.m4, lang/python/m4/lt~obsolete.m4: New.
* lang/python/setup.py.in: Remove code for in-tree builds. Initialize
libs from @GPGME_LIBS@ instead of @GPGME_CONFIG_LIBS@. Initialize
include_dirs and define_macros from @GPGME_CFLAGS@ instead of
@GPGME_CONFIG_CFLAGS@. Look for gpgme.h in @prefix@/include and in
include_dirs and '/usr/include'.
* lang/python/tests/13CBE3758AFE42B5E5E2AE4CED27AFA455E3F87F,
lang/python/tests/13CD0F3BDF24BE53FE192D62F18737256FF6E4FD,
lang/python/tests/76F7E2B35832976B50A27A282D9B87E44577EB66,
lang/python/tests/7A030357C0F253A5BBCD282FFC4E521B37558F5C,
lang/python/tests/A0747D5F9425E6664F4FFBEED20FBCA79FDED2BD: New.
* lang/python/tests/Makefile.am (test_srcdir): Remove.
(TESTS_ENVIRONMENT): Remove adding .libs directory with gpgme library
to LD_LIBRARYPATH.
(private_keys): Use local copies instead of files from gpgme's
tests.
(EXTRA_DIST): Add new files.
(clean-local): Call local copy of start-stop-agent script.
(gpg-sample.stamp): Use local copies of private keys.
(pubring-stamp): Use local copies of pubdemo.asc and secdemo.asc.
(gpg-agent.conf): Use local copy of pinentry helper.
* lang/python/tests/cipher-1.asc, lang/python/tests/cipher-2.asc,
lang/python/tests/cipher-3.asc, lang/python/tests/cipher-no-sig.asc,
lang/python/tests/pinentry, lang/python/tests/pubdemo.asc,
lang/python/tests/pubkey-1.asc, lang/python/tests/secdemo.asc,
lang/python/tests/seckey-1.asc, lang/python/tests/start-stop-agent:
New.
* lang/python/tests/support.py (make_filename): Adapt to changed
path of test files.
--
This makes building and distributing the Python bindings independent of
the sources of gpgme. Many of the new files are copied from gpgme to
make the Python bindings a self-contained package. A later commit
re-adds the possibility to build the Python bindings as nested package
together with gpgme.
GnuPG-bug-id: 7110
2024-05-29 12:24:30 +00:00
|
|
|
if '@GPGME_LIBS@':
|
|
|
|
libs = '@GPGME_LIBS@'.split(' ')
|
2022-10-26 02:02:36 +00:00
|
|
|
else:
|
|
|
|
libs = []
|
2016-05-11 09:42:00 +00:00
|
|
|
|
build,python: Separate Python bindings from gpgme
* configure.ac: Remove "python" from available_languages and from
default_languages.
Remove checks for SWIG and available Python versions.
Remove substitution of PYTHONS.
Remove generation of files in lang/python.
* lang/Makefile.am (DIST_SUBDIRS): Remove python.
* lang/python/.gitignore, lang/python/AUTHORS, lang/python/COPYING,
lang/python/COPYING.LESSER, lang/python/ChangeLog, lang/python/INSTALL,
lang/python/NEWS, lang/python/autogen.rc, lang/python/autogen.sh,
lang/python/configure.ac: New.
* lang/python/Makefile.am (EXTRA_DIST): Add autogen.sh, autogen.rc.
copystamp: Remove symbolic linking of gpgme's internal data.h header
and of gpgme's config.h file.
CLEANFILES: Remove cleaning of config.h and data.h.
(RELEASE_ARCHIVE_SUFFIX, ACLOCAL_AMFLAGS, dist-hook, distcheck-hook,
.PHONY, gen_start_date, gen-ChangeLog, RELEASE_NAME, release,
sign-release): New (copied from top-level Makefile.am).
* lang/python/build-aux/compile, lang/python/build-aux/config.guess,
lang/python/build-aux/config.sub, lang/python/build-aux/depcomp,
lang/python/build-aux/install-sh,
lang/python/build-aux/libtool-patch.sed,
lang/python/build-aux/ltmain.sh, lang/python/build-aux/missing: New.
* m4/ax_pkg_swig.m4: Move to...
* lang/python/m4/ax_pkg_swig.m4: ...here.
* m4/ax_python_devel.m4: Move to...
* lang/python/m4/ax_python_devel.m4: ...here.
* m4/python.m4: Move to...
* lang/python/m4/python.m4: ...here.
* lang/python/m4/gpg-error.m4, lang/python/m4/gpgme.m4,
lang/python/m4/libassuan.m4, lang/python/m4/libtool.m4,
lang/python/m4/ltoptions.m4, lang/python/m4/ltsugar.m4,
lang/python/m4/ltversion.m4, lang/python/m4/lt~obsolete.m4: New.
* lang/python/setup.py.in: Remove code for in-tree builds. Initialize
libs from @GPGME_LIBS@ instead of @GPGME_CONFIG_LIBS@. Initialize
include_dirs and define_macros from @GPGME_CFLAGS@ instead of
@GPGME_CONFIG_CFLAGS@. Look for gpgme.h in @prefix@/include and in
include_dirs and '/usr/include'.
* lang/python/tests/13CBE3758AFE42B5E5E2AE4CED27AFA455E3F87F,
lang/python/tests/13CD0F3BDF24BE53FE192D62F18737256FF6E4FD,
lang/python/tests/76F7E2B35832976B50A27A282D9B87E44577EB66,
lang/python/tests/7A030357C0F253A5BBCD282FFC4E521B37558F5C,
lang/python/tests/A0747D5F9425E6664F4FFBEED20FBCA79FDED2BD: New.
* lang/python/tests/Makefile.am (test_srcdir): Remove.
(TESTS_ENVIRONMENT): Remove adding .libs directory with gpgme library
to LD_LIBRARYPATH.
(private_keys): Use local copies instead of files from gpgme's
tests.
(EXTRA_DIST): Add new files.
(clean-local): Call local copy of start-stop-agent script.
(gpg-sample.stamp): Use local copies of private keys.
(pubring-stamp): Use local copies of pubdemo.asc and secdemo.asc.
(gpg-agent.conf): Use local copy of pinentry helper.
* lang/python/tests/cipher-1.asc, lang/python/tests/cipher-2.asc,
lang/python/tests/cipher-3.asc, lang/python/tests/cipher-no-sig.asc,
lang/python/tests/pinentry, lang/python/tests/pubdemo.asc,
lang/python/tests/pubkey-1.asc, lang/python/tests/secdemo.asc,
lang/python/tests/seckey-1.asc, lang/python/tests/start-stop-agent:
New.
* lang/python/tests/support.py (make_filename): Adapt to changed
path of test files.
--
This makes building and distributing the Python bindings independent of
the sources of gpgme. Many of the new files are copied from gpgme to
make the Python bindings a self-contained package. A later commit
re-adds the possibility to build the Python bindings as nested package
together with gpgme.
GnuPG-bug-id: 7110
2024-05-29 12:24:30 +00:00
|
|
|
if '@GPGME_CFLAGS@':
|
|
|
|
for item in '@GPGME_CFLAGS@'.split(' '):
|
2022-10-26 02:02:36 +00:00
|
|
|
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))
|
2015-05-05 17:09:44 +00:00
|
|
|
|
|
|
|
# Adjust include and library locations in case of win32
|
2018-11-30 20:45:50 +00:00
|
|
|
uname_s = os.popen('uname -s').read()
|
|
|
|
if uname_s.startswith('MINGW32'):
|
2018-08-18 08:19:16 +00:00
|
|
|
mnts = [
|
2018-11-30 20:45:50 +00:00
|
|
|
x.split()[0:3:2] for x in os.popen('mount').read().split('\n') if x
|
2018-08-18 08:19:16 +00:00
|
|
|
]
|
|
|
|
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
|
2018-11-30 20:45:50 +00:00
|
|
|
for item in [x[2:] for x in libs if x.startswith('-L')]:
|
2018-08-18 08:19:16 +00:00
|
|
|
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
|
|
|
|
|
build,python: Separate Python bindings from gpgme
* configure.ac: Remove "python" from available_languages and from
default_languages.
Remove checks for SWIG and available Python versions.
Remove substitution of PYTHONS.
Remove generation of files in lang/python.
* lang/Makefile.am (DIST_SUBDIRS): Remove python.
* lang/python/.gitignore, lang/python/AUTHORS, lang/python/COPYING,
lang/python/COPYING.LESSER, lang/python/ChangeLog, lang/python/INSTALL,
lang/python/NEWS, lang/python/autogen.rc, lang/python/autogen.sh,
lang/python/configure.ac: New.
* lang/python/Makefile.am (EXTRA_DIST): Add autogen.sh, autogen.rc.
copystamp: Remove symbolic linking of gpgme's internal data.h header
and of gpgme's config.h file.
CLEANFILES: Remove cleaning of config.h and data.h.
(RELEASE_ARCHIVE_SUFFIX, ACLOCAL_AMFLAGS, dist-hook, distcheck-hook,
.PHONY, gen_start_date, gen-ChangeLog, RELEASE_NAME, release,
sign-release): New (copied from top-level Makefile.am).
* lang/python/build-aux/compile, lang/python/build-aux/config.guess,
lang/python/build-aux/config.sub, lang/python/build-aux/depcomp,
lang/python/build-aux/install-sh,
lang/python/build-aux/libtool-patch.sed,
lang/python/build-aux/ltmain.sh, lang/python/build-aux/missing: New.
* m4/ax_pkg_swig.m4: Move to...
* lang/python/m4/ax_pkg_swig.m4: ...here.
* m4/ax_python_devel.m4: Move to...
* lang/python/m4/ax_python_devel.m4: ...here.
* m4/python.m4: Move to...
* lang/python/m4/python.m4: ...here.
* lang/python/m4/gpg-error.m4, lang/python/m4/gpgme.m4,
lang/python/m4/libassuan.m4, lang/python/m4/libtool.m4,
lang/python/m4/ltoptions.m4, lang/python/m4/ltsugar.m4,
lang/python/m4/ltversion.m4, lang/python/m4/lt~obsolete.m4: New.
* lang/python/setup.py.in: Remove code for in-tree builds. Initialize
libs from @GPGME_LIBS@ instead of @GPGME_CONFIG_LIBS@. Initialize
include_dirs and define_macros from @GPGME_CFLAGS@ instead of
@GPGME_CONFIG_CFLAGS@. Look for gpgme.h in @prefix@/include and in
include_dirs and '/usr/include'.
* lang/python/tests/13CBE3758AFE42B5E5E2AE4CED27AFA455E3F87F,
lang/python/tests/13CD0F3BDF24BE53FE192D62F18737256FF6E4FD,
lang/python/tests/76F7E2B35832976B50A27A282D9B87E44577EB66,
lang/python/tests/7A030357C0F253A5BBCD282FFC4E521B37558F5C,
lang/python/tests/A0747D5F9425E6664F4FFBEED20FBCA79FDED2BD: New.
* lang/python/tests/Makefile.am (test_srcdir): Remove.
(TESTS_ENVIRONMENT): Remove adding .libs directory with gpgme library
to LD_LIBRARYPATH.
(private_keys): Use local copies instead of files from gpgme's
tests.
(EXTRA_DIST): Add new files.
(clean-local): Call local copy of start-stop-agent script.
(gpg-sample.stamp): Use local copies of private keys.
(pubring-stamp): Use local copies of pubdemo.asc and secdemo.asc.
(gpg-agent.conf): Use local copy of pinentry helper.
* lang/python/tests/cipher-1.asc, lang/python/tests/cipher-2.asc,
lang/python/tests/cipher-3.asc, lang/python/tests/cipher-no-sig.asc,
lang/python/tests/pinentry, lang/python/tests/pubdemo.asc,
lang/python/tests/pubkey-1.asc, lang/python/tests/secdemo.asc,
lang/python/tests/seckey-1.asc, lang/python/tests/start-stop-agent:
New.
* lang/python/tests/support.py (make_filename): Adapt to changed
path of test files.
--
This makes building and distributing the Python bindings independent of
the sources of gpgme. Many of the new files are copied from gpgme to
make the Python bindings a self-contained package. A later commit
re-adds the possibility to build the Python bindings as nested package
together with gpgme.
GnuPG-bug-id: 7110
2024-05-29 12:24:30 +00:00
|
|
|
if not gpgme_h:
|
|
|
|
if os.path.exists(os.path.join('@prefix@', 'include', 'gpgme.h')):
|
|
|
|
gpgme_h = os.path.join('@prefix@', 'include', 'gpgme.h')
|
|
|
|
else:
|
|
|
|
for include_dir in (include_dirs or ['/usr/include']):
|
|
|
|
if os.path.exists(os.path.join(include_dir, 'gpgme.h')):
|
|
|
|
gpgme_h = os.path.join(include_dir, 'gpgme.h')
|
|
|
|
break
|
|
|
|
|
|
|
|
if not gpgme_h:
|
|
|
|
sys.exit('gpgme.h not found.')
|
|
|
|
|
2015-05-05 17:09:44 +00:00
|
|
|
|
2017-04-03 13:44:14 +00:00
|
|
|
def in_srcdir(name):
|
2018-11-30 20:45:50 +00:00
|
|
|
return os.path.join(os.environ.get('srcdir', ''), name)
|
2018-08-18 08:19:16 +00:00
|
|
|
|
|
|
|
|
2017-04-03 13:44:14 +00:00
|
|
|
def up_to_date(source, target):
|
2018-08-18 08:19:16 +00:00
|
|
|
return (os.path.exists(target) and
|
|
|
|
os.path.getmtime(source) <= os.path.getmtime(target))
|
|
|
|
|
2017-04-03 13:44:14 +00:00
|
|
|
|
2016-07-11 14:38:37 +00:00
|
|
|
# We build an Extension using SWIG, which generates a Python module.
|
|
|
|
# By default, the 'build_py' step is run before 'build_ext', and
|
|
|
|
# therefore the generated Python module is not copied into the build
|
|
|
|
# directory.
|
2018-08-18 08:19:16 +00:00
|
|
|
# Bugs: https://bugs.python.org/issue1016626
|
|
|
|
# https://bugs.python.org/issue2624
|
2016-07-11 14:38:37 +00:00
|
|
|
# Workaround:
|
2018-08-18 08:19:16 +00:00
|
|
|
# https://stackoverflow.com/questions/12491328/python-distutils-not-include-the-swig-generated-module
|
2018-08-18 14:21:47 +00:00
|
|
|
#
|
|
|
|
# To install to multiple Python installations or to alternate ones run the
|
|
|
|
# following three commands (yes, run the build one twice):
|
|
|
|
#
|
|
|
|
# /path/to/pythonX.Y setup.py build
|
|
|
|
# /path/to/pythonX.Y setup.py build
|
|
|
|
# /path/to/pythonX.Y setup.py install
|
|
|
|
#
|
|
|
|
# It is highly likely that this will need to be run as root or with sudo (or
|
|
|
|
# sudo -H). It may or may not work with venv. and outside a virtualenv
|
2018-08-18 08:19:16 +00:00
|
|
|
|
|
|
|
class BuildExtFirstHack(build):
|
2017-04-08 13:34:32 +00:00
|
|
|
def _read_header(self, header, cflags):
|
2018-11-30 20:45:50 +00:00
|
|
|
tmp_include = self._in_build_base('include1.h')
|
2017-04-08 13:34:32 +00:00
|
|
|
with open(tmp_include, 'w') as f:
|
2018-11-30 20:45:50 +00:00
|
|
|
f.write('#include <%s>' % header)
|
2018-08-18 08:19:16 +00:00
|
|
|
return subprocess.check_output(
|
|
|
|
os.environ.get('CPP', 'cc -E').split() + cflags +
|
|
|
|
[tmp_include]).decode('utf-8')
|
2017-04-08 13:34:32 +00:00
|
|
|
|
|
|
|
def _write_if_unchanged(self, target, content):
|
|
|
|
if os.path.exists(target):
|
|
|
|
with open(target) as f:
|
|
|
|
if f.read() == content:
|
|
|
|
return
|
|
|
|
|
2018-11-30 20:45:50 +00:00
|
|
|
with open(target, 'w') as sink:
|
2017-04-08 13:34:32 +00:00
|
|
|
sink.write(content)
|
|
|
|
|
2017-04-03 13:44:14 +00:00
|
|
|
def _generate_gpgme_h(self, source_name, sink_name):
|
2018-11-30 20:45:50 +00:00
|
|
|
print('Using gpgme.h from {}'.format(source_name))
|
2018-02-20 16:34:14 +00:00
|
|
|
shutil.copy2(source_name, sink_name)
|
2017-04-03 13:44:14 +00:00
|
|
|
|
2017-04-08 13:34:32 +00:00
|
|
|
def _generate_errors_i(self):
|
|
|
|
|
2022-10-26 02:02:36 +00:00
|
|
|
ge_cflags='@GPG_ERROR_CFLAGS@'
|
2018-08-18 08:19:16 +00:00
|
|
|
gpg_error_content = self._read_header(
|
2022-10-26 02:02:36 +00:00
|
|
|
'gpg-error.h', ge_cflags.split(' ') if ge_cflags else [])
|
2017-04-03 13:44:14 +00:00
|
|
|
|
|
|
|
filter_re = re.compile(r'GPG_ERR_[^ ]* =')
|
|
|
|
rewrite_re = re.compile(r' *(.*) = .*')
|
|
|
|
|
2017-04-08 13:34:32 +00:00
|
|
|
errors_i_content = ''
|
|
|
|
for line in gpg_error_content.splitlines():
|
|
|
|
if not filter_re.search(line):
|
|
|
|
continue
|
2018-08-18 08:19:16 +00:00
|
|
|
errors_i_content += rewrite_re.sub(
|
|
|
|
r'%constant long \1 = \1;' + '\n', line.strip())
|
2017-04-08 13:34:32 +00:00
|
|
|
|
2018-08-18 08:19:16 +00:00
|
|
|
self._write_if_unchanged(
|
2018-11-30 20:45:50 +00:00
|
|
|
self._in_build_base('errors.i'), errors_i_content)
|
2017-04-03 13:44:14 +00:00
|
|
|
|
2017-04-07 14:31:47 +00:00
|
|
|
def _in_build_base(self, name):
|
|
|
|
return os.path.join(self.build_base, name)
|
|
|
|
|
2017-04-01 23:29:52 +00:00
|
|
|
def _generate(self):
|
|
|
|
# Cleanup gpgme.h from deprecated functions and typedefs.
|
|
|
|
if not os.path.exists(self.build_base):
|
|
|
|
os.makedirs(self.build_base)
|
|
|
|
|
2018-11-30 20:45:50 +00:00
|
|
|
self._generate_gpgme_h(gpgme_h, self._in_build_base('gpgme.h'))
|
2017-04-08 13:34:32 +00:00
|
|
|
self._generate_errors_i()
|
2017-04-03 13:44:14 +00:00
|
|
|
|
2018-10-18 04:10:19 +00:00
|
|
|
# Copy due to https://bugs.python.org/issue2624
|
2017-04-01 23:29:52 +00:00
|
|
|
# Avoid creating in srcdir
|
2017-04-07 14:31:47 +00:00
|
|
|
for source, target in ((in_srcdir(n), self._in_build_base(n))
|
2018-08-18 08:19:16 +00:00
|
|
|
for n in ('gpgme.i', 'helpers.c', 'private.h',
|
|
|
|
'helpers.h')):
|
2017-04-03 13:44:14 +00:00
|
|
|
if not up_to_date(source, target):
|
|
|
|
shutil.copy2(source, target)
|
2017-04-01 23:29:52 +00:00
|
|
|
|
|
|
|
# Append generated files via build_base
|
2018-11-30 20:45:50 +00:00
|
|
|
if not os.path.exists(os.path.join(self.build_lib, 'gpg')):
|
|
|
|
os.makedirs(os.path.join(self.build_lib, 'gpg'))
|
|
|
|
shutil.copy2('version.py', os.path.join(self.build_lib, 'gpg'))
|
2017-04-05 16:47:08 +00:00
|
|
|
|
|
|
|
def run(self):
|
|
|
|
self._generate()
|
2017-04-01 23:29:52 +00:00
|
|
|
|
2018-08-18 08:19:16 +00:00
|
|
|
swig_sources.extend((self._in_build_base('gpgme.i'),
|
|
|
|
self._in_build_base('helpers.c')))
|
|
|
|
swig_opts.extend([
|
|
|
|
'-I' + self.build_base, '-outdir',
|
|
|
|
os.path.join(self.build_lib, 'gpg')
|
|
|
|
])
|
2017-05-18 09:42:13 +00:00
|
|
|
include_dirs.insert(0, self.build_base)
|
2017-04-01 23:29:52 +00:00
|
|
|
|
2016-07-11 14:38:37 +00:00
|
|
|
self.run_command('build_ext')
|
|
|
|
build.run(self)
|
|
|
|
|
2018-08-18 08:19:16 +00:00
|
|
|
|
2017-04-07 14:31:47 +00:00
|
|
|
swig_sources = []
|
build,python: Separate Python bindings from gpgme
* configure.ac: Remove "python" from available_languages and from
default_languages.
Remove checks for SWIG and available Python versions.
Remove substitution of PYTHONS.
Remove generation of files in lang/python.
* lang/Makefile.am (DIST_SUBDIRS): Remove python.
* lang/python/.gitignore, lang/python/AUTHORS, lang/python/COPYING,
lang/python/COPYING.LESSER, lang/python/ChangeLog, lang/python/INSTALL,
lang/python/NEWS, lang/python/autogen.rc, lang/python/autogen.sh,
lang/python/configure.ac: New.
* lang/python/Makefile.am (EXTRA_DIST): Add autogen.sh, autogen.rc.
copystamp: Remove symbolic linking of gpgme's internal data.h header
and of gpgme's config.h file.
CLEANFILES: Remove cleaning of config.h and data.h.
(RELEASE_ARCHIVE_SUFFIX, ACLOCAL_AMFLAGS, dist-hook, distcheck-hook,
.PHONY, gen_start_date, gen-ChangeLog, RELEASE_NAME, release,
sign-release): New (copied from top-level Makefile.am).
* lang/python/build-aux/compile, lang/python/build-aux/config.guess,
lang/python/build-aux/config.sub, lang/python/build-aux/depcomp,
lang/python/build-aux/install-sh,
lang/python/build-aux/libtool-patch.sed,
lang/python/build-aux/ltmain.sh, lang/python/build-aux/missing: New.
* m4/ax_pkg_swig.m4: Move to...
* lang/python/m4/ax_pkg_swig.m4: ...here.
* m4/ax_python_devel.m4: Move to...
* lang/python/m4/ax_python_devel.m4: ...here.
* m4/python.m4: Move to...
* lang/python/m4/python.m4: ...here.
* lang/python/m4/gpg-error.m4, lang/python/m4/gpgme.m4,
lang/python/m4/libassuan.m4, lang/python/m4/libtool.m4,
lang/python/m4/ltoptions.m4, lang/python/m4/ltsugar.m4,
lang/python/m4/ltversion.m4, lang/python/m4/lt~obsolete.m4: New.
* lang/python/setup.py.in: Remove code for in-tree builds. Initialize
libs from @GPGME_LIBS@ instead of @GPGME_CONFIG_LIBS@. Initialize
include_dirs and define_macros from @GPGME_CFLAGS@ instead of
@GPGME_CONFIG_CFLAGS@. Look for gpgme.h in @prefix@/include and in
include_dirs and '/usr/include'.
* lang/python/tests/13CBE3758AFE42B5E5E2AE4CED27AFA455E3F87F,
lang/python/tests/13CD0F3BDF24BE53FE192D62F18737256FF6E4FD,
lang/python/tests/76F7E2B35832976B50A27A282D9B87E44577EB66,
lang/python/tests/7A030357C0F253A5BBCD282FFC4E521B37558F5C,
lang/python/tests/A0747D5F9425E6664F4FFBEED20FBCA79FDED2BD: New.
* lang/python/tests/Makefile.am (test_srcdir): Remove.
(TESTS_ENVIRONMENT): Remove adding .libs directory with gpgme library
to LD_LIBRARYPATH.
(private_keys): Use local copies instead of files from gpgme's
tests.
(EXTRA_DIST): Add new files.
(clean-local): Call local copy of start-stop-agent script.
(gpg-sample.stamp): Use local copies of private keys.
(pubring-stamp): Use local copies of pubdemo.asc and secdemo.asc.
(gpg-agent.conf): Use local copy of pinentry helper.
* lang/python/tests/cipher-1.asc, lang/python/tests/cipher-2.asc,
lang/python/tests/cipher-3.asc, lang/python/tests/cipher-no-sig.asc,
lang/python/tests/pinentry, lang/python/tests/pubdemo.asc,
lang/python/tests/pubkey-1.asc, lang/python/tests/secdemo.asc,
lang/python/tests/seckey-1.asc, lang/python/tests/start-stop-agent:
New.
* lang/python/tests/support.py (make_filename): Adapt to changed
path of test files.
--
This makes building and distributing the Python bindings independent of
the sources of gpgme. Many of the new files are copied from gpgme to
make the Python bindings a self-contained package. A later commit
re-adds the possibility to build the Python bindings as nested package
together with gpgme.
GnuPG-bug-id: 7110
2024-05-29 12:24:30 +00:00
|
|
|
swig_opts = ['-threads']
|
2018-08-18 08:19:16 +00:00
|
|
|
swige = Extension(
|
2018-11-30 20:45:50 +00:00
|
|
|
'gpg._gpgme',
|
2018-08-18 08:19:16 +00:00
|
|
|
sources=swig_sources,
|
|
|
|
swig_opts=swig_opts,
|
|
|
|
include_dirs=include_dirs,
|
|
|
|
define_macros=define_macros,
|
|
|
|
library_dirs=library_dirs,
|
|
|
|
extra_link_args=libs)
|
|
|
|
|
|
|
|
setup(
|
2018-11-30 20:45:50 +00:00
|
|
|
name='gpg',
|
2018-08-18 08:19:16 +00:00
|
|
|
cmdclass={'build': BuildExtFirstHack},
|
2018-11-30 20:45:50 +00:00
|
|
|
version='@VERSION@',
|
|
|
|
# Note: description appears as Summary in egg-info file.
|
|
|
|
description='Python bindings to the GPGME API of the GnuPG cryptography library.',
|
|
|
|
# Note: long-description appears as Description in egg-info file.
|
|
|
|
long_description='''Dynamically generated bindings to the C API of the GNU Privacy Guard.
|
|
|
|
|
|
|
|
The GPG Made Easy (GPGME) library provides a high-level API in C to all the
|
|
|
|
component software and libraries in the GnuPG Project, including GPG itself
|
|
|
|
(the GnuPG OpenPGP implementation), libgcrypt, libgpg-error, libassuan and
|
|
|
|
more.
|
|
|
|
|
|
|
|
The official CPython bindings to GPGME are generated during the compiling
|
|
|
|
process of GPGME itself and built for the specific C header and include files
|
|
|
|
produced when GPGME is compiled using SWIG. This provides access to over two
|
|
|
|
thousand functions, methods and values via both the lower level dynamically
|
|
|
|
generated bindings and a more intuitively pythonic higher level layer.
|
|
|
|
|
|
|
|
While the lower level, dynamically generated bindings provide access to
|
|
|
|
everything which GPGME itself provides; the higher level layer is easier to use
|
|
|
|
by Python developers, provides access to the vast majority of functionality
|
|
|
|
developers would want from GnuPG and is extensively documented.
|
|
|
|
|
|
|
|
GPGME and these bindings is available here:
|
|
|
|
|
|
|
|
https://gnupg.org/software/gpgme/index.html
|
|
|
|
''',
|
2018-08-18 08:19:16 +00:00
|
|
|
author='The GnuPG hackers',
|
|
|
|
author_email='gnupg-devel@gnupg.org',
|
|
|
|
url='https://www.gnupg.org',
|
|
|
|
ext_modules=[swige],
|
|
|
|
packages=[
|
|
|
|
'gpg', 'gpg.constants', 'gpg.constants.data', 'gpg.constants.keylist',
|
|
|
|
'gpg.constants.sig', 'gpg.constants.tofu'
|
|
|
|
],
|
2018-11-30 20:45:50 +00:00
|
|
|
license='LGPL2.1+ (the library), GPL2+ (tests and examples)',
|
2018-08-18 08:19:16 +00:00
|
|
|
classifiers=[
|
|
|
|
'Development Status :: 4 - Beta',
|
|
|
|
'Intended Audience :: Developers',
|
|
|
|
'License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)',
|
|
|
|
'Programming Language :: Python :: 2',
|
|
|
|
'Programming Language :: Python :: 2.7',
|
|
|
|
'Programming Language :: Python :: 3',
|
|
|
|
'Programming Language :: Python :: 3.6',
|
2024-05-29 13:17:58 +00:00
|
|
|
'Programming Language :: Python :: 3.8',
|
|
|
|
'Programming Language :: Python :: 3.9',
|
|
|
|
'Programming Language :: Python :: 3.10',
|
|
|
|
'Programming Language :: Python :: 3.11',
|
|
|
|
'Programming Language :: Python :: 3.12',
|
2018-08-18 08:19:16 +00:00
|
|
|
'Operating System :: POSIX',
|
|
|
|
'Operating System :: Microsoft :: Windows',
|
|
|
|
'Topic :: Communications :: Email',
|
|
|
|
'Topic :: Security :: Cryptography',
|
|
|
|
],
|
2015-05-05 17:09:44 +00:00
|
|
|
)
|