Skip to content

Commit 6de0256

Browse files
John B. Wyatt IVshuahkh
authored andcommitted
pm: cpupower: Add install and uninstall options to bindings makefile
Installs the .so and .py files generated by SWIG to system's site packages directory. This allows the Python bindings to be used system wide. This commit also includes documentation on setting up and installing the Python bindings. Link: https://lore.kernel.org/r/20241219012606.38963-1-jwyatt@redhat.com Signed-off-by: "John B. Wyatt IV" <jwyatt@redhat.com> Signed-off-by: "John B. Wyatt IV" <sageofredondo@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 8395d43 commit 6de0256

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

tools/power/cpupower/bindings/python/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ HAVE_PYCONFIG := $(shell if which python-config >/dev/null 2>&1; then echo 1; el
1111
LIB_DIR := ../../lib
1212
PY_INCLUDE = $(firstword $(shell python-config --includes))
1313
OBJECTS_LIB = $(wildcard $(LIB_DIR)/*.o)
14+
INSTALL_DIR = $(shell python3 -c "import site; print(site.getsitepackages()[0])")
1415

1516
all: _raw_pylibcpupower.so
1617

@@ -28,6 +29,15 @@ else ifeq ($(HAVE_PYCONFIG),0)
2829
endif
2930
swig -python raw_pylibcpupower.swg
3031

32+
# Only installs the Python bindings
33+
install: _raw_pylibcpupower.so
34+
install -D _raw_pylibcpupower.so $(INSTALL_DIR)/_raw_pylibcpupower.so
35+
install -D raw_pylibcpupower.py $(INSTALL_DIR)/raw_pylibcpupower.py
36+
37+
uninstall:
38+
rm -f $(INSTALL_DIR)/_raw_pylibcpupower.so
39+
rm -f $(INSTALL_DIR)/raw_pylibcpupower.py
40+
3141
# Will only clean the bindings folder; will not clean the actual cpupower folder
3242
clean:
3343
rm -f raw_pylibcpupower.py raw_pylibcpupower_wrap.c raw_pylibcpupower_wrap.o _raw_pylibcpupower.so

tools/power/cpupower/bindings/python/README

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,31 @@ To run the test script:
4848
$ python test_raw_pylibcpupower.py
4949

5050

51+
developing/using the bindings directly
52+
--------------------------------------
53+
54+
You need to add the Python bindings directory to your $PYTHONPATH.
55+
56+
You would set the path in the Bash terminal or in the Bash profile:
57+
58+
PYTHONPATH=~/linux/tools/power/cpupower/bindings/python:$PYTHONPATH
59+
60+
This allows you to set a specific repo of the bindings to use.
61+
62+
63+
installing/uninstalling
64+
-----------------------
65+
66+
Python uses a system specific site-packages folder to look up modules to import
67+
by default. You do not need to install cpupower to use the SWIG bindings.
68+
69+
You can install and uninstall the bindings to the site-packages with:
70+
71+
sudo make install
72+
73+
sudo make uninstall
74+
75+
5176
credits
5277
-------
5378

0 commit comments

Comments
 (0)