| 1 | This folder contains the necessary files to build the Python bindings for |
| 2 | libcpupower (aside from the libcpupower object files). |
| 3 | |
| 4 | |
| 5 | requirements |
| 6 | ------------ |
| 7 | |
| 8 | * If you are building completely from upstream; please install libcpupower by |
| 9 | running `make install-lib` within the cpupower directory. This installs the |
| 10 | libcpupower.so file and symlinks needed. Otherwise, please make sure a symlink |
| 11 | to libcpupower.so exists in your library path from your distribution's |
| 12 | packages. |
| 13 | * The SWIG program must be installed. |
| 14 | * The Python's development libraries must be installed. |
| 15 | |
| 16 | Please check that your version of SWIG is compatible with the version of Python |
| 17 | installed on your machine by checking the SWIG changelog on their website. |
| 18 | https://swig.org/ |
| 19 | |
| 20 | Note that while SWIG itself is GPL v3+ licensed; the resulting output, |
| 21 | the bindings code: is permissively licensed + the license of libcpupower's |
| 22 | library files. For these bindings that means GPL v2. |
| 23 | |
| 24 | Please see https://swig.org/legal.html and the discussion [1] for more details. |
| 25 | |
| 26 | [1] |
| 27 | https://lore.kernel.org/linux-pm/Zqv9BOjxLAgyNP5B@hatbackup/ |
| 28 | |
| 29 | |
| 30 | build |
| 31 | ----- |
| 32 | |
| 33 | Install SWIG and the Python development files provided by your distribution. |
| 34 | |
| 35 | Build the object files for libcpupower by running make in the cpupower |
| 36 | directory. |
| 37 | |
| 38 | Return to the directory this README is in to run: |
| 39 | |
| 40 | $ make |
| 41 | |
| 42 | |
| 43 | testing |
| 44 | ------- |
| 45 | |
| 46 | Please verify the _raw_pylibcpupower.so and raw_pylibcpupower.py files have |
| 47 | been created. |
| 48 | |
| 49 | To run the test script: |
| 50 | |
| 51 | $ python test_raw_pylibcpupower.py |
| 52 | |
| 53 | |
| 54 | developing/using the bindings directly |
| 55 | -------------------------------------- |
| 56 | |
| 57 | You need to add the Python bindings directory to your $PYTHONPATH. |
| 58 | |
| 59 | You would set the path in the Bash terminal or in the Bash profile: |
| 60 | |
| 61 | PYTHONPATH=~/linux/tools/power/cpupower/bindings/python:$PYTHONPATH |
| 62 | |
| 63 | This allows you to set a specific repo of the bindings to use. |
| 64 | |
| 65 | |
| 66 | installing/uninstalling |
| 67 | ----------------------- |
| 68 | |
| 69 | Python uses a system specific site-packages folder to look up modules to import |
| 70 | by default. You do not need to install cpupower to use the SWIG bindings. |
| 71 | |
| 72 | You can install and uninstall the bindings to the site-packages with: |
| 73 | |
| 74 | sudo make install |
| 75 | |
| 76 | sudo make uninstall |
| 77 | |
| 78 | |
| 79 | credits |
| 80 | ------- |
| 81 | |
| 82 | Original Bindings Author: |
| 83 | John B. Wyatt IV |
| 84 | [email protected] |
| 85 | [email protected] |
| 86 | |
| 87 | Copyright (C) 2024 Red Hat |