build,python: Support building Python bindings as nested package
* autogen-all.sh (packages): Add lang/python. * configure.ac: Add python to available languages if subdir exists. Add python to nested languages if enabled to generate corresponding make targets. Call configure script of nested python package recursively. * lang/python/configure.ac: Check if Python bindings are built as nested package and set GPGME_CFLAGS and GPGME_LIBS accordingly. * lang/python/setup.py.in: Define some variables where they are used first. Extract library directories from GPGME_LIBS variable similar to the extraction of include directories from GPGME_CFLAGS. Adjust library locations in case of win32 the same way as the include locations. Prefer gpgme.h in the include directories from GPGME_CFLAGS over the one in the prefix, so that the correct gpgme.h is taken in case of nested builds. -- This re-adds the ability to build the Python bindings together with gpgme with a single `configure && make` command (if building from git). GnuPG-bug-id: 7110
This commit is contained in:
parent
0b0a2881ff
commit
67ebc53b0f
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
prog=$(basename "$0")
|
prog=$(basename "$0")
|
||||||
|
|
||||||
packages=". lang/cpp lang/qt"
|
packages=". lang/cpp lang/qt lang/python"
|
||||||
|
|
||||||
fatal () {
|
fatal () {
|
||||||
echo "${prog}:" "$*" >&2
|
echo "${prog}:" "$*" >&2
|
||||||
|
10
configure.ac
10
configure.ac
@ -238,7 +238,7 @@ have_macos_system=no
|
|||||||
build_w32_glib=no
|
build_w32_glib=no
|
||||||
available_languages="cl"
|
available_languages="cl"
|
||||||
default_languages="cl"
|
default_languages="cl"
|
||||||
for lang in cpp qt; do
|
for lang in cpp qt python; do
|
||||||
if test -d $srcdir/lang/$lang; then
|
if test -d $srcdir/lang/$lang; then
|
||||||
available_languages="$available_languages $lang"
|
available_languages="$available_languages $lang"
|
||||||
fi
|
fi
|
||||||
@ -364,6 +364,10 @@ LIST_MEMBER("qt", $enabled_languages)
|
|||||||
if test "$found" = "1"; then
|
if test "$found" = "1"; then
|
||||||
nested_languages="$nested_languages qt"
|
nested_languages="$nested_languages qt"
|
||||||
fi
|
fi
|
||||||
|
LIST_MEMBER("python", $enabled_languages)
|
||||||
|
if test "$found" = "1"; then
|
||||||
|
nested_languages="$nested_languages python"
|
||||||
|
fi
|
||||||
|
|
||||||
AC_SUBST(NESTED_LANGUAGES, $nested_languages)
|
AC_SUBST(NESTED_LANGUAGES, $nested_languages)
|
||||||
|
|
||||||
@ -851,6 +855,10 @@ LIST_MEMBER("qt", $enabled_languages)
|
|||||||
if test "$found" = "1"; then
|
if test "$found" = "1"; then
|
||||||
AC_CONFIG_SUBDIRS([lang/qt])
|
AC_CONFIG_SUBDIRS([lang/qt])
|
||||||
fi
|
fi
|
||||||
|
LIST_MEMBER("python", $enabled_languages)
|
||||||
|
if test "$found" = "1"; then
|
||||||
|
AC_CONFIG_SUBDIRS([lang/python])
|
||||||
|
fi
|
||||||
|
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|
||||||
|
@ -409,8 +409,26 @@ AM_CONDITIONAL(USE_GPGRT_CONFIG, [test -n "$GPGRT_CONFIG" \
|
|||||||
|
|
||||||
# And for gpgme.
|
# And for gpgme.
|
||||||
have_gpgme=no
|
have_gpgme=no
|
||||||
AM_PATH_GPGME("$NEED_GPGME_VERSION",
|
builddir=`pwd`
|
||||||
|
# Check if Python bindings are built as nested package of gpgme
|
||||||
|
if test "${srcdir%/lang/python}/lang/python" == "$srcdir" -a \
|
||||||
|
"${builddir%/lang/python}/lang/python" == "$builddir"; then
|
||||||
|
AC_MSG_CHECKING(for GpgME - assuming nested build)
|
||||||
|
gpgme_build_dir=${builddir%/lang/python}
|
||||||
|
if test -f "$gpgme_build_dir/src/gpgme.h"; then
|
||||||
|
GPGME_CFLAGS="-I$gpgme_build_dir/src"
|
||||||
|
GPGME_LIBS="-L$gpgme_build_dir/src/.libs -lgpgme"
|
||||||
|
have_gpgme=yes
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "$have_gpgme" = "no"; then
|
||||||
|
AM_PATH_GPGME("$NEED_GPGME_VERSION",
|
||||||
have_gpgme=yes, have_gpgme=no)
|
have_gpgme=yes, have_gpgme=no)
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -33,10 +33,6 @@ import shutil
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
# Out-of-tree build of the gpg bindings.
|
|
||||||
gpgme_h = ''
|
|
||||||
include_dirs = [os.getcwd()]
|
|
||||||
library_dirs = []
|
|
||||||
|
|
||||||
if hasattr(subprocess, 'DEVNULL'):
|
if hasattr(subprocess, 'DEVNULL'):
|
||||||
devnull = subprocess.DEVNULL
|
devnull = subprocess.DEVNULL
|
||||||
@ -52,12 +48,17 @@ major, minor, patch = map(int, version.split('.'))
|
|||||||
if not (major > 1 or (major == 1 and minor >= 7)):
|
if not (major > 1 or (major == 1 and minor >= 7)):
|
||||||
sys.exit('Need at least GPGME version 1.7, found {}.'.format(version_raw))
|
sys.exit('Need at least GPGME version 1.7, found {}.'.format(version_raw))
|
||||||
|
|
||||||
define_macros = []
|
library_dirs = []
|
||||||
|
libs = []
|
||||||
if '@GPGME_LIBS@':
|
if '@GPGME_LIBS@':
|
||||||
libs = '@GPGME_LIBS@'.split(' ')
|
for item in '@GPGME_LIBS@'.split(' '):
|
||||||
else:
|
if item.startswith('-L'):
|
||||||
libs = []
|
library_dirs.append(item[2:])
|
||||||
|
else:
|
||||||
|
libs.append(item)
|
||||||
|
|
||||||
|
include_dirs = [os.getcwd()]
|
||||||
|
define_macros = []
|
||||||
if '@GPGME_CFLAGS@':
|
if '@GPGME_CFLAGS@':
|
||||||
for item in '@GPGME_CFLAGS@'.split(' '):
|
for item in '@GPGME_CFLAGS@'.split(' '):
|
||||||
if item.startswith('-I'):
|
if item.startswith('-I'):
|
||||||
@ -87,20 +88,20 @@ if uname_s.startswith('MINGW32'):
|
|||||||
extra_dirs.append(os.path.join(tgt, item))
|
extra_dirs.append(os.path.join(tgt, item))
|
||||||
break
|
break
|
||||||
include_dirs += extra_dirs
|
include_dirs += extra_dirs
|
||||||
for item in [x[2:] for x in libs if x.startswith('-L')]:
|
extra_dirs = []
|
||||||
|
for item in library_dirs:
|
||||||
for ln, mnt, tgt in tmplist:
|
for ln, mnt, tgt in tmplist:
|
||||||
if item.startswith(mnt):
|
if item.startswith(mnt):
|
||||||
item = os.path.normpath(item[ln:])
|
item = os.path.normpath(item[ln:])
|
||||||
while item[0] == os.path.sep:
|
while item[0] == os.path.sep:
|
||||||
item = item[1:]
|
item = item[1:]
|
||||||
library_dirs.append(os.path.join(tgt, item))
|
extra_dirs.append(os.path.join(tgt, item))
|
||||||
break
|
break
|
||||||
|
library_dirs += extra_dirs
|
||||||
|
|
||||||
if not gpgme_h:
|
gpgme_h = None
|
||||||
if os.path.exists(os.path.join('@prefix@', 'include', 'gpgme.h')):
|
for include_dir in (include_dirs +
|
||||||
gpgme_h = os.path.join('@prefix@', 'include', 'gpgme.h')
|
[os.path.join('@prefix@', 'include'), '/usr/include']):
|
||||||
else:
|
|
||||||
for include_dir in (include_dirs or ['/usr/include']):
|
|
||||||
if os.path.exists(os.path.join(include_dir, 'gpgme.h')):
|
if os.path.exists(os.path.join(include_dir, 'gpgme.h')):
|
||||||
gpgme_h = os.path.join(include_dir, 'gpgme.h')
|
gpgme_h = os.path.join(include_dir, 'gpgme.h')
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user