| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| %py_byte_compile()\ |
| py2_byte_compile () {\ |
| python_binary="env PYTHONHASHSEED=0 %1"\ |
| bytecode_compilation_path="%2"\ |
| failure=0\ |
| find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -s -c 'import py_compile, sys; [py_compile.compile(f, dfile=f.partition("'"$RPM_BUILD_ROOT"'")[2], doraise=True) for f in sys.argv[1:]]' || failure=1\ |
| find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -s -O -c 'import py_compile, sys; [py_compile.compile(f, dfile=f.partition("'"$RPM_BUILD_ROOT"'")[2], doraise=True) for f in sys.argv[1:]]' || failure=1\ |
| test $failure -eq 0\ |
| }\ |
| \ |
| py3_byte_compile () {\ |
| python_binary="env PYTHONHASHSEED=0 %1"\ |
| bytecode_compilation_path="%2"\ |
| PYTHONPATH="%{_rpmconfigdir}/redhat" $python_binary -s -B -m compileall2 -o 0 -o 1 -s $RPM_BUILD_ROOT -p / $bytecode_compilation_path \ |
| }\ |
| \ |
| py39_byte_compile () {\ |
| python_binary="env PYTHONHASHSEED=0 %1"\ |
| bytecode_compilation_path="%2"\ |
| $python_binary -s -B -m compileall -o 0 -o 1 -s $RPM_BUILD_ROOT -p / $bytecode_compilation_path \ |
| }\ |
| \ |
| |
| [[ "%1" =~ " -" ]] && echo "ERROR py_byte_compile: Path to interpreter should not contain any arguments" >&2 && exit 1 \ |
| |
| python_version=$(%1 -c "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))") \ |
| |
| |
| if [ "$python_version" -ge 39 ]; then \ |
| py39_byte_compile "%1" "%2"; \ |
| elif [ "$python_version" -ge 34 ]; then \ |
| py3_byte_compile "%1" "%2"; \ |
| else \ |
| py2_byte_compile "%1" "%2"; \ |
| fi |