churchyard / rpms / rpm

Forked from rpms/rpm 6 years ago
Clone
3f65cd7
diff --git a/scripts/brp-python-bytecompile b/scripts/brp-python-bytecompile
364d038
index 894fa34..c06bdfa 100644
3f65cd7
--- a/scripts/brp-python-bytecompile
3f65cd7
+++ b/scripts/brp-python-bytecompile
364d038
@@ -1,5 +1,6 @@
364d038
 #!/bin/bash
364d038
 errors_terminate=$2
364d038
+extra=$3
364d038
 
364d038
 # If using normal root, avoid changing anything.
364d038
 if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
364d038
@@ -79,14 +80,22 @@ do
364d038
 done
364d038
 
364d038
 
364d038
-# Handle other locations in the filesystem using the default python
364d038
-# implementation - if we  have a default python interpreter
364d038
+# Handle other locations in the filesystem using the default python implementation
364d038
+# if extra is set to 0, don't do this
364d038
+if [ 0$extra -eq 0 ]; then
364d038
+	exit 0
364d038
+fi
364d038
 
364d038
+# If we don't have a default python interpreter, we cannot proceed
364d038
 default_python=${1:-/usr/bin/python}
364d038
 if [ ! -x "$default_python" ]; then
3f65cd7
 	exit 0
3f65cd7
 fi
3f65cd7
 
3f65cd7
+# Figure out if there are files to be bytecompiled with the default_python at all
3f65cd7
+# this prevents unnecessary default_python invocation
3f65cd7
+find "$RPM_BUILD_ROOT" -type f -name "*.py" | grep -Ev "/bin/|/sbin/|/usr/lib(64)?/python[0-9]\.[0-9]|/usr/share/doc" || exit 0
3f65cd7
+
3f65cd7
 # Generate normal (.pyc) byte-compiled files.
3f65cd7
 python_bytecompile "" $default_python "/bin/|/sbin/|/usr/lib(64)?/python[0-9]\.[0-9]|/usr/share/doc" "$RPM_BUILD_ROOT" "$depth" "/"
3f65cd7
 if [ $? -ne 0 -a 0$errors_terminate -ne 0 ]; then