diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2022-12-17 17:37:15 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2022-12-19 18:26:58 +0300 |
commit | 66dfc517e8ec530b1d8d4776c05e3f264f38ecb8 (patch) | |
tree | fcd0a2d43f08bb741fc56140acd976f0167000a0 /tools/perf/Makefile.config | |
parent | 77856d911a8c8724ee8e2b09d55979fc1de8f1c0 (diff) | |
download | linux-66dfc517e8ec530b1d8d4776c05e3f264f38ecb8.tar.xz |
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>
Diffstat (limited to 'tools/perf/Makefile.config')
-rw-r--r-- | tools/perf/Makefile.config | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 83ed969b95b4..c21bd6010be1 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 |