Skip to content

Modernize RPM packaging for EL9+/Fedora 43+, drop EL7/python2, refresh Python syntax - #98

Open
mouchar wants to merge 6 commits into
gooddata:masterfrom
mouchar:fedora
Open

Modernize RPM packaging for EL9+/Fedora 43+, drop EL7/python2, refresh Python syntax#98
mouchar wants to merge 6 commits into
gooddata:masterfrom
mouchar:fedora

Conversation

@mouchar

@mouchar mouchar commented Jul 4, 2026

Copy link
Copy Markdown
Member

Summary

  • Migrate the RPM spec's Fedora/EL8+ build path from the deprecated %py3_build/%py3_install macros to %pyproject_wheel/%pyproject_install, driving %files via %pyproject_save_files.
  • Drop EL7/python2 support from the spec entirely — target EL9+ and Fedora 43+, where python3 is always >= 3.9. Removes the now-dead %py2_build/%py2_install/%python2 branches.
  • Use the SPDX BSD-3-Clause identifier for License (spec and setup.py) instead of the bare "BSD" string, and drop the now-deprecated License :: classifier.
  • Modernize setup.py: python3 shebang, drop the unneeded # -*- coding: utf-8 -*- declaration, remove the dead test_suite option (setuptools no longer recognizes it — it was emitting Unknown distribution option warnings), add python_requires=">=3.9".
  • Clean up Python 2-era leftovers across the codebase: coding declarations, shebangs on non-executable modules, redundant explicit (object) base classes, old-style super(ClassName, self) calls.
  • Fix two latent bugs found along the way: Python 2 print statements inside usage-example docstrings (smoker/util/tap.py, smoker/util/progressbar.py), and a non-raw regex string with invalid escape sequences in smoker/server/plugins/varnishparser.py that only worked via CPython's SyntaxWarning-emitting fallback.
  • Replace the third-party mock test dependency with stdlib unittest.mock, dropping mock from requirements-test.txt and python3dist(mock) from the spec's %check BuildRequires.
  • Refresh README.md's install/build/test instructions to match (Python 3.9+, EL9+/Fedora 43+, dnf, current pip requirements files, pytest instead of py.test, git+https:// clone URL).

