[meta-python2,1/1] python: use update-alternatives for python link

Submitted by Slater, Joseph on July 6, 2021, 6:18 p.m. | Patch ID: 179919

Details

Message ID 20210706181849.18345-1-joe.slater@windriver.com
State New
Headers show

Commit Message

Slater, Joseph July 6, 2021, 6:18 p.m.
Make the link of python to python2.7 an alternative.  This
allows python3 to provide a link if we are not around, but
makes our link override any python3 provides, assuming he
uses the default priority.

Signed-off-by: Joe Slater <joe.slater@windriver.com>
---
 recipes-devtools/python/python_2.7.18.bb | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/recipes-devtools/python/python_2.7.18.bb b/recipes-devtools/python/python_2.7.18.bb
index 7350562..3faf154 100644
--- a/recipes-devtools/python/python_2.7.18.bb
+++ b/recipes-devtools/python/python_2.7.18.bb
@@ -34,7 +34,14 @@  SRC_URI += " \
 
 S = "${WORKDIR}/Python-${PV}"
 
-inherit autotools multilib_header python-dir pythonnative ptest
+inherit autotools multilib_header python-dir pythonnative ptest update-alternatives
+
+# Make 'python' an alternative so that if python3 also provides it, we will be the default.
+#
+ALTERNATIVE_${PN}-core = "python"
+ALTERNATIVE_LINK_NAME[python] = "${bindir}/python"
+ALTERNATIVE_TARGET[python] = "${bindir}/python${PYTHON_MAJMIN}"
+ALTERNATIVE_PRIORITY[python] = "50"
 
 EXTRA_OECONF += "--with-system-ffi"
 

Comments

Martin Jansa July 9, 2021, 12:07 p.m.
As this wasn't needed until now and python3 also doesn't use u-a for
${bindir}/python as all python3 scripts should explicitly call python3, why
do you think it would be worth adding to dead python2 recipe?

If you need this symlink would it make sense to use separate recipe
like python-is-python2/python-is-python3 packages in debian based systems
and create the symlink there instead of u-a in python itself?

On Tue, Jul 6, 2021 at 8:19 PM Joe Slater <joe.slater@windriver.com> wrote:

> Make the link of python to python2.7 an alternative.  This
> allows python3 to provide a link if we are not around, but
> makes our link override any python3 provides, assuming he
> uses the default priority.
>
> Signed-off-by: Joe Slater <joe.slater@windriver.com>
> ---
>  recipes-devtools/python/python_2.7.18.bb | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/recipes-devtools/python/python_2.7.18.bb
> b/recipes-devtools/python/python_2.7.18.bb
> index 7350562..3faf154 100644
> --- a/recipes-devtools/python/python_2.7.18.bb
> +++ b/recipes-devtools/python/python_2.7.18.bb
> @@ -34,7 +34,14 @@ SRC_URI += " \
>
>  S = "${WORKDIR}/Python-${PV}"
>
> -inherit autotools multilib_header python-dir pythonnative ptest
> +inherit autotools multilib_header python-dir pythonnative ptest
> update-alternatives
> +
> +# Make 'python' an alternative so that if python3 also provides it, we
> will be the default.
> +#
> +ALTERNATIVE_${PN}-core = "python"
> +ALTERNATIVE_LINK_NAME[python] = "${bindir}/python"
> +ALTERNATIVE_TARGET[python] = "${bindir}/python${PYTHON_MAJMIN}"
> +ALTERNATIVE_PRIORITY[python] = "50"
>
>  EXTRA_OECONF += "--with-system-ffi"
>
> --
> 2.29.2
>
>
> 
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#92165): https://lists.openembedded.org/g/openembedded-devel/message/92165
Mute This Topic: https://lists.openembedded.org/mt/84027038/3617530
Group Owner: openembedded-devel+owner@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [oe-patchwork@oe-patch.openembedded.org]
-=-=-=-=-=-=-=-=-=-=-=-