Fix %%py_shebang_flags handling within %%py_check_import
%%py{3}_check_import now respects the custom setting of %%py{3}_shebang_flags
and invokes Python with the respective values.
If %%py{3}_shebang_flags is undefined or set to no value,
there no flags are passed to Python on invoke.
Resolves: rhbz#2018615
This commit is contained in:
parent
a3ce038993
commit
f836bce1c4
4 changed files with 45 additions and 8 deletions
|
|
@ -643,6 +643,7 @@ def test_py3_check_import(args, expected_args, __python3, lib):
|
|||
macros = {
|
||||
'buildroot': 'BUILDROOT',
|
||||
'_rpmconfigdir': 'RPMCONFIGDIR',
|
||||
'py3_shebang_flags': 's',
|
||||
}
|
||||
if __python3 is not None:
|
||||
macros['__python3'] = __python3
|
||||
|
|
@ -665,7 +666,27 @@ def test_py3_check_import(args, expected_args, __python3, lib):
|
|||
PATH="BUILDROOT/usr/bin:$PATH"
|
||||
PYTHONPATH="${{PYTHONPATH:-BUILDROOT/usr/{lib}/python{x_y}/site-packages:BUILDROOT/usr/lib/python{x_y}/site-packages}}"
|
||||
PYTHONDONTWRITEBYTECODE=1
|
||||
{__python3 or '/usr/bin/python3'} -s RPMCONFIGDIR/redhat/import_all_modules.py
|
||||
{expected_args}
|
||||
{__python3 or '/usr/bin/python3'} -s RPMCONFIGDIR/redhat/import_all_modules.py {expected_args}
|
||||
""")
|
||||
assert lines == expected.splitlines()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'shebang_flags_value, expected_shebang_flags',
|
||||
[
|
||||
('s', '-s'),
|
||||
('%{nil}', ''),
|
||||
(None, ''),
|
||||
('Es', '-Es'),
|
||||
]
|
||||
)
|
||||
def test_py3_check_import_respects_shebang_flags(shebang_flags_value, expected_shebang_flags, lib):
|
||||
macros = {
|
||||
'_rpmconfigdir': 'RPMCONFIGDIR',
|
||||
'__python3': '/usr/bin/python3',
|
||||
'py3_shebang_flags': shebang_flags_value,
|
||||
}
|
||||
lines = rpm_eval('%py3_check_import sys', **macros)
|
||||
# Compare the last line of the command, that's where lua part is evaluated
|
||||
expected = f'/usr/bin/python3 {expected_shebang_flags} RPMCONFIGDIR/redhat/import_all_modules.py sys'
|
||||
assert lines[-1].strip() == expected
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue