Allow multiline arguments processing for %%py3_check_import
Fixes the regression introduced with the macro reimplementation. Resolves: rhbz#2018809
This commit is contained in:
parent
51d0619929
commit
aa7cf4e2bd
|
@ -39,6 +39,10 @@ def read_modules_from_cli(argv):
|
|||
# we need to unify the output to a list of particular elements
|
||||
modules_as_str = ' '.join(argv)
|
||||
modules = re.split(r'[\s,]+', modules_as_str)
|
||||
# Because of shell expansion in some less typical cases it may happen
|
||||
# that a trailing space will occur at the end of the list.
|
||||
# Remove the empty items from the list before passing it further
|
||||
modules = [m for m in modules if m]
|
||||
return modules
|
||||
|
||||
|
||||
|
|
|
@ -77,8 +77,11 @@
|
|||
PATH="%{buildroot}%{_bindir}:$PATH"\\\
|
||||
PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python_sitearch}:%{buildroot}%{python_sitelib}}"\\\
|
||||
PYTHONDONTWRITEBYTECODE=1\\\
|
||||
%{__python} -%{py_shebang_flags} %{_rpmconfigdir}/redhat/import_all_modules.py %{?**}
|
||||
}
|
||||
%{__python} -%{py_shebang_flags} %{_rpmconfigdir}/redhat/import_all_modules.py\\\
|
||||
%{lua:
|
||||
-- handle multiline arguments correctly, see https://bugzilla.redhat.com/2018809
|
||||
local args=rpm.expand('%{?**}'):gsub("[%s\\\\]*%s+", " ");print(args)
|
||||
}}
|
||||
|
||||
%python_provide() %{lua:
|
||||
local python = require "fedora.srpm.python"
|
||||
|
|
|
@ -75,8 +75,11 @@
|
|||
PATH="%{buildroot}%{_bindir}:$PATH"\\\
|
||||
PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}"\\\
|
||||
PYTHONDONTWRITEBYTECODE=1\\\
|
||||
%{__python3} -%{py3_shebang_flags} %{_rpmconfigdir}/redhat/import_all_modules.py %{?**}
|
||||
}
|
||||
%{__python3} -%{py3_shebang_flags} %{_rpmconfigdir}/redhat/import_all_modules.py\\\
|
||||
%{lua:
|
||||
-- handle multiline arguments correctly, see https://bugzilla.redhat.com/2018809
|
||||
local args=rpm.expand('%{?**}'):gsub("[%s\\\\]*%s+", " ");print(args)
|
||||
}}
|
||||
|
||||
# This only supports Python 3.5+ and will never work with Python 2.
|
||||
# Hence, it has no Python version in the name.
|
||||
|
|
|
@ -23,7 +23,7 @@ License: MIT and Python
|
|||
# The macro is defined in python-srpm-macros.
|
||||
%{?load:%{SOURCE102}}
|
||||
Version: %{__default_python3_version}
|
||||
Release: 40%{?dist}
|
||||
Release: 41%{?dist}
|
||||
|
||||
BuildArch: noarch
|
||||
|
||||
|
@ -98,6 +98,10 @@ install -m 644 import_all_modules.py %{buildroot}%{_rpmconfigdir}/redhat/
|
|||
|
||||
|
||||
%changelog
|
||||
* Mon Nov 01 2021 Karolina Surma <ksurma@redhat.com> - 3.9-41
|
||||
- Fix multiline arguments processing for %%py_check_import
|
||||
Resolves: rhbz#2018809
|
||||
|
||||
* Mon Oct 25 2021 Karolina Surma <ksurma@redhat.com> - 3.9-40
|
||||
- Introduce -f (read from file) option to %%py{3}_check_import
|
||||
- Introduce -t (filter top-level modules) option to %%py{3}_check_import
|
||||
|
|
|
@ -622,20 +622,22 @@ def test_python3_sitearch_value(lib):
|
|||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'args',
|
||||
'args, expected_args',
|
||||
[
|
||||
'six',
|
||||
'-f foo.txt',
|
||||
'-t -f foo.txt six, seven',
|
||||
'-e "foo*" -f foo.txt six, seven',
|
||||
'six.quarter six.half,, SIX',
|
||||
('six', 'six'),
|
||||
('-f foo.txt', '-f foo.txt'),
|
||||
('-t -f foo.txt six, seven', '-t -f foo.txt six, seven'),
|
||||
('-e "foo*" -f foo.txt six, seven', '-e "foo*" -f foo.txt six, seven'),
|
||||
('six.quarter six.half,, SIX', 'six.quarter six.half,, SIX'),
|
||||
('-f foo.txt six\nsix.half\nSIX', '-f foo.txt six six.half SIX'),
|
||||
('six \\ -e six.half', 'six -e six.half'),
|
||||
]
|
||||
)
|
||||
@pytest.mark.parametrize('__python3',
|
||||
[None,
|
||||
f'/usr/bin/python{X_Y}',
|
||||
'/usr/bin/python3.6'])
|
||||
def test_py3_check_import(args, __python3, lib):
|
||||
def test_py3_check_import(args, expected_args, __python3, lib):
|
||||
x_y = X_Y
|
||||
macros = {
|
||||
'buildroot': 'BUILDROOT',
|
||||
|
@ -650,7 +652,8 @@ def test_py3_check_import(args, __python3, lib):
|
|||
if (match := re.match(r'.+python(\d+\.\d+)$', __python3)):
|
||||
x_y = match.group(1)
|
||||
|
||||
lines = rpm_eval(f'%py3_check_import {args}', **macros)
|
||||
invocation = '%{py3_check_import ' + args +'}'
|
||||
lines = rpm_eval(invocation, **macros)
|
||||
|
||||
# An equality check is a bit inflexible here,
|
||||
# every time we change the macro we need to change this test.
|
||||
|
@ -661,6 +664,7 @@ def test_py3_check_import(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 {args}
|
||||
{__python3 or '/usr/bin/python3'} -s RPMCONFIGDIR/redhat/import_all_modules.py
|
||||
{expected_args}
|
||||
""")
|
||||
assert lines == expected.splitlines()
|
||||
|
|
|
@ -30,6 +30,7 @@ def preserve_sys_modules():
|
|||
('five six seven', ['five', 'six', 'seven']),
|
||||
('six,seven, eight', ['six', 'seven', 'eight']),
|
||||
('six.quarter six.half,, SIX', ['six.quarter', 'six.half', 'SIX']),
|
||||
('six.quarter six.half,, SIX \\ ', ['six.quarter', 'six.half', 'SIX']),
|
||||
]
|
||||
)
|
||||
def test_read_modules_from_cli(args, imports):
|
||||
|
|
Loading…
Reference in New Issue