mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] perf build: Fix pylint build failures
@ 2026-09-30  9:01 Leo Yan
  2026-09-30  9:01 ` [PATCH 1/3] perf build: Build the Python extension before pylint consumers Leo Yan
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Leo Yan @ 2026-09-30  9:01 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers,
	Adrian Hunter, James Clark, Aishwarya TCV
  Cc: linux-perf-users, linux-kernel, Arnaldo Carvalho de Melo, Leo Yan

Recent changes to perf's Python module, including enabling pylint by
default, exposed build failures in our CI. For example:

  tests/shell/lib/perf_brstack_max.py:8:0: E0401: Unable to import 'perf' (import-error)

This series ensures the perf Python extension is built before running
pylint on its consumers and prepends the output Python directory to
PYTHONPATH for out-of-tree builds.

The series also mutes the optparse deprecation warning from older pylint
versions. Python has reversed this deprecation, and newer pylint
versions no longer report it.

Signed-off-by: Leo Yan <leo.yan@arm.com>
---
Leo Yan (3):
      perf build: Build the Python extension before pylint consumers
      perf build: Add the output Python directory to pylint's PYTHONPATH
      perf test: Suppress optparse deprecation warning with older pylint

 tools/perf/Makefile.perf           | 8 +++++++-
 tools/perf/tests/shell/lib/attr.py | 3 ++-
 2 files changed, 9 insertions(+), 2 deletions(-)
---
base-commit: 45d15e89a783a0a279b7a54f9018c230127380d7
change-id: 20260930-perf_fix_pylint_errors-3cef583b1e47

Best regards,
-- 
Leo Yan <leo.yan@arm.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] perf build: Build the Python extension before pylint consumers
  2026-09-30  9:01 [PATCH 0/3] perf build: Fix pylint build failures Leo Yan
@ 2026-09-30  9:01 ` Leo Yan
  2026-09-30  9:01 ` [PATCH 2/3] perf build: Add the output Python directory to pylint's PYTHONPATH Leo Yan
  2026-09-30  9:01 ` [PATCH 3/3] perf test: Suppress optparse deprecation warning with older pylint Leo Yan
  2 siblings, 0 replies; 4+ messages in thread
From: Leo Yan @ 2026-09-30  9:01 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers,
	Adrian Hunter, James Clark, Aishwarya TCV
  Cc: linux-perf-users, linux-kernel, Arnaldo Carvalho de Melo, Leo Yan

Pylint checks for tests and standalone Python scripts can run before the
perf Python extension is available. On a clean parallel build, an import
error can stop make before the extension is built.

When pylint is enabled, make the perf and perf-test sub-makes wait for the
enabled language bindings using an order-only dependency. The extension
does not depend on either consumer, so this does not introduce a cycle.

Fixes: 8a54784e708b ("perf build: Add pylint build tests")
Reported-by: Aishwarya TCV <aishwarya.tcv@arm.com>
Assisted-by: Codex:gpt-6
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 tools/perf/Makefile.perf | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 0102c3468a0b79fb22966d8cbd8fa8525d2ff3ae..d350d085542c64fc6d0bed4c5d7d1daac51efa8b 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -578,6 +578,12 @@ strip: $(PROGRAMS) $(OUTPUT)perf
 	$(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf
 
 PERF_IN := $(OUTPUT)perf-in.o
+
+ifdef PYLINT
+# Build the Python extension before starting sub-makes that lint its users.
+$(PERF_IN) $(LIBPERF_TEST_IN): | $(LANG_BINDINGS)
+endif
+
 export NO_JEVENTS
 
 build := -f $(srctree)/tools/build/Makefile.build dir=. obj

-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/3] perf build: Add the output Python directory to pylint's PYTHONPATH
  2026-09-30  9:01 [PATCH 0/3] perf build: Fix pylint build failures Leo Yan
  2026-09-30  9:01 ` [PATCH 1/3] perf build: Build the Python extension before pylint consumers Leo Yan
@ 2026-09-30  9:01 ` Leo Yan
  2026-09-30  9:01 ` [PATCH 3/3] perf test: Suppress optparse deprecation warning with older pylint Leo Yan
  2 siblings, 0 replies; 4+ messages in thread
From: Leo Yan @ 2026-09-30  9:01 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers,
	Adrian Hunter, James Clark, Aishwarya TCV
  Cc: linux-perf-users, linux-kernel, Arnaldo Carvalho de Melo, Leo Yan

Prepend the output Python directory to pylint's PYTHONPATH so builds
using O= can also find the generated extension.

Fixes: 5fe83fb352c8 ("perf build: Make pylint build test opt-out (NO_PYLINT=1)")
Reported-by: Aishwarya TCV <aishwarya.tcv@arm.com>
Assisted-by: Codex:gpt-6
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 tools/perf/Makefile.perf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index d350d085542c64fc6d0bed4c5d7d1daac51efa8b..0151aac394569671b98c98a42d97f75d380856cc 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -310,7 +310,7 @@ ifneq ($(force_fixdep),1)
       $(warning Warning: pylint version is older than 2.16.0, skipping pylint checks.)
       override PYLINT :=
     else
-      override PYLINT := PYTHONPATH=$(srctree)/tools/perf/python:$(srctree)/tools/perf/pmu-events \
+      override PYLINT := PYTHONPATH=$(abspath $(OUTPUT)python):$(srctree)/tools/perf/python:$(srctree)/tools/perf/pmu-events \
         $(PYLINT) --disable=all --enable=E,W --disable=W0123,W0311,W0511,W0603,W0622,W0718 \
         --ignored-modules=textual,setproctitle
     endif

-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/3] perf test: Suppress optparse deprecation warning with older pylint
  2026-09-30  9:01 [PATCH 0/3] perf build: Fix pylint build failures Leo Yan
  2026-09-30  9:01 ` [PATCH 1/3] perf build: Build the Python extension before pylint consumers Leo Yan
  2026-09-30  9:01 ` [PATCH 2/3] perf build: Add the output Python directory to pylint's PYTHONPATH Leo Yan
@ 2026-09-30  9:01 ` Leo Yan
  2 siblings, 0 replies; 4+ messages in thread
From: Leo Yan @ 2026-09-30  9:01 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers,
	Adrian Hunter, James Clark, Aishwarya TCV
  Cc: linux-perf-users, linux-kernel, Arnaldo Carvalho de Melo, Leo Yan

Python 3.13 reversed optparse's deprecation, and pylint 3.3.5 removed it
from the deprecated-module list. Perf supports older pylint versions,
so suppress the warning on this import and document the reason. Keep
other deprecated-module diagnostics enabled.

Link: https://docs.python.org/3.13/whatsnew/3.13.html#optparse
Link: https://pylint.readthedocs.io/en/latest/whatsnew/3/3.3/index.html#what-s-new-in-pylint-3-3-5
Fixes: 8a54784e708b ("perf build: Add pylint build tests")
Reported-by: Aishwarya TCV <aishwarya.tcv@arm.com>
Assisted-by: Codex:gpt-6
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 tools/perf/tests/shell/lib/attr.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/shell/lib/attr.py b/tools/perf/tests/shell/lib/attr.py
index 7f3d5b64b00dd7de45baff4f7d9baff89e003147..523257bcf8e126cb662af589727144bb26cff4d5 100644
--- a/tools/perf/tests/shell/lib/attr.py
+++ b/tools/perf/tests/shell/lib/attr.py
@@ -4,7 +4,8 @@ import configparser
 import os
 import sys
 import glob
-import optparse
+# Pylint before 3.3.5 still treats optparse as deprecated.
+import optparse  # pylint: disable=deprecated-module
 import platform
 import tempfile
 import logging

-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-30  9:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-30  9:01 [PATCH 0/3] perf build: Fix pylint build failures Leo Yan
2026-09-30  9:01 ` [PATCH 1/3] perf build: Build the Python extension before pylint consumers Leo Yan
2026-09-30  9:01 ` [PATCH 2/3] perf build: Add the output Python directory to pylint's PYTHONPATH Leo Yan
2026-09-30  9:01 ` [PATCH 3/3] perf test: Suppress optparse deprecation warning with older pylint Leo Yan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®