URL: https://github.com/SSSD/sssd/pull/653
Author: sumit-bose
 Title: #653: sbus: dectect python binary for sbus_generate.sh
Action: synchronized

To pull the PR as Git branch:
git remote add ghsssd https://github.com/SSSD/sssd
git fetch ghsssd pull/653/head:pr653
git checkout pr653
From 52399671b99a0efcd53d8aaf81ccaff1a77f38fb Mon Sep 17 00:00:00 2001
From: Sumit Bose <sb...@redhat.com>
Date: Mon, 10 Sep 2018 15:40:14 +0200
Subject: [PATCH] sbus: dectect python binary for sbus_generate.sh

We already detect python2 and python3 binaries during configure. With
this patch PYTHON_EXEC is set to the python3 binary if python3 bindings
are generated and to the python2 binary otherwise. With the help of an
environment variable sbus_generate.sh is made aware of it.

Related to https://pagure.io/SSSD/sssd/issue/3807
---
 Makefile.am      | 2 +-
 configure.ac     | 7 +++++++
 sbus_generate.sh | 3 ++-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 11d040500..5fb09e8e3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1020,7 +1020,7 @@ libsss_cert_la_LDFLAGS = \
     $(NULL)
 
 generate-sbus-code:
-	$(srcdir)/sbus_generate.sh $(abs_srcdir)
+	PYTHON=$(PYTHON_EXEC) $(srcdir)/sbus_generate.sh $(abs_srcdir)
 
 .PHONY: generate-sbus-code
 
diff --git a/configure.ac b/configure.ac
index 1aac65f4d..6e38feda4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -373,6 +373,13 @@ them please use argument --without-python3-bindings when running configure.])])
     SSS_CLEAN_PYTHON_VARIABLES
 fi
 
+if test x$HAVE_PYTHON3_BINDINGS = x1; then
+    PYTHON_EXEC=$PYTHON3
+else
+    PYTHON_EXEC=$PYTHON2
+fi
+AC_SUBST(PYTHON_EXEC)
+
 AM_CONDITIONAL([BUILD_PYTHON_BINDINGS],
                [test x"$with_python2_bindings" = xyes \
                      -o x"$with_python3_bindings" = xyes])
diff --git a/sbus_generate.sh b/sbus_generate.sh
index 338fd9d33..c130a4c17 100755
--- a/sbus_generate.sh
+++ b/sbus_generate.sh
@@ -2,6 +2,7 @@
 
 SRCDIR=$1
 CODEGEN="$SRCDIR/src/sbus/codegen/sbus_CodeGen.py"
+PYTHON=${PYTHON:=$(command -v python python3 python2 | head -n1)}
 
 generate() {
     XML=$1
@@ -13,7 +14,7 @@ generate() {
 
     echo "Generating sbus code for: $XML"
 
-    python $CODEGEN --sbus sbus --util util \
+    $PYTHON $CODEGEN --sbus sbus --util util \
         --headers "$HEADERS" \
         --dest "$SRCDIR/src/$DEST" \
         --fileprefix "sbus_${PREFIX}_" \
_______________________________________________
sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org
To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedorahosted.org/archives/list/sssd-devel@lists.fedorahosted.org

Reply via email to