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
2d0673afb1
commit
b20d8aa23a
@ -39,6 +39,10 @@ def read_modules_from_cli(argv):
|
|||||||
# we need to unify the output to a list of particular elements
|
# we need to unify the output to a list of particular elements
|
||||||
modules_as_str = ' '.join(argv)
|
modules_as_str = ' '.join(argv)
|
||||||
modules = re.split(r'[\s,]+', modules_as_str)
|
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
|
return modules
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,8 +79,11 @@
|
|||||||
PATH="%{buildroot}%{_bindir}:$PATH"\\\
|
PATH="%{buildroot}%{_bindir}:$PATH"\\\
|
||||||
PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python_sitearch}:%{buildroot}%{python_sitelib}}"\\\
|
PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python_sitearch}:%{buildroot}%{python_sitelib}}"\\\
|
||||||
PYTHONDONTWRITEBYTECODE=1\\\
|
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:
|
%python_provide() %{lua:
|
||||||
local python = require "fedora.srpm.python"
|
local python = require "fedora.srpm.python"
|
||||||
|
@ -77,8 +77,11 @@
|
|||||||
PATH="%{buildroot}%{_bindir}:$PATH"\\\
|
PATH="%{buildroot}%{_bindir}:$PATH"\\\
|
||||||
PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}"\\\
|
PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}"\\\
|
||||||
PYTHONDONTWRITEBYTECODE=1\\\
|
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.
|
# This only supports Python 3.5+ and will never work with Python 2.
|
||||||
# Hence, it has no Python version in the name.
|
# Hence, it has no Python version in the name.
|
||||||
|
@ -49,7 +49,7 @@ elseif posix.stat('macros.python-srpm') then
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
Version: %{__default_python3_version}
|
Version: %{__default_python3_version}
|
||||||
Release: 12%{?dist}
|
Release: 13%{?dist}
|
||||||
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
@ -145,6 +145,10 @@ install -m 755 brp-* %{buildroot}%{_rpmconfigdir}/redhat/
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Nov 01 2021 Karolina Surma <ksurma@redhat.com> - 3.10-13
|
||||||
|
- Fix multiline arguments processing for %%py_check_import
|
||||||
|
Resolves: rhbz#2018809
|
||||||
|
|
||||||
* Mon Oct 25 2021 Karolina Surma <ksurma@redhat.com> - 3.10-12
|
* Mon Oct 25 2021 Karolina Surma <ksurma@redhat.com> - 3.10-12
|
||||||
- Introduce -f (read from file) option to %%py{3}_check_import
|
- Introduce -f (read from file) option to %%py{3}_check_import
|
||||||
- Introduce -t (filter top-level modules) option to %%py{3}_check_import
|
- Introduce -t (filter top-level modules) option to %%py{3}_check_import
|
||||||
|
@ -671,20 +671,22 @@ def test_python3_sitearch_value_alternate_python(lib, alt_x_y):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'args',
|
'args, expected_args',
|
||||||
[
|
[
|
||||||
'six',
|
('six', 'six'),
|
||||||
'-f foo.txt',
|
('-f foo.txt', '-f foo.txt'),
|
||||||
'-t -f foo.txt six, seven',
|
('-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', '-e "foo*" -f foo.txt six, seven'),
|
||||||
'six.quarter six.half,, SIX',
|
('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',
|
@pytest.mark.parametrize('__python3',
|
||||||
[None,
|
[None,
|
||||||
f'/usr/bin/python{X_Y}',
|
f'/usr/bin/python{X_Y}',
|
||||||
'/usr/bin/pythonX.Y'])
|
'/usr/bin/pythonX.Y'])
|
||||||
def test_py3_check_import(args, __python3, lib):
|
def test_py3_check_import(args, expected_args, __python3, lib):
|
||||||
x_y = X_Y
|
x_y = X_Y
|
||||||
macros = {
|
macros = {
|
||||||
'buildroot': 'BUILDROOT',
|
'buildroot': 'BUILDROOT',
|
||||||
@ -700,7 +702,8 @@ def test_py3_check_import(args, __python3, lib):
|
|||||||
if (match := re.match(r'.+python(\d+\.\d+)$', __python3)):
|
if (match := re.match(r'.+python(\d+\.\d+)$', __python3)):
|
||||||
x_y = match.group(1)
|
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,
|
# An equality check is a bit inflexible here,
|
||||||
# every time we change the macro we need to change this test.
|
# every time we change the macro we need to change this test.
|
||||||
@ -711,6 +714,7 @@ def test_py3_check_import(args, __python3, lib):
|
|||||||
PATH="BUILDROOT/usr/bin:$PATH"
|
PATH="BUILDROOT/usr/bin:$PATH"
|
||||||
PYTHONPATH="${{PYTHONPATH:-BUILDROOT/usr/{lib}/python{x_y}/site-packages:BUILDROOT/usr/lib/python{x_y}/site-packages}}"
|
PYTHONPATH="${{PYTHONPATH:-BUILDROOT/usr/{lib}/python{x_y}/site-packages:BUILDROOT/usr/lib/python{x_y}/site-packages}}"
|
||||||
PYTHONDONTWRITEBYTECODE=1
|
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()
|
assert lines == expected.splitlines()
|
||||||
|
@ -30,6 +30,7 @@ def preserve_sys_modules():
|
|||||||
('five six seven', ['five', 'six', 'seven']),
|
('five six seven', ['five', 'six', 'seven']),
|
||||||
('six,seven, eight', ['six', 'seven', 'eight']),
|
('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']),
|
||||||
|
('six.quarter six.half,, SIX \\ ', ['six.quarter', 'six.half', 'SIX']),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
def test_read_modules_from_cli(args, imports):
|
def test_read_modules_from_cli(args, imports):
|
||||||
|
Loading…
Reference in New Issue
Block a user