All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH] python: make python2 and python3 alternatives to python
Date: Thu, 13 Apr 2017 11:33:44 +0300	[thread overview]
Message-ID: <20170413083344.22737-1-dmitry.rozhkov@linux.intel.com> (raw)

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



             reply	other threads:[~2017-04-13  8:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-13  8:33 Dmitry Rozhkov [this message]
2017-04-13 10:15 ` [PATCH] python: make python2 and python3 alternatives to python 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170413083344.22737-1-dmitry.rozhkov@linux.intel.com \
    --to=dmitry.rozhkov@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.