[OE-core] [PATCH] python: make python2 and python3 alternatives to python
Dmitry Rozhkov
dmitry.rozhkov at linux.intel.com
Thu Apr 13 08:33:44 UTC 2017
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.
Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov at linux.intel.com>
---
meta/recipes-devtools/python/python3_3.5.2.bb | 9 +++++++++
meta/recipes-devtools/python/python_2.7.13.bb | 7 +++++++
2 files changed, 16 insertions(+)
diff --git a/meta/recipes-devtools/python/python3_3.5.2.bb b/meta/recipes-devtools/python/python3_3.5.2.bb
index 2ff7c9e..310d43f 100644
--- a/meta/recipes-devtools/python/python3_3.5.2.bb
+++ b/meta/recipes-devtools/python/python3_3.5.2.bb
@@ -221,4 +221,13 @@ FILES_${PN}-misc = "${libdir}/python${PYTHON_MAJMIN}"
PACKAGES += "${PN}-man"
FILES_${PN}-man = "${datadir}/man"
+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"
+
BBCLASSEXTEND = "nativesdk"
diff --git a/meta/recipes-devtools/python/python_2.7.13.bb b/meta/recipes-devtools/python/python_2.7.13.bb
index 4ef9952..0cf7498 100644
--- a/meta/recipes-devtools/python/python_2.7.13.bb
+++ b/meta/recipes-devtools/python/python_2.7.13.bb
@@ -168,4 +168,11 @@ do_install_ptest() {
PACKAGES += "${PN}-man"
FILES_${PN}-man = "${datadir}/man"
+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"
+
BBCLASSEXTEND = "nativesdk"
--
2.9.3
More information about the Openembedded-core
mailing list