Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] python: make python2 and python3 alternatives to python
@ 2017-04-13  8:33 Dmitry Rozhkov
  2017-04-13 10:15 ` Alexander Kanavin
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Rozhkov @ 2017-04-13  8:33 UTC (permalink / raw)
  To: openembedded-core

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@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



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-04-18  9:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-13  8:33 [PATCH] python: make python2 and python3 alternatives to python Dmitry Rozhkov
2017-04-13 10:15 ` Alexander Kanavin
2017-04-13 10:18   ` Alexander Kanavin
2017-04-13 14:47   ` Burton, Ross
2017-04-18  8:44     ` Dmitry Rozhkov
2017-04-18  9:33       ` Burton, Ross

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox