Adapt %py(3)_shebang_fix to use versioned pathfixX.Y.py
Versioned pathfixX.Y.py is available in main as well as in alternative Pythons so this change enables to build an alternative Python stack without a dependency on the main python3-devel.
This commit is contained in:
parent
0eae1d90da
commit
1979a78de9
@ -10,7 +10,14 @@
|
||||
%py_shbang_opts -s
|
||||
%py_shbang_opts_nodash %(opts=%{py_shbang_opts}; echo ${opts#-})
|
||||
%py_shebang_flags %(opts=%{py_shbang_opts}; echo ${opts#-})
|
||||
%py_shebang_fix %{expand:/usr/bin/pathfix.py -pni %{__python} -k%{?py_shebang_flags:a %py_shebang_flags}}
|
||||
%py_shebang_fix %{expand:\\\
|
||||
if [ -f /usr/bin/pathfix%{python_version}.py ]; then
|
||||
pathfix=/usr/bin/pathfix%{python_version}.py
|
||||
else
|
||||
# older versions of Python don't have it and must BR /usr/bin/pathfix.py from python3-devel explicitly
|
||||
pathfix=/usr/bin/pathfix.py
|
||||
fi
|
||||
$pathfix -pni %{__python} -k%{?py_shebang_flags:a %py_shebang_flags}}
|
||||
|
||||
# Use the slashes after expand so that the command starts on the same line as
|
||||
# the macro
|
||||
|
@ -8,7 +8,14 @@
|
||||
%py3_shbang_opts -s
|
||||
%py3_shbang_opts_nodash %(opts=%{py3_shbang_opts}; echo ${opts#-})
|
||||
%py3_shebang_flags %(opts=%{py3_shbang_opts}; echo ${opts#-})
|
||||
%py3_shebang_fix %{expand:/usr/bin/pathfix.py -pni %{__python3} -k%{?py3_shebang_flags:a %py3_shebang_flags}}
|
||||
%py3_shebang_fix %{expand:\\\
|
||||
if [ -f /usr/bin/pathfix%{python3_version}.py ]; then
|
||||
pathfix=/usr/bin/pathfix%{python3_version}.py
|
||||
else
|
||||
# older versions of Python don't have it and must BR /usr/bin/pathfix.py from python3-devel explicitly
|
||||
pathfix=/usr/bin/pathfix.py
|
||||
fi
|
||||
$pathfix -pni %{__python3} -k%{?py3_shebang_flags:a %py3_shebang_flags}}
|
||||
|
||||
# Use the slashes after expand so that the command starts on the same line as
|
||||
# the macro
|
||||
|
@ -1,6 +1,6 @@
|
||||
Name: python-rpm-macros
|
||||
Version: 3.9
|
||||
Release: 8%{?dist}
|
||||
Release: 9%{?dist}
|
||||
Summary: The common Python RPM macros
|
||||
|
||||
# macros and lua: MIT, compileall2.py: PSFv2
|
||||
@ -107,6 +107,9 @@ install -m 644 compileall2.py %{buildroot}%{_rpmconfigdir}/redhat/
|
||||
|
||||
|
||||
%changelog
|
||||
* Fri Jul 24 2020 Lumír Balhar <lbalhar@redhat.com> - 3.9-9
|
||||
- Adapt %%py[3]_shebang_fix to use versioned pathfixX.Y.py
|
||||
|
||||
* Fri Jul 24 2020 Lumír Balhar <lbalhar@redhat.com> - 3.9-8
|
||||
- Disable Python hash seed randomization in %%py_byte_compile
|
||||
|
||||
|
@ -228,23 +228,23 @@ def test_pypi_source_explicit_tilde():
|
||||
|
||||
|
||||
def test_py3_shebang_fix():
|
||||
cmd = rpm_eval('%py3_shebang_fix arg1 arg2 arg3')[0]
|
||||
assert cmd == '/usr/bin/pathfix.py -pni /usr/bin/python3 -ka s arg1 arg2 arg3'
|
||||
cmd = rpm_eval('%py3_shebang_fix arg1 arg2 arg3')[-1].strip()
|
||||
assert cmd == '$pathfix -pni /usr/bin/python3 -ka s arg1 arg2 arg3'
|
||||
|
||||
|
||||
def test_py3_shebang_fix_custom_flags():
|
||||
cmd = rpm_eval('%py3_shebang_fix arg1 arg2 arg3', py3_shebang_flags='Es')[0]
|
||||
assert cmd == '/usr/bin/pathfix.py -pni /usr/bin/python3 -ka Es arg1 arg2 arg3'
|
||||
cmd = rpm_eval('%py3_shebang_fix arg1 arg2 arg3', py3_shebang_flags='Es')[-1].strip()
|
||||
assert cmd == '$pathfix -pni /usr/bin/python3 -ka Es arg1 arg2 arg3'
|
||||
|
||||
|
||||
def test_py3_shebang_fix_empty_flags():
|
||||
cmd = rpm_eval('%py3_shebang_fix arg1 arg2 arg3', py3_shebang_flags=None)[0]
|
||||
assert cmd == '/usr/bin/pathfix.py -pni /usr/bin/python3 -k arg1 arg2 arg3'
|
||||
cmd = rpm_eval('%py3_shebang_fix arg1 arg2 arg3', py3_shebang_flags=None)[-1].strip()
|
||||
assert cmd == '$pathfix -pni /usr/bin/python3 -k arg1 arg2 arg3'
|
||||
|
||||
|
||||
def test_py_shebang_fix_custom():
|
||||
cmd = rpm_eval('%py_shebang_fix arg1 arg2 arg3', __python='/usr/bin/pypy')[0]
|
||||
assert cmd == '/usr/bin/pathfix.py -pni /usr/bin/pypy -ka s arg1 arg2 arg3'
|
||||
cmd = rpm_eval('%py_shebang_fix arg1 arg2 arg3', __python='/usr/bin/pypy')[-1].strip()
|
||||
assert cmd == '$pathfix -pni /usr/bin/pypy -ka s arg1 arg2 arg3'
|
||||
|
||||
|
||||
def test_pycached_in_sitelib():
|
||||
|
Loading…
Reference in New Issue
Block a user