Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not embrace macros inside %python_module #322

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions spec_cleaner/rpmregexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class Regexp(object):
r'%{?(python_sitelib|python_sitearch|python_bin_suffix|python_version)}?'
)
re_python_interp_expand = re.compile(r'\s+(python)\s+')
re_python_module = re.compile(r'.*\s%{python_module\s.*}')

# rpmcopyright
re_copyright_string = re.compile(r'^#\s*Copyright\ \(c\)\s*(.*)', re.IGNORECASE)
Expand Down
7 changes: 6 additions & 1 deletion spec_cleaner/rpmsection.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ def _complete_cleanup(self, line: str) -> str:
line = line.replace(u'\xa0', ' ')

if not line.startswith('#'):
if not self.minimal and not self.no_curlification:
is_python_module = self.reg.re_python_module.match(line)
if (not self.minimal
and not self.no_curlification
# Do not embrace macros inside python_module
# gh#rpm-software-management/spec-cleaner#321
and not is_python_module):
line = self.embrace_macros(line)
line = self.replace_buildroot(line)
line = self.replace_optflags(line)
Expand Down
15 changes: 15 additions & 0 deletions tests/in/python-conditional-buildrequires.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
BuildRequires: %{python_module tomli >= 1.2.2 if %python-base < 3.11}
Requires: %oldpython-base

%install
%python_expand %fdupes %{buildroot}%{python_sitelib}
%python_expand %fdupes %{buildroot}%{python_sitearch}


%check
%python_expand PYTHONPATH=%{python_sitearch} nosetests-%{python_bin_suffix}
%python_expand testr-%{python_version}
%{python_expand python -m unittest discover}

%changelog

14 changes: 14 additions & 0 deletions tests/out/python-conditional-buildrequires.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
BuildRequires: %{python_module tomli >= 1.2.2 if %python-base < 3.11}
Requires: %{oldpython}-base

%install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%python_expand %fdupes %{buildroot}%{$python_sitearch}


%check
%python_expand PYTHONPATH=%{$python_sitearch} nosetests-%{$python_bin_suffix}
%python_expand testr-%{$python_version}
%{python_expand $python -m unittest discover}

%changelog