Re: [PATCH v1] perf python: Clean up and restructure setup.py

From: Namhyung Kim

Date: Thu Jul 23 2026 - 01:32:24 EST


On Wed, Jul 22, 2026 at 09:51:34AM -0700, Ian Rogers wrote:
> On Thu, May 21, 2026 at 10:55 AM Ian Rogers <irogers@xxxxxxxxxx> wrote:
> >
> > Clean up and restructure the python setup script to resolve pylint
> > warnings, improve code quality, and increase robustness and
> > readability, targeting Python 3.9+ (the Linux kernel build minimum
> > Python version).
> >
> > Changes:
> > - Restructure the script to use a `main()` function as the entry point,
> > leaving only imports, classes, and pure functions at module level.
> > - Eliminate all global/module-level variables, making them local to
> > `main()` or the respective classes/functions.
> > - Make `clang_has_option` a pure function by passing all necessary
> > parameters explicitly.
> > - Extract clang compiler flag filtering into a new
> > `filter_clang_options` helper function. This function uses a loop
> > over a tuple of options, replacing ~30 lines of repetitive blocks
> > and reducing branch/statement complexity in the main flow.
> > - Cleanly define attributes in `__init__` for `BuildExt` and `InstallLib`
> > and read environment variables dynamically within the methods, removing
> > their dependency on global variables.
> > - Replace legacy Popen with subprocess.run for safer process handling.
> > - Use list-based flag filtering (split, filter, re-join) instead of regex
> > `re.sub` substitutions on space-separated compiler flag strings. This
> > avoids boundary bugs and safely handles flags with arguments (e.g.
> > `-fcf-protection=full`).
> > - Safely parse `CC` env var using `shlex.split` to handle quotes and pass
> > compiler arguments as `list[str]` lists to helper functions, avoiding
> > redundant string formatting and parsing.
> > - Remove unused `import re`.
> > - Rename setuptools command subclasses to PascalCase (BuildExt, InstallLib).
> > - Add type annotations to functions and methods.
> > - Add missing docstrings for module, functions, and classes.
> > - Split long lines to adhere to standard limits.
> >
> > Assisted-by: Antigravity:gemini-3.5-flash
> > Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
>
> Ping.

Sorry for the delay. Can you please resend the series?

Thanks,
Namhyung