Friday 2 August 2013

Quickly changing python version in gentoo from 2.x to 3.x series

On my gentoo laptop I am upgrading my python from version 2.7 to 3.2 to aid in some development at my job.

Since it's been set up with 2.7, I cannot utilize some important libraries such as python-sqlite because they are not built for the 3.2 target.

Without going into the more complex explanation on why it works, these are the steps to configure your system to utilize python 3.x.

/etc/portage/make.conf:
USE_PYTHON="3.2 3.3 2.7"
PYTHON_TARGETS="python3_2 python3_3"
PYTHON_SINGLE_TARGET="python3_2"
Simple Explanation:

USE_PYTHON tells emerge the list of desired python versions.

PYTHON_TARGETS tells emerge what targets you prefer to build for. Only if a package cannot build for these targets, yet has a version in USE_PYTHON, will it build in a different version -- I *think*.

PYTHON_SINGLE_TARGET tells emerge that if a package can be built for only one target, use that target. My install of Blender requires the single target point to python3_3.

Be sure to set the python version with eselect.

eselect python set [number]

Next step is to update things by calling python-update, no parameters.
Once your eselect python show --ABI shows the 3.x version you specify in PYTHON_SINGLE_TARGET, you can start rebuilding your system.

This process may take a while. All packages that cannot be built in the 3 series must have the python version specified in /etc/portage/package.use. An example of how to do this is so:

echo "[group]/[package] python_targets_python2_[x] python_single_target_python2_[x]" >> /etc/portage/package.use

Do this until you can get through emerge --deep --update --newuse world -av without dependency issues.

Once you complete the emerge, run revdep-rebuild to make sure your packages are in order.

No comments:

Post a Comment