summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2015-02-10 17:22:03 +0100
committerJakub Hrozek <jhrozek@redhat.com>2015-02-25 08:38:40 +0100
commit4a5a18f489f4d19aa0571528a7f0c7a8d35ac83f (patch)
tree3a9381a56ce6a7e2635b354208d202a1dcca9975 /src
parent4706958e7505ce279f06cb2bf413eb38ee8f114c (diff)
downloadsssd-4a5a18f489f4d19aa0571528a7f0c7a8d35ac83f.tar.gz
sssd-4a5a18f489f4d19aa0571528a7f0c7a8d35ac83f.tar.xz
sssd-4a5a18f489f4d19aa0571528a7f0c7a8d35ac83f.zip
BUILD: Add possibility to build python{2,3} bindings
Resolves: https://fedorahosted.org/sssd/ticket/2574 Reviewed-by: Stephen Gallagher <sgallagh@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/conf_macros.m439
-rwxr-xr-xsrc/tests/pyhbac-test.py22
-rwxr-xr-xsrc/tests/pysss_murmur-test.py22
3 files changed, 66 insertions, 17 deletions
diff --git a/src/conf_macros.m4 b/src/conf_macros.m4
index 027490e52..ff49f8442 100644
--- a/src/conf_macros.m4
+++ b/src/conf_macros.m4
@@ -360,21 +360,38 @@ AC_DEFUN([WITH_KRB5_CONF],
AC_DEFINE_UNQUOTED([KRB5_CONF_PATH], ["$KRB5_CONF_PATH"], [KRB5 configuration file])
])
-AC_DEFUN([WITH_PYTHON_BINDINGS],
- [ AC_ARG_WITH([python-bindings],
- [AC_HELP_STRING([--with-python-bindings],
- [Whether to build python bindings [yes]]
- )
+AC_DEFUN([WITH_PYTHON2_BINDINGS],
+ [ AC_ARG_WITH([python2-bindings],
+ [AC_HELP_STRING([--with-python2-bindings],
+ [Whether to build python2 bindings [yes]])
+ ],
+ [],
+ [with_python2_bindings=yes]
+ )
+ if test x"$with_python2_bindings" = xyes; then
+ AC_SUBST([HAVE_PYTHON2_BINDINGS], [1])
+ AC_DEFINE_UNQUOTED([HAVE_PYTHON2_BINDINGS], [1],
+ [Build with python2 bindings])
+ fi
+ AM_CONDITIONAL([BUILD_PYTHON2_BINDINGS],
+ [test x"$with_python2_bindings" = xyes])
+ ])
+
+AC_DEFUN([WITH_PYTHON3_BINDINGS],
+ [ AC_ARG_WITH([python3-bindings],
+ [AC_HELP_STRING([--with-python3-bindings],
+ [Whether to build python3 bindings [yes]])
],
[],
- with_python_bindings=yes
+ [with_python3_bindings=no]
)
- if test x"$with_python_bindings" = xyes; then
- HAVE_PYTHON_BINDINGS=1
- AC_SUBST(HAVE_PYTHON_BINDINGS)
- AC_DEFINE_UNQUOTED(HAVE_PYTHON_BINDINGS, 1, [Build with python bindings])
+ if test x"$with_python3_bindings" = xyes; then
+ AC_SUBST([HAVE_PYTHON3_BINDINGS], [1])
+ AC_DEFINE_UNQUOTED([HAVE_PYTHON3_BINDINGS], [1],
+ [Build with python3 bindings])
fi
- AM_CONDITIONAL([BUILD_PYTHON_BINDINGS], [test x"$with_python_bindings" = xyes])
+ AM_CONDITIONAL([BUILD_PYTHON3_BINDINGS],
+ [test x"$with_python3_bindings" = xyes])
])
AC_DEFUN([WITH_SELINUX],
diff --git a/src/tests/pyhbac-test.py b/src/tests/pyhbac-test.py
index 0abc5703d..83958d7bf 100755
--- a/src/tests/pyhbac-test.py
+++ b/src/tests/pyhbac-test.py
@@ -6,10 +6,9 @@ import sys
import os
import copy
import sys
+import errno
-srcdir = os.getenv('builddir')
-if not srcdir:
- srcdir = "."
+srcdir = os.getenv('builddir') or "."
MODPATH = srcdir + "/.libs" #FIXME - is there a way to get this from libtool?
if sys.version_info[0] > 2:
@@ -41,6 +40,23 @@ class PyHbacImport(unittest.TestCase):
def testImport(self):
" Import the module and assert it comes from tree "
try:
+ cwd_backup = os.getcwd()
+
+ try:
+ os.unlink(MODPATH + "/pyhbac.so")
+ except OSError as e:
+ if e.errno == errno.ENOENT:
+ pass
+ else:
+ raise e
+
+ os.chdir(MODPATH)
+ if sys.version_info[0] > 2:
+ os.symlink("_py3hbac.so", "pyhbac.so")
+ else:
+ os.symlink("_py2hbac.so", "pyhbac.so")
+ os.chdir(cwd_backup)
+
import pyhbac
except ImportError as e:
print("Could not load the pyhbac module. Please check if it is compiled", file=sys.stderr)
diff --git a/src/tests/pysss_murmur-test.py b/src/tests/pysss_murmur-test.py
index 0b28f45e6..faa8bb2d3 100755
--- a/src/tests/pysss_murmur-test.py
+++ b/src/tests/pysss_murmur-test.py
@@ -23,10 +23,9 @@ import unittest
import sys
import os
import copy
+import errno
-srcdir = os.getenv('builddir')
-if not srcdir:
- srcdir = "."
+srcdir = os.getenv('builddir') or "."
MODPATH = srcdir + "/.libs" #FIXME - is there a way to get this from libtool?
def compat_assertItemsEqual(this, expected_seq, actual_seq, msg=None):
@@ -57,6 +56,23 @@ class PySssMurmurImport(unittest.TestCase):
def testImport(self):
" Import the module and assert it comes from tree "
try:
+ cwd_backup = os.getcwd()
+
+ try:
+ os.unlink(MODPATH + "/pysss_murmur.so")
+ except OSError as e:
+ if e.errno == errno.ENOENT:
+ pass
+ else:
+ raise e
+
+ os.chdir(MODPATH)
+ if sys.version_info[0] > 2:
+ os.symlink("_py3sss_murmur.so", "pysss_murmur.so")
+ else:
+ os.symlink("_py2sss_murmur.so", "pysss_murmur.so")
+ os.chdir(cwd_backup)
+
import pysss_murmur
except ImportError as e:
print("Could not load the pysss_murmur module. Please check if it is compiled", file=sys.stderr)