Python 2.x is legacy; it has an end-of-life set for 2020.
Python 3.x is the present and future of the language. Version 3.0 was released on (15 years, 11 months ago).
Python 3 has many new exciting features, for example:
WeeChat supports Python 3 since version 0.3.7, which was released on (12 years, 8 months ago).
The support of Python 3 is optional: the WeeChat python plugin can be compiled with Python 2.7 or Python 3.x, but not both at same time.
As of , it is recommended to compile with Python 2.7 because many scripts won't work at all with Python 3.x, while all scripts should run fine with Python 2.7.
To compile with Python 3.x support and enable quick switch between Python 2.7 and 3.x, see: Compile and test with Python 2.7 and 3.x
Here is the roadmap for the transition to Python 3 in WeeChat:
The scripts which are compatible with Python 3 have tag "py3".
Transition status at various dates:
Date | Scripts | Python scripts | Compatible with Python 3 | Not yet compatible | Notes |
---|---|---|---|---|---|
347 | 216 (62%) | 43 (19%) | 173 (81%) | ||
362 | 226 (62%) | 96 (42%) | 130 (58%) | ||
364 | 228 (62%) | 125 (54%) | 103 (46%) | ||
364 | 228 (62%) | 129 (56%) | 99 (44%) | ||
(today) | 370 [ list ] | 234 (63%) [ list ] | 187 (79%) [ list ] | 47 (21%) [ list ] |
If possible, the author of script should make the necessary changes to make the script compatible with both Python 2.7 and 3.x.
Here's a list of some resources that can help to port scripts to Python 3:
You can not use Python 2.7 and 3.x at same time in WeeChat, but you could compile both versions of the Python plugin and switch the Python plugin with aliases.
First check that you have both Python 2.7 and 3.x libraries installed to compile WeeChat with both versions.
Compile WeeChat with Python 3.x and install it in home directory. From the cloned git repository:
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/dev/weechat -DENABLE_PYTHON3=ON
$ make install
$ mv ~/dev/weechat/lib/weechat/plugins/python.so ~/dev/weechat/python3.so
$ rm -f CMakeCache.txt
$ cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/dev/weechat -DENABLE_PYTHON3=OFF
$ make install
Run WeeChat:
$ ~/dev/weechat/bin/weechat
Check that Python version is 2.7:
/debug libs
Libs:
(…)
python: 2.7.16rc1
Add aliases to quickly switch between Python 2.7 and 3.x:
/alias add py2 /plugin unload python; /plugin load python
/alias add py3 /plugin unload python; /plugin load ~/dev/weechat/python3.so
Now you can type /py2 or /py3 to switch the Python version.
Note: this unloads all scripts because the Python plugin is reloaded.
To switch to Python 3.x:
/py3
Check that Python version is 3.x:
/debug libs
Libs:
(…)
python: 3.7.2+