forked from rpms/python-rpm-macros
Use the values of %_py3_shebang_s and %_py3_shebang_P in the shebang opts/flags
As proposed in https://src.fedoraproject.org/rpms/python-rpm-macros/pull-request/141#comment-109228 And discussed in: - https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/4YD2X7HU5U5DFO3N4FWJLPSKVMKH4VSB/ - https://lists.fedoraproject.org/archives/list/packaging@lists.fedoraproject.org/thread/4YD2X7HU5U5DFO3N4FWJLPSKVMKH4VSB/
This commit is contained in:
parent
4d31ea8034
commit
4abed5f105
|
@ -13,7 +13,9 @@
|
|||
%python_cache_tag %(RPM_BUILD_ROOT= %{__python} -Esc "import sys; print(sys.implementation.cache_tag)")
|
||||
|
||||
%py_setup setup.py
|
||||
%py_shbang_opts -s%(RPM_BUILD_ROOT= %{__python} -Esc "import sys; print('P' if hasattr(sys.flags, 'safe_path') else '')")
|
||||
%_py_shebang_s s
|
||||
%_py_shebang_P %(RPM_BUILD_ROOT= %{__python} -Esc "import sys; print('P' if hasattr(sys.flags, 'safe_path') else '')")
|
||||
%py_shbang_opts -%{?_py_shebang_s}%{?_py_shebang_P}
|
||||
%py_shbang_opts_nodash %(opts=%{py_shbang_opts}; echo ${opts#-})
|
||||
%py_shebang_flags %(opts=%{py_shbang_opts}; echo ${opts#-})
|
||||
%py_shebang_fix %{expand:\\\
|
||||
|
|
|
@ -11,7 +11,9 @@
|
|||
%python3_cache_tag %(RPM_BUILD_ROOT= %{__python3} -Ic "import sys; print(sys.implementation.cache_tag)")
|
||||
%py3dir %{_builddir}/python3-%{name}-%{version}-%{release}
|
||||
|
||||
%py3_shbang_opts -s%(RPM_BUILD_ROOT= %{__python3} -Ic "import sys; print('P' if hasattr(sys.flags, 'safe_path') else '')")
|
||||
%_py3_shebang_s s
|
||||
%_py3_shebang_P %(RPM_BUILD_ROOT= %{__python3} -Ic "import sys; print('P' if hasattr(sys.flags, 'safe_path') else '')")
|
||||
%py3_shbang_opts -%{?_py3_shebang_s}%{?_py3_shebang_P}
|
||||
%py3_shbang_opts_nodash %(opts=%{py3_shbang_opts}; echo ${opts#-})
|
||||
%py3_shebang_flags %(opts=%{py3_shbang_opts}; echo ${opts#-})
|
||||
%py3_shebang_fix %{expand:\\\
|
||||
|
|
|
@ -423,6 +423,31 @@ def test_py3_shebang_fix_custom_shebang_flags():
|
|||
assert shell_stdout('\n'.join(lines)) == '-kaEs'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('_py3_shebang_s', [None, '%{nil}'])
|
||||
def test_py3_shebang_fix_undefined_py3_shebang_s(_py3_shebang_s):
|
||||
lines = rpm_eval('%py3_shebang_fix arg1 arg2', _py3_shebang_s=_py3_shebang_s)
|
||||
lines[-1] = 'echo $shebang_flags'
|
||||
expected = f'-ka{safe_path_flag(X_Y)}' if safe_path_flag(X_Y) else '-k'
|
||||
assert shell_stdout('\n'.join(lines)) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize('_py3_shebang_P', [None, '%{nil}'])
|
||||
def test_py3_shebang_fix_undefined_py3_shebang_P(_py3_shebang_P):
|
||||
lines = rpm_eval('%py3_shebang_fix arg1 arg2', _py3_shebang_P=_py3_shebang_P)
|
||||
lines[-1] = 'echo $shebang_flags'
|
||||
assert shell_stdout('\n'.join(lines)) == '-kas'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('_py3_shebang_s', [None, '%{nil}'])
|
||||
@pytest.mark.parametrize('_py3_shebang_P', [None, '%{nil}'])
|
||||
def test_py3_shebang_fix_undefined_py3_shebang_sP(_py3_shebang_s, _py3_shebang_P):
|
||||
lines = rpm_eval('%py3_shebang_fix arg1 arg2',
|
||||
_py3_shebang_s=_py3_shebang_s,
|
||||
_py3_shebang_P=_py3_shebang_P)
|
||||
lines[-1] = 'echo $shebang_flags'
|
||||
assert shell_stdout('\n'.join(lines)) == '-k'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('flags', [None, '%{nil}'])
|
||||
def test_py3_shebang_fix_no_shebang_flags(flags):
|
||||
lines = rpm_eval('%py3_shebang_fix arg1 arg2', py3_shebang_flags=flags)
|
||||
|
|
Loading…
Reference in New Issue