diff --git a/brp-python-bytecompile b/brp-python-bytecompile index ead7022..71f4d2d 100755 --- a/brp-python-bytecompile +++ b/brp-python-bytecompile @@ -38,7 +38,7 @@ function python_bytecompile() local options=$1 local python_binary=$2 local exclude=$3 - local python_libdir=$4 + local python_libdir="$4" local depth=$5 # Not used for Python >= 3.4 local real_libdir=$6 # Not used for Python >= 3.4 @@ -57,7 +57,7 @@ function python_bytecompile() # -x and -e together implements the same functionality as the Filter class below # -s strips $RPM_BUILD_ROOT from the path # -p prepends the leading slash to the path to make it absolute - $python_binary -B $options -m compileall -q -f $exclude -s $RPM_BUILD_ROOT -p / -e $RPM_BUILD_ROOT $python_libdir + $python_binary -B $options -m compileall -q -f $exclude -s "$RPM_BUILD_ROOT" -p / -e "$RPM_BUILD_ROOT" "$python_libdir" # # Python 3.4 and higher @@ -73,7 +73,7 @@ function python_bytecompile() # -x and -e together implements the same functionality as the Filter class below # -s strips $RPM_BUILD_ROOT from the path # -p prepends the leading slash to the path to make it absolute - PYTHONPATH=/usr/lib/rpm/redhat/ $python_binary -B $options -m compileall2 -q -f $exclude -s $RPM_BUILD_ROOT -p / -e $RPM_BUILD_ROOT $python_libdir + PYTHONPATH=/usr/lib/rpm/redhat/ $python_binary -B $options -m compileall2 -q -f $exclude -s "$RPM_BUILD_ROOT" -p / -e "$RPM_BUILD_ROOT" "$python_libdir" else # # Python 3.3 and lower (incl. Python 2) @@ -119,9 +119,9 @@ fi export PYTHONHASHSEED=0 shopt -s nullglob -for python_libdir in `find "$RPM_BUILD_ROOT" -type d|grep -E "/(usr|app)/lib(64)?/python[0-9]\.[0-9]+$"`; +find "$RPM_BUILD_ROOT" -type d -print0|grep -z -E "/(usr|app)/lib(64)?/python[0-9]\.[0-9]+$" | while read -d "" python_libdir; do - python_binary=$(basename $python_libdir) + python_binary=$(basename "$python_libdir") real_libdir=${python_libdir/$RPM_BUILD_ROOT/} echo "Bytecompiling .py files below $python_libdir using $python_binary"