diff options
| author | Ian Rogers <irogers@google.com> | 2026-07-23 10:27:09 -0700 |
|---|---|---|
| committer | Namhyung Kim <namhyung@kernel.org> | 2026-07-23 22:49:39 -0700 |
| commit | 1fa8d81be1ebaf0393a5141c48916f335e26f2f2 (patch) | |
| tree | 09d75d3f6879615ba5b72821f568afd3386828c3 /tools/perf/scripts/python/bin/stackcollapse-record | |
| parent | 87ec3437f37b9fe44c524ba967cb12e78de06f15 (diff) | |
perf python: Clean up and restructure setup.py
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 (including `srctree` in `InstallLib.run`), removing their
dependency on global variables.
- Replace legacy Popen with subprocess.run for safer process handling.
- Use quote-aware flag filtering (`shlex.split`, filter, `shlex.join`)
on sysconfig CFLAGS and OPT instead of regex `re.sub` substitutions.
This avoids boundary bugs and safely handles quoted arguments and
options with values.
- Rely on setuptools to handle user CFLAGS from the environment
directly rather than manually prepending them to extra_compile_args.
- 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@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools/perf/scripts/python/bin/stackcollapse-record')
0 files changed, 0 insertions, 0 deletions