Test plan

  • pytest -q passes 115/115 before and after the changes (no regressions)
  • python -m py_compile on every tracked .py file with -Werror::SyntaxWarning (clean)
  • make rpm built successfully on a Fedora 44 host with zero rpmbuild warnings (previously two %py3_build/%py3_install deprecation warnings plus a %source_date_epoch_from_changelog warning)
  • Verified package contents (rpm -qlp) still ship the three /usr/bin/*.py scripts alongside the new dist-info metadata, no duplicate file listings

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Updated setup, installation, licensing, and testing instructions to match current Python 3 and RPM build requirements.
    • Clarified the project license as BSD 3-Clause.
  • Bug Fixes

    • Improved compatibility with Python 3 across command-line tools and core modules.
    • Updated test commands and dependencies to use modern pytest-based workflows.
  • Chores

    • Modernized packaging and build configuration for current RPM/pyproject-based builds.
    • Removed outdated legacy Python 2 references throughout the project.

mouchar added 6 commits July 4, 2026 11:30
%py3_build and %py3_install are deprecated and slated for removal in
Fedora 45. Switch the non-EL7 build path to %pyproject_wheel and
%pyproject_install, driving %files via %pyproject_save_files instead
of hardcoded python3_sitelib paths. EL7 keeps the python2 macros
since pyproject-rpm-macros isn't available there.

Also add a %changelog entry so %source_date_epoch_from_changelog has
something to read.
Target EL9+ and Fedora 43+ only, where python3 is always >= 3.9.
Removes the now-dead %py2_build/%py2_install/%python2 branches and
the python2_sitelib %files entries left over from the EL7 era.
License: BSD-3-Clause matches setup.py's SPDX identifier instead of
the bare "BSD" string. python3dist(mock) is no longer needed since
tests/server/test_client.py now uses stdlib unittest.mock.
- Shebang: python -> python3, drop the now-unneeded coding declaration
  (Python 3 defaults source files to UTF-8).
- Drop the dead "test_suite" distutils option; setuptools no longer
  recognizes it (it warned "Unknown distribution option") and tests
  already run via pytest per the Makefile/tox.ini.
- Replace the "License :: OSI Approved :: BSD License" classifier and
  bare "BSD" license string with the SPDX identifier "BSD-3-Clause",
  avoiding setuptools' license-classifier deprecation warning.
- Add python_requires=">=3.9" to declare the actual support floor.
Mechanical cleanup found while auditing the codebase for syntax that
pre-dates the Python 3.9 floor:

- Drop the "# -*- coding: utf-8 -*-" magic comment everywhere; Python
  3 source files default to UTF-8 (PEP 3120), so it's dead weight.
- Drop "#!/usr/bin/env python" shebangs from library modules that
  were never executable in the first place; the three actual entry
  points (bin/*.py) now say "python3" explicitly, matching hosts that
  have no bare "python" on PATH.
- Drop the redundant explicit "(object)" base class (implicit since
  Python 3).
- Replace old-style super(ClassName, self) calls with bare super().

Two real latent bugs surfaced along the way:
- smoker/util/tap.py and smoker/util/progressbar.py had Python 2
  `print` statements inside their usage-example docstrings; fixed to
  call syntax so anyone copy-pasting the example gets working code.
- smoker/server/plugins/varnishparser.py built its regex from a
  non-raw string with backslash-space escapes, which is only valid
  today via CPython's SyntaxWarning-emitting fallback and will become
  a hard SyntaxError in a future Python. Made it a raw string.

Also swap tests/server/test_client.py's third-party "mock" import for
stdlib unittest.mock (available since Python 3.3), dropping the
external test dependency (see requirements-test.txt).

Verified: `pytest -q` still passes 115/115 before and after.
Smoker now targets Python 3.9+ on EL9+/Fedora 43+ (see recent spec
and setup.py changes), so update the stale Python 2.6.6-era
instructions:

- Build deps: yum -> dnf, drop python2-setuptools, add the
  pyproject-rpm-macros toolchain smoker.spec now requires.
- Point pip installs at requirements.txt/requirements-test.txt
  instead of a hand-maintained package list that had already drifted
  (missing PyYAML's real name, listing argparse which is stdlib,
  and mock/lockfile which aren't actual dependencies).
- git:// clone URL -> git+https:// (git:// is no longer served by
  GitHub).
- py.test -> pytest (the py.test alias is long gone).
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR modernizes the codebase for Python 3, removing legacy shebangs, encoding declarations, explicit object base classes, and old-style super() calls across most modules and tests. Packaging metadata (setup.py, smoker.spec, requirements-test.txt) and README are updated for BSD-3-Clause licensing, Python 3.9+, and pytest.

Changes

Python 3 modernization

Layer / File(s) Summary
Documentation and licensing updates
README.md
License wording updated to BSD 3-Clause; install and testing instructions modernized for Python 3.9+ and pytest.
Packaging metadata and build spec migration
setup.py, smoker.spec, requirements-test.txt
License changed to BSD-3-Clause, python_requires>=3.9 added, test_suite removed; RPM spec migrated to pyproject macros with updated Release/License and changelog; mock removed from test requirements.
Executable script shebang updates
bin/check_smoker_plugin.py, bin/smokercli.py, bin/smokerd.py
Shebangs changed to python3 with no functional logic changes.
Client module syntax cleanup
smoker/client/__init__.py, smoker/client/cli.py, smoker/client/out_junit/*, smoker/client/plugins/__init__.py
Removed shebangs/encoding headers, dropped explicit object inheritance, and modernized super() calls.
Server and util module syntax cleanup
smoker/logger/*, smoker/server/*, smoker/util/*
Removed shebangs/encoding headers, dropped object inheritance, updated super() calls, converted print statements, and reworked a regex in varnishparser.py.
Test suite cleanup and mock migration
tests/**/*
Removed shebangs/encoding headers, dropped object inheritance, and switched test_client.py to unittest.mock.

Estimated code review effort: 2 (Simple) | ~15 minutes

Poem

