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