Blame SOURCES/0003-build-parametrize-Python-invocations-in-the-shebangs.patch

b8c11e
From 31133e8ac07c08b607ee7799c0074c1dce37a952 Mon Sep 17 00:00:00 2001
b8c11e
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
b8c11e
Date: Wed, 11 Jul 2018 14:18:50 +0200
b8c11e
Subject: [PATCH] build: parametrize Python invocations in the shebangs
b8c11e
MIME-Version: 1.0
b8c11e
Content-Type: text/plain; charset=UTF-8
b8c11e
Content-Transfer-Encoding: 8bit
b8c11e
b8c11e
Consequently, there's no reason to have the affected files marked as
b8c11e
executable (processing the files by the means of AC_CONFIG_FILES will
b8c11e
get rid of any such permission bits, anyway), but at the very least,
b8c11e
test/runtests.py needs to be set executable afterwards so as no to
b8c11e
cause failures with the current "make check" arrangement that invokes
b8c11e
TESTS subtargets directly (i.e. no extension-based LOG_COMPILER set).
b8c11e
b8c11e
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
b8c11e
---
b8c11e
 configure.ac                             | 12 +++++++++++-
b8c11e
 script/{unit-test.py => unit-test.py.in} |  2 +-
b8c11e
 test/{runtests.py => runtests.py.in}     |  2 +-
b8c11e
 3 files changed, 13 insertions(+), 3 deletions(-)
b8c11e
 rename script/{unit-test.py => unit-test.py.in} (99%)
b8c11e
 mode change 100755 => 100644
b8c11e
 rename test/{runtests.py => runtests.py.in} (98%)
b8c11e
 mode change 100755 => 100644
b8c11e
b8c11e
diff --git a/configure.ac b/configure.ac
b8c11e
index 3bf41b3..a6ad86e 100644
b8c11e
--- a/configure.ac
b8c11e
+++ b/configure.ac
b8c11e
@@ -97,6 +97,14 @@ CPPFLAGS="$CPPFLAGS $XML2HEAD"
b8c11e
 
b8c11e
 PKG_CHECK_MODULES(GLIB, [glib-2.0])
b8c11e
 
b8c11e
+# Python casing, prefer 3.3+ to 2.{6...}
b8c11e
+AM_PATH_PYTHON([3.3], , [PYTHON=:])
b8c11e
+if test "x$PYTHON" = x:; then
b8c11e
+	AM_PATH_PYTHON([2.6])
b8c11e
+fi
b8c11e
+PYTHON_SHEBANG="$PYTHON ${PYTHON_OPTS--Es}"
b8c11e
+AC_ARG_VAR([PYTHON_SHEBANG], [Python invocation used in shebangs])
b8c11e
+
b8c11e
 # Checks for header files.
b8c11e
 AC_FUNC_ALLOCA
b8c11e
 AC_HEADER_DIRENT
b8c11e
@@ -157,7 +165,9 @@ AC_CONFIG_FILES([Makefile
b8c11e
 		 docs/Makefile
b8c11e
 		 conf/Makefile])
b8c11e
 AC_CONFIG_FILES([conf/booth-arbitrator.service conf/booth@.service])
b8c11e
-
b8c11e
+AC_CONFIG_FILES([script/unit-test.py test/runtests.py],
b8c11e
+		dnl Following required at least for "make check"
b8c11e
+		[chmod +x test/runtests.py])
b8c11e
 AC_CONFIG_FILES([script/service-runnable], [chmod +x script/service-runnable])
b8c11e
 
b8c11e
 # ===============================================
b8c11e
diff --git a/script/unit-test.py b/script/unit-test.py.in
b8c11e
old mode 100755
b8c11e
new mode 100644
b8c11e
similarity index 99%
b8c11e
rename from script/unit-test.py
b8c11e
rename to script/unit-test.py.in
b8c11e
index 399528e..4f3cf62
b8c11e
--- a/script/unit-test.py
b8c11e
+++ b/script/unit-test.py.in
b8c11e
@@ -1,4 +1,4 @@
b8c11e
-#!/usr/bin/python
b8c11e
+#!@PYTHON_SHEBANG@
b8c11e
 # vim: fileencoding=utf-8
b8c11e
 # see http://stackoverflow.com/questions/728891/correct-way-to-define-python-source-code-encoding
b8c11e
 # NOTE: setting the encoding is needed as non-ASCII characters are contained
b8c11e
diff --git a/test/runtests.py b/test/runtests.py.in
b8c11e
old mode 100755
b8c11e
new mode 100644
b8c11e
similarity index 98%
b8c11e
rename from test/runtests.py
b8c11e
rename to test/runtests.py.in
b8c11e
index 833b1a7..ec59159
b8c11e
--- a/test/runtests.py
b8c11e
+++ b/test/runtests.py.in
b8c11e
@@ -1,4 +1,4 @@
b8c11e
-#!/usr/bin/python
b8c11e
+#!@PYTHON_SHEBANG@
b8c11e
 
b8c11e
 import os
b8c11e
 import re
b8c11e
-- 
b8c11e
2.18.0.rc2
b8c11e