Blame SOURCES/macros.pybytecompile

61e6f0
# Note that the path could itself be a python file, or a directory
61e6f0
61e6f0
# Python's compile_all module only works on directories, and requires a max
61e6f0
# recursion depth
61e6f0
61e6f0
# Usage:
61e6f0
#    %py_byte_compile <interpereter> <path>
61e6f0
# Example:
61e6f0
#    %py_byte_compile %{__python3} %{buildroot}%{_datadir}/spam/plugins/
61e6f0
61e6f0
# This will terminate build on SyntaxErrors, if you want to avoid that,
61e6f0
# use it in a subshell like this:
61e6f0
#    (%{py_byte_compile <interpereter> <path>}) || :
61e6f0
61e6f0
%py_byte_compile()\
61e6f0
python_binary="%1"\
61e6f0
buildroot_path="%2"\
61e6f0
bytecode_compilation_path=".${buildroot_path/#$RPM_BUILD_ROOT}"\
61e6f0
failure=0\
61e6f0
pushd $RPM_BUILD_ROOT\
61e6f0
find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -O -m py_compile || failure=1\
61e6f0
find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -m py_compile || failure=1\
61e6f0
popd\
61e6f0
test $failure -eq 0