As we all know, Python has reached the end of its life, which means that it will no longer receive any support, bugfixes, or security updates. In this article, I will explain how to migrate Gentoo from Python2 to Python3.
In my system, we have the following versions of Python available:
dev-lang/python
Available versions:
(2.7) 2.7.14-r1 ~2.7.14-r2 2.7.15
(3.4) 3.4.5-r1(3.4/3.4m)^t ~3.4.6-r1(3.4/3.4m) 3.4.8(3.4/3.4m) ~3.4.8-r1(3.4/3.4m)
(3.5) 3.5.4-r1(3.5/3.5m)^t 3.5.5(3.5/3.5m)^t ~3.5.5-r1(3.5/3.5m)^t
(3.6) 3.6.3-r1(3.6/3.6m)^t ~3.6.4(3.6/3.6m)^t 3.6.5(3.6/3.6m)^t ~3.6.5-r1(3.6/3.6m)^t ~3.6.6(3.6/3.6m)^t
(3.7) ~3.7.0(3.7/3.7m)^t
To choose one or the other, we will use the eselect utility, first we list the versions recognized by Gentoo and then we indicate which one we want to use:
eselect python set X
We assign the PYTHON_TARGETS and PYTHON_SINGLE_TARGET variables in make.conf so that the software is compiled according to our preferences.
PYTHON_TARGETS="python2_7 python3_6"
PYTHON_SINGLE_TARGET="python3_6"
From now on, if any ebuild complains because it only supports an old version of Python, we compile with that version until the ebuild is updated to Python3.
An example could be this:
We can get a list of ebuilds compiled with Python2.7:
Now we can remove unnecessary versions of Python:
NOTE: Keep in mind that we will have to run this command periodically as Python versions are updated.
We update the eselect list: