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

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