Bytecompilation: Pass --invalidation-mode=timestamp to compileall
(Only on Python 3.7+, where it exists and matters.) This will replace patch 328 in Python and fix https://bugzilla.redhat.com/2133850
This commit is contained in:
parent
eb7a4fda28
commit
e4baf5ab7e
@ -47,6 +47,15 @@ function python_bytecompile()
|
|||||||
compileall_module=compileall2
|
compileall_module=compileall2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$python_version" -ge 37 ]; then
|
||||||
|
# Force the TIMESTAMP invalidation mode
|
||||||
|
invalidation_option=--invalidation-mode=timestamp
|
||||||
|
else
|
||||||
|
# For older Pythons, the option does not exist
|
||||||
|
# as the invalidation is always based on size+mtime
|
||||||
|
invalidation_option=
|
||||||
|
fi
|
||||||
|
|
||||||
[ ! -z $exclude ] && exclude="-x '$exclude'"
|
[ ! -z $exclude ] && exclude="-x '$exclude'"
|
||||||
|
|
||||||
# PYTHONPATH is needed for compileall2, but doesn't hurt for the stdlib
|
# PYTHONPATH is needed for compileall2, but doesn't hurt for the stdlib
|
||||||
@ -58,7 +67,7 @@ function python_bytecompile()
|
|||||||
# -x and -e together implements the same functionality as the Filter class below
|
# -x and -e together implements the same functionality as the Filter class below
|
||||||
# -s strips $RPM_BUILD_ROOT from the path
|
# -s strips $RPM_BUILD_ROOT from the path
|
||||||
# -p prepends the leading slash to the path to make it absolute
|
# -p prepends the leading slash to the path to make it absolute
|
||||||
PYTHONPATH=/usr/lib/rpm/redhat/ $python_binary -B -m $compileall_module -o 0 -o 1 -q -f $exclude -s "$RPM_BUILD_ROOT" -p / --hardlink-dupes -e "$RPM_BUILD_ROOT" "$python_libdir"
|
PYTHONPATH=/usr/lib/rpm/redhat/ $python_binary -B -m $compileall_module -o 0 -o 1 -q -f $exclude -s "$RPM_BUILD_ROOT" -p / --hardlink-dupes $invalidation_option -e "$RPM_BUILD_ROOT" "$python_libdir"
|
||||||
|
|
||||||
else
|
else
|
||||||
#
|
#
|
||||||
|
@ -26,16 +26,21 @@ py2_byte_compile () {\
|
|||||||
test $failure -eq 0\
|
test $failure -eq 0\
|
||||||
}\
|
}\
|
||||||
\
|
\
|
||||||
py3_byte_compile () {\
|
py34_byte_compile () {\
|
||||||
python_binary="%{__env_unset_source_date_epoch_if_not_clamp_mtime} PYTHONHASHSEED=0 %1"\
|
python_binary="%{__env_unset_source_date_epoch_if_not_clamp_mtime} PYTHONHASHSEED=0 %1"\
|
||||||
bytecode_compilation_path="%2"\
|
bytecode_compilation_path="%2"\
|
||||||
PYTHONPATH="%{_rpmconfigdir}/redhat" $python_binary -s -B -m compileall2 -o 0 -o 1 -s $RPM_BUILD_ROOT -p / --hardlink-dupes $bytecode_compilation_path \
|
PYTHONPATH="%{_rpmconfigdir}/redhat" $python_binary -s -B -m compileall2 -o 0 -o 1 -s $RPM_BUILD_ROOT -p / --hardlink-dupes $bytecode_compilation_path \
|
||||||
}\
|
}\
|
||||||
|
py37_byte_compile () {\
|
||||||
|
python_binary="%{__env_unset_source_date_epoch_if_not_clamp_mtime} 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 / --hardlink-dupes --invalidation-mode=timestamp $bytecode_compilation_path \
|
||||||
|
}\
|
||||||
\
|
\
|
||||||
py39_byte_compile () {\
|
py39_byte_compile () {\
|
||||||
python_binary="%{__env_unset_source_date_epoch_if_not_clamp_mtime} PYTHONHASHSEED=0 %1"\
|
python_binary="%{__env_unset_source_date_epoch_if_not_clamp_mtime} PYTHONHASHSEED=0 %1"\
|
||||||
bytecode_compilation_path="%2"\
|
bytecode_compilation_path="%2"\
|
||||||
$python_binary -s -B -m compileall -o 0 -o 1 -s $RPM_BUILD_ROOT -p / --hardlink-dupes $bytecode_compilation_path \
|
$python_binary -s -B -m compileall -o 0 -o 1 -s $RPM_BUILD_ROOT -p / --hardlink-dupes --invalidation-mode=timestamp $bytecode_compilation_path \
|
||||||
}\
|
}\
|
||||||
\
|
\
|
||||||
# Path to intepreter should not contain any arguments \
|
# Path to intepreter should not contain any arguments \
|
||||||
@ -44,10 +49,13 @@ py39_byte_compile () {\
|
|||||||
python_version=$(%1 -c "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))") \
|
python_version=$(%1 -c "import sys; sys.stdout.write('{0.major}{0.minor}'.format(sys.version_info))") \
|
||||||
# compileall2 is an enhanced fork of stdlib compileall module for Python >= 3.4 \
|
# compileall2 is an enhanced fork of stdlib compileall module for Python >= 3.4 \
|
||||||
# and it was merged back to stdlib in Python >= 3.9 \
|
# and it was merged back to stdlib in Python >= 3.9 \
|
||||||
|
# Only Python 3.7+ supports and needs the --invalidation-mode option \
|
||||||
if [ "$python_version" -ge 39 ]; then \
|
if [ "$python_version" -ge 39 ]; then \
|
||||||
py39_byte_compile "%1" "%2"; \
|
py39_byte_compile "%1" "%2"; \
|
||||||
|
elif [ "$python_version" -ge 37 ]; then \
|
||||||
|
py37_byte_compile "%1" "%2"; \
|
||||||
elif [ "$python_version" -ge 34 ]; then \
|
elif [ "$python_version" -ge 34 ]; then \
|
||||||
py3_byte_compile "%1" "%2"; \
|
py34_byte_compile "%1" "%2"; \
|
||||||
else \
|
else \
|
||||||
py2_byte_compile "%1" "%2"; \
|
py2_byte_compile "%1" "%2"; \
|
||||||
fi
|
fi
|
||||||
|
@ -162,6 +162,7 @@ grep -E '^#[^%%]*%%[^%%]' %{buildroot}%{rpmmacrodir}/macros.* && exit 1 || true
|
|||||||
%changelog
|
%changelog
|
||||||
* Mon Dec 19 2022 Miro Hrončok <mhroncok@redhat.com> - 3.11-7
|
* Mon Dec 19 2022 Miro Hrončok <mhroncok@redhat.com> - 3.11-7
|
||||||
- Bytecompilation: Unset $SOURCE_DATE_EPOCH when %%clamp_mtime_to_source_date_epoch is not set
|
- Bytecompilation: Unset $SOURCE_DATE_EPOCH when %%clamp_mtime_to_source_date_epoch is not set
|
||||||
|
- Bytecompilation: Pass --invalidation-mode=timestamp to compileall (on Python 3.7+)
|
||||||
|
|
||||||
* Sun Nov 13 2022 Miro Hrončok <mhroncok@redhat.com> - 3.11-6
|
* Sun Nov 13 2022 Miro Hrončok <mhroncok@redhat.com> - 3.11-6
|
||||||
- Set PYTEST_XDIST_AUTO_NUM_WORKERS=%%{_smp_build_ncpus} from %%pytest
|
- Set PYTEST_XDIST_AUTO_NUM_WORKERS=%%{_smp_build_ncpus} from %%pytest
|
||||||
|
Loading…
Reference in New Issue
Block a user