[U/P][PATCH] UBUNTU: [Packaging] linux-perf: Fix python perf library location
Juerg Haefliger
juerg.haefliger at canonical.com
Thu Mar 20 14:44:09 UTC 2025
BugLink: https://bugs.launchpad.net/bugs/2103653
Now that we have a single unversioned linux-perf package per series,
there's only one python perf library and we no longer need a wrapper
to find the library that matches the running kernel. So put the library
in the correct location /usr/lib/python3/dist-packages/ so that Python
can find it on its own and remove the wrapper.
Signed-off-by: Juerg Haefliger <juerg.haefliger at canonical.com>
---
debian/rules.d/2-binary-arch.mk | 5 +++--
debian/rules.d/3-binary-indep.mk | 7 -------
debian/tools/python-perf.py | 31 -------------------------------
3 files changed, 3 insertions(+), 40 deletions(-)
delete mode 100644 debian/tools/python-perf.py
diff --git a/debian/rules.d/2-binary-arch.mk b/debian/rules.d/2-binary-arch.mk
index 7c89fa14f27f..187a551d2f76 100644
--- a/debian/rules.d/2-binary-arch.mk
+++ b/debian/rules.d/2-binary-arch.mk
@@ -731,16 +731,17 @@ ifeq ($(do_tools_rtla),true)
endif
ifeq ($(do_tools_perf),true)
install -d $(perfpkgdir)/usr/bin
- install -d $(perfpkgdir)/usr/lib
install -m755 $(builddirpa)/tools/perf/perf \
$(perfpkgdir)/usr/bin/perf
ifeq ($(do_tools_perf_jvmti),true)
+ install -d $(perfpkgdir)/usr/lib
install -m644 $(builddirpa)/tools/perf/libperf-jvmti.so \
$(perfpkgdir)/usr/lib/
endif
ifeq ($(do_tools_perf_python),true)
+ install -d $(perfpkgdir)/usr/lib/python3/dist-packages
install -m644 $(builddirpa)/tools/perf/python/perf.*.so \
- $(perfpkgdir)/usr/lib/
+ $(perfpkgdir)/usr/lib/python3/dist-packages/
endif
endif # do_tools_perf
ifeq ($(do_tools_bpftool),true)
diff --git a/debian/rules.d/3-binary-indep.mk b/debian/rules.d/3-binary-indep.mk
index 1566f40cf17e..27dbe1e7f057 100644
--- a/debian/rules.d/3-binary-indep.mk
+++ b/debian/rules.d/3-binary-indep.mk
@@ -60,7 +60,6 @@ install-tools: bpftoolbashcomp = $(CURDIR)/debian/$(bpftoolpkg)/usr/share/bash-c
install-tools: perfpkg = $(perf_pkg_name)
install-tools: perfbin = $(CURDIR)/debian/$(perfpkg)/usr/bin
install-tools: perfman = $(CURDIR)/debian/$(perfpkg)/usr/share/man
-install-tools: perfpython = $(CURDIR)/debian/$(perfpkg)/usr/lib/python3/dist-packages
install-tools: toolspkg = $(tools_common_pkg_name)
install-tools: toolsbin = $(CURDIR)/debian/$(toolspkg)/usr/bin
install-tools: toolssbin = $(CURDIR)/debian/$(toolspkg)/usr/sbin
@@ -94,7 +93,6 @@ ifeq ($(do_tools_common),true)
install -d $(toolsbashcomp)
install -d $(perfbin)
install -d $(perfman)/man1
- install -d $(perfpython)
install -m755 debian/tools/generic $(toolsbin)/usbip
install -m755 debian/tools/generic $(toolsbin)/usbipd
@@ -115,11 +113,6 @@ ifeq ($(do_tools_common),true)
install -m644 $(CURDIR)/tools/power/x86/x86_energy_perf_policy/*.8 $(toolsman)/man8
install -m644 $(CURDIR)/tools/power/x86/turbostat/*.8 $(toolsman)/man8
-ifeq ($(do_tools_perf_python),true)
- # Python wrapper module for python-perf
- install -d $(perfpython)/perf
- install -m644 debian/tools/python-perf.py $(perfpython)/perf/__init__.py
-endif
ifeq ($(do_cloud_tools),true)
ifeq ($(do_tools_hyperv),true)
dh_prep -p$(cloudpkg)
diff --git a/debian/tools/python-perf.py b/debian/tools/python-perf.py
deleted file mode 100644
index d1991d677dcb..000000000000
--- a/debian/tools/python-perf.py
+++ /dev/null
@@ -1,31 +0,0 @@
-import os
-import importlib.util
-from glob import glob
-
-
-class KernelNotFoundError(Exception):
- def __init__(self):
- kernel_version = os.uname().release
- flavor = kernel_version.split("-", 2)[2]
- super().__init__(
- f"\nWARNING: python perf module not found for kernel {kernel_version}\n\n"
- f" You may need to install the following package for this specific kernel:\n"
- f" linux-tools-{kernel_version}\n\n"
- f" You may also want to install the following package to keep up to date:\n"
- f" linux-tools-{flavor}"
- )
-
-
-# Load the actual python-perf module for the running kernel
-_kernel_version = os.uname().release
-_perf_dir = f"/usr/lib/linux-tools/{_kernel_version}/lib"
-if not os.path.exists(_perf_dir):
- raise KernelNotFoundError()
-_perf_lib = glob(os.path.join(_perf_dir, "perf.*.so"))[-1]
-
-_spec = importlib.util.spec_from_file_location("perf", _perf_lib)
-_perf = importlib.util.module_from_spec(_spec)
-_spec.loader.exec_module(_perf)
-
-# Expose the 'perf' module.
-__all__ = ["perf"]
--
2.43.0
More information about the kernel-team
mailing list