python3: make python point to python3 (resolves #570)

This commit is just a copy of the patch that Dmitry Rozhkov
submitted to openembedded-core, but it was rejected there [1].

If only python3 is installed on an image nothing provides
/usr/bin/python even though many scripts compatible with
both python2 and python3 just state `#!/usr/bin/env python`
in their shebang line.

Make python and python3 recipes provide alternatives for
/usr/bin/python and /usr/bin/python-config. By default
python2 has higher priority over python3.

In meta-ros, we need this behaviour for ROS_USE_PYTHON3 = "yes"
because ROS packages are always written to be python2 and python3
compatible.

[1] https://patchwork.openembedded.org/patch/139143/

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
This commit is contained in:
Lukas Bulwahn 2018-02-02 20:54:36 +01:00
parent bbe1c74839
commit 6ddc0cc518
2 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,8 @@
inherit update-alternatives
ALTERNATIVE_PRIORITY = "80"
ALTERNATIVE_${PN}-core = "python python_config"
ALTERNATIVE_LINK_NAME[python] = "${bindir}/python"
ALTERNATIVE_LINK_NAME[python_config] = "${bindir}/python-config"
ALTERNATIVE_TARGET[python] = "${bindir}/python3"
ALTERNATIVE_TARGET[python_config] = "${bindir}/python3-config"

View File

@ -1,3 +1,10 @@
EXTRA_OECONF += "\
--enable-ipv6 \
"
inherit update-alternatives
ALTERNATIVE_PRIORITY = "100"
ALTERNATIVE_${PN}-core = "python python_config"
ALTERNATIVE_LINK_NAME[python] = "${bindir}/python"
ALTERNATIVE_LINK_NAME[python_config] = "${bindir}/python-config"