A rabbit hops through code so old,
Sheds its skin of shebangs bold,
No more object, no more python2,
Just super() clean and pytest true.
With BSD-3 tags shining bright,
This burrow's ready for Python's light! 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: RPM packaging modernization, dropping EL7/Python 2 support, and Python 3 syntax updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@README.md`:
- Around line 55-74: Fix the typo in the README wording by changing “bellow” to
“below” in the dependencies/install instructions text. Update the sentence in
the README section around the Smoker setup guidance so the phrasing is correct
and consistent with the rest of the documentation.

In `@smoker.spec`:
- Around line 44-58: The package manifest in smoker.spec is missing the license
entry in the %files section. Update the %files block alongside %pyproject_files
to include LICENSE.TXT using the proper %license tag, while keeping the existing
%doc etc/* entry unchanged.
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c79226c2-13b1-4215-b3fb-0cb57fcace5b

📥 Commits

Reviewing files that changed from the base of the PR and between b91b1b6 and 6ff5dca.

📒 Files selected for processing (45)
  • README.md
  • bin/check_smoker_plugin.py
  • bin/smokercli.py
  • bin/smokerd.py
  • requirements-test.txt
  • setup.py
  • smoker.spec
  • smoker/__init__.py
  • smoker/client/__init__.py
  • smoker/client/cli.py
  • smoker/client/out_junit/__init__.py
  • smoker/client/out_junit/default_config.py
  • smoker/client/out_junit/rows.py
  • smoker/client/out_junit/xml_builder.py
  • smoker/client/plugins/__init__.py
  • smoker/logger/__init__.py
  • smoker/logger/level_handler.py
  • smoker/server/__init__.py
  • smoker/server/daemon.py
  • smoker/server/exceptions.py
  • smoker/server/parser.py
  • smoker/server/plugins/__init__.py
  • smoker/server/plugins/fsmount.py
  • smoker/server/plugins/glusterfs.py
  • smoker/server/plugins/mongo.py
  • smoker/server/plugins/testconnection.py
  • smoker/server/plugins/uname.py
  • smoker/server/plugins/varnishparser.py
  • smoker/server/restserver.py
  • smoker/util/__init__.py
  • smoker/util/command.py
  • smoker/util/console.py
  • smoker/util/nagios.py
  • smoker/util/progressbar.py
  • smoker/util/tap.py
  • tests/__init__.py
  • tests/server/__init__.py
  • tests/server/smoker_test_resources/__init__.py
  • tests/server/smoker_test_resources/client_mock_result.py
  • tests/server/smoker_test_resources/smokermodule.py
  • tests/server/smoker_test_resources/smokerparser.py
  • tests/server/test_client.py
  • tests/server/test_daemon.py
  • tests/server/test_plugins.py
  • tests/server/test_restapi.py
💤 Files with no reviewable changes (24)
  • smoker/server/plugins/glusterfs.py
  • smoker/logger/level_handler.py
  • smoker/server/plugins/mongo.py
  • tests/server/smoker_test_resources/smokermodule.py
  • smoker/client/out_junit/rows.py
  • smoker/server/plugins/fsmount.py
  • smoker/server/plugins/uname.py
  • tests/server/init.py
  • tests/init.py
  • smoker/init.py
  • smoker/client/out_junit/default_config.py
  • requirements-test.txt
  • smoker/util/nagios.py
  • tests/server/smoker_test_resources/client_mock_result.py
  • smoker/server/exceptions.py
  • smoker/server/init.py
  • smoker/client/out_junit/init.py
  • tests/server/smoker_test_resources/smokerparser.py
  • tests/server/smoker_test_resources/init.py
  • smoker/logger/init.py
  • smoker/util/console.py
  • smoker/client/cli.py
  • smoker/server/plugins/testconnection.py
  • smoker/util/init.py

Comment thread README.md
Comment on lines +55 to +74
Smoker requires Python 3.9 or newer, and is built and tested on EL9+ and Fedora 43+.

To build smoker with 'make rpm' folowing packages required to be installed on the CentOS, RHEL or Fedora:
To build smoker with 'make rpm' following packages are required on EL9+ or Fedora:

yum install gcc rpm-build python-setproctitle python-flask-restful python2-setuptools
dnf install gcc rpm-build rpmdevtools redhat-rpm-config systemd-rpm-macros \
python3-devel python3-setuptools python3-pip python3-wheel pyproject-rpm-macros

It doesn't have much dependencies, follow instructions bellow to install them:

With PIP:

pip install psutil PyAML argparse setproctitle Flask-RESTful
pip install -r requirements.txt

Or install packages from your distribution repository.

### Smoker app

With PIP (from Github):

pip install -e 'git://github.com/gooddata/smoker.git#egg=smoker'
pip install -e 'git+https://github.com/gooddata/smoker.git#egg=smoker'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Typo: "bellow" → "below".

Line 62: It doesn't have much dependencies, follow instructions bellow to install them: — "bellow" should be "below".

✏️ Proposed fix
-It doesn't have much dependencies, follow instructions bellow to install them:
+It doesn't have much dependencies, follow instructions below to install them:
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Smoker requires Python 3.9 or newer, and is built and tested on EL9+ and Fedora 43+.
To build smoker with 'make rpm' folowing packages required to be installed on the CentOS, RHEL or Fedora:
To build smoker with 'make rpm' following packages are required on EL9+ or Fedora:
yum install gcc rpm-build python-setproctitle python-flask-restful python2-setuptools
dnf install gcc rpm-build rpmdevtools redhat-rpm-config systemd-rpm-macros \
python3-devel python3-setuptools python3-pip python3-wheel pyproject-rpm-macros
It doesn't have much dependencies, follow instructions bellow to install them:
With PIP:
pip install psutil PyAML argparse setproctitle Flask-RESTful
pip install -r requirements.txt
Or install packages from your distribution repository.
### Smoker app
With PIP (from Github):
pip install -e 'git://github.com/gooddata/smoker.git#egg=smoker'
pip install -e 'git+https://github.com/gooddata/smoker.git#egg=smoker'
Smoker requires Python 3.9 or newer, and is built and tested on EL9+ and Fedora 43+.
To build smoker with 'make rpm' following packages are required on EL9+ or Fedora:
dnf install gcc rpm-build rpmdevtools redhat-rpm-config systemd-rpm-macros \
python3-devel python3-setuptools python3-pip python3-wheel pyproject-rpm-macros
It doesn't have much dependencies, follow instructions below to install them:
With PIP:
pip install -r requirements.txt
Or install packages from your distribution repository.
### Smoker app
With PIP (from Github):
pip install -e 'git+https://github.com/gooddata/smoker.git#egg=smoker'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` around lines 55 - 74, Fix the typo in the README wording by
changing “bellow” to “below” in the dependencies/install instructions text.
Update the sentence in the README section around the Smoker setup guidance so
the phrasing is correct and consistent with the rest of the documentation.

Comment thread smoker.spec
Comment on lines +44 to 58
%pyproject_wheel

%install
%if 0%{?el7}
%py2_install
%else
%py3_install
%endif
%pyproject_install
%pyproject_save_files smoker
install -d %{buildroot}%{_unitdir}
install -pm644 -t %{buildroot}%{_unitdir} smokerd.service

%if %{with check}
%check
%if 0%{?el7}
%python2 -m pytest -vv
%else
%python3 -m pytest -vv
%endif
%endif

%files
%files -f %{pyproject_files}
%doc etc/*

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check for a LICENSE file at the repo root and whether it's referenced anywhere in packaging files
fd -i '^license' -d 2
rg -n '%license' smoker.spec
rg -n 'license' setup.py -i

Repository: gooddata/smoker

Length of output: 199


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '== smoker.spec ==\n'
cat -n smoker.spec | sed -n '1,220p'

printf '\n== packaging files mentioning license ==\n'
rg -n -i 'license|LICENSE' -S pyproject.toml setup.py smoker.spec . || true

printf '\n== top-level files ==\n'
fd -d 1 . .

Repository: gooddata/smoker

Length of output: 3878


Add %license LICENSE.TXT to %filesLICENSE.TXT is present at the repo root, but the spec only ships %doc etc/*. The BSD-3-Clause text should be tagged separately.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@smoker.spec` around lines 44 - 58, The package manifest in smoker.spec is
missing the license entry in the %files section. Update the %files block
alongside %pyproject_files to include LICENSE.TXT using the proper %license tag,
while keeping the existing %doc etc/* entry unchanged.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

An unexpected error occurred while generating fixes: Not Found - https://docs.github.com/rest/git/refs#get-a-reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant