Petr Viktorin 3f65cd
diff --git a/scripts/brp-python-bytecompile b/scripts/brp-python-bytecompile
Petr Viktorin 3f65cd
index 894fa3459..47776215a 100644
Petr Viktorin 3f65cd
--- a/scripts/brp-python-bytecompile
Petr Viktorin 3f65cd
+++ b/scripts/brp-python-bytecompile
Petr Viktorin 3f65cd
@@ -87,6 +87,10 @@ if [ ! -x "$default_python" ]; then
Petr Viktorin 3f65cd
 	exit 0
Petr Viktorin 3f65cd
 fi
Petr Viktorin 3f65cd
 
Petr Viktorin 3f65cd
+# Figure out if there are files to be bytecompiled with the default_python at all
Petr Viktorin 3f65cd
+# this prevents unnecessary default_python invocation
Petr Viktorin 3f65cd
+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
Petr Viktorin 3f65cd
+
Petr Viktorin 3f65cd
 # Generate normal (.pyc) byte-compiled files.
Petr Viktorin 3f65cd
 python_bytecompile "" $default_python "/bin/|/sbin/|/usr/lib(64)?/python[0-9]\.[0-9]|/usr/share/doc" "$RPM_BUILD_ROOT" "$depth" "/"
Petr Viktorin 3f65cd
 if [ $? -ne 0 -a 0$errors_terminate -ne 0 ]; then