aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2022-12-17 11:37:15 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2022-12-19 12:26:58 -0300
commit66dfc517e8ec530b1d8d4776c05e3f264f38ecb8 (patch)
treefcd0a2d43f08bb741fc56140acd976f0167000a0
parent77856d911a8c8724ee8e2b09d55979fc1de8f1c0 (diff)
downloadpci-66dfc517e8ec530b1d8d4776c05e3f264f38ecb8.tar.gz
perf python: Don't stop building if python setuptools isn't installed
The python3-setuptools package is needed to build the python binding, so that one can use things like: # ~acme/git/perf/tools/perf/python/twatch.py cpu: 6, pid: 4573, tid: 2184618 { type: exit, pid: 4573, ppid: 4172, tid: 2184618, ptid: 4172, time: 12563190090107} cpu: 24, pid: 4573, tid: 4573 { type: fork, pid: 4573, ppid: 4573, tid: 2190991, ptid: 4573, time: 12563415289331} cpu: 29, pid: 4573, tid: 2190991 { type: comm, pid: 4573, tid: 2190991, comm: StreamT~ns #401 } cpu: 29, pid: 4573, tid: 2190991 { type: comm, pid: 4573, tid: 2190991, comm: StreamT~ns #401 } ^CTraceback (most recent call last): File "/var/home/acme/git/perf/tools/perf/python/twatch.py", line 61, in <module> main() File "/var/home/acme/git/perf/tools/perf/python/twatch.py", line 33, in main evlist.poll(timeout = -1) KeyboardInterrupt # That have 'import perf;'. But distros don't always have that python3-setuptools (or equivalent) installed, which was breaking the build. Just check if it is installed and emit a warning that such binding isn't being built and continue the build without it: With it: $ rpm -q python3-setuptools python3-setuptools-59.6.0-3.fc36.noarch $ rm -rf /tmp/build/perf; mkdir -p /tmp/build/perf $ make O=/tmp/build/perf -C tools/perf install-bin make: Entering directory '/var/home/acme/git/perf/tools/perf' <SNIP> ... libpython: [ on ] <SNIP> GEN /tmp/build/perf/python/perf.cpython-310-x86_64-linux-gnu.so <SNIP> $ ls -la /tmp/build/perf/python/perf.cpython-310-x86_64-linux-gnu.so -rwxr-xr-x. 1 acme acme 1609112 Dec 17 11:39 /tmp/build/perf/python/perf.cpython-310-x86_64-linux-gnu.so $ Without it: $ sudo rpm -e python3-setuptools $ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf $ make O=/tmp/build/perf -C tools/perf install-bin make: Entering directory '/var/home/acme/git/perf/tools/perf' <SNIP> ... libpython: [ on ] <SNIP> $ ls -la /tmp/build/perf/python/perf.cpython-310-x86_64-linux-gnu.so ls: cannot access '/tmp/build/perf/python/perf.cpython-310-x86_64-linux-gnu.so': No such file or directory $ Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lore.kernel.org/lkml/Y53XHw3rlsaaUgOs@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/Makefile.config9
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 83ed969b95b4a..c21bd6010be13 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -890,8 +890,13 @@ else
else
LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
EXTLIBS += $(PYTHON_EMBED_LIBADD)
- PYTHON_EXTENSION_SUFFIX := $(shell $(PYTHON) -c 'from importlib import machinery; print(machinery.EXTENSION_SUFFIXES[0])')
- LANG_BINDINGS += $(obj-perf)python/perf$(PYTHON_EXTENSION_SUFFIX)
+ PYTHON_SETUPTOOLS_INSTALLED := $(shell $(PYTHON) -c 'import setuptools;' 2> /dev/null && echo "yes" || echo "no")
+ ifeq ($(PYTHON_SETUPTOOLS_INSTALLED), yes)
+ PYTHON_EXTENSION_SUFFIX := $(shell $(PYTHON) -c 'from importlib import machinery; print(machinery.EXTENSION_SUFFIXES[0])')
+ LANG_BINDINGS += $(obj-perf)python/perf$(PYTHON_EXTENSION_SUFFIX)
+ else
+ msg := $(warning Missing python setuptools, the python binding won't be built, please install python3-setuptools or equivalent);
+ endif
CFLAGS += -DHAVE_LIBPYTHON_SUPPORT
$(call detected,CONFIG_LIBPYTHON)
endif