-
-
Save belkka/4dc42664fe383983c5a5d9d99da00952 to your computer and use it in GitHub Desktop.
How to compile weechat's python plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
shopt -s nullglob | |
# This is a guide how to resolve an issue with weechat python plugin crashes. | |
# In short: python 3.12 is buggy, use 3.13. | |
# If you have python3.12 and weechat installed on your system, you can | |
# additionally install python3.13, recompile the weechat's python plugin | |
# linked to 3.13 and put it in ~/.local/share/weechat/plugins/ directory. | |
### GET SOURCE CODE ### | |
# python plugin must be compiled for the corresponding version of weechat | |
# e.g. 4.3.2 | |
version=$(weechat --version) | |
echo "Installed version of weechat: $version" | |
echo "Fetching weechat source code (tag v$version)" | |
# tag name is "v4.3.2" | |
git clone --depth 1 --branch "v$version" git@github.com:weechat/weechat.git | |
cd weechat | |
### CHOOSE PYTHON VERSION ### | |
echo "Looking for the pkgconfig directory:" | |
# find where python3.pc or python3-embed.pc is located in your system | |
# e.g. /usr/lib/pkgconfig/python3-embed.pc | |
locate --basename python3-embed.pc || | |
locate --basename python3.pc | |
echo "Select python version that you need (NOT 3.12):" | |
# e.g. /usr/lib/pkgconfig/python-3.13-embed.pc | |
path=$(locate --basename python3.pc | xargs -r dirname) | |
select python_pc in "$path"/python*.pc | |
do | |
echo "selection: ${python_pc@Q}. CTRL+D to confirm" | |
done || true | |
test -n "$python_pc" | |
echo "selected: ${python_pc@Q}" | |
### BUILD PYTHON PLUGIN ### | |
# in cmake/FindPython.cmake replace "python3-embed" with your version | |
# e.g. python-3.13-embed | |
name=$(basename "$python_pc" .pc) | |
sed -e "s/python3-embed/$name/" -i ./cmake/FindPython.cmake | |
mkdir build; cd build | |
cmake .. -DENABLE_{PHP,RUBY}=OFF || | |
{ | |
cat <<-EXPLANATION | |
*** | |
Failed to run cmake, ccmake TUI will be launched... | |
Read the output from cmake above and note error messages "XXX not found" | |
(they are probably red). Your task is to disable ENABLE_XXX options | |
for those XXX, then press <c> and <g>. | |
Or you can disable them ALL, but you must keep ENABLE_PYTHON and ENABLE_SCRIPTS. | |
If you are unfamiliar with ccmake, use keys <j>/<k> to go down/up, | |
press <space> to toggle options, then <c> to configure, | |
and eventually <g> to generate (after successful configuration). | |
EXPLANATION | |
read -sp $'Remember instructions above and press Enter to launch ccmake...\n' | |
ccmake .. | |
} | |
# build ./src/plugins/python/python.so file | |
make python | |
### PUT PYTHON PLUGIN INTO USER's WEECHAT DATA DIR ### | |
plugin_dir="$HOME/.local/share/weechat/plugins" | |
echo "Copying ./src/plugins/python/python.so into ${plugin_dir}." | |
echo "This will override system-wide version of the plugin." | |
mkdir -p "$plugin_dir" | |
ln ./src/plugins/python/python.so "$plugin_dir/" || true | |
### CLEAN UP ### | |
echo "Remove the weechat repository if you don't need it anymore" | |
echo "Or remove the weechat/build/ directory, which was created by this script" | |
make clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The issue: weechat/weechat#2046