All of lore.kernel.org
 help / color / mirror / Atom feed
* [meta-python2][PATCH 1/1] python: use update-alternatives for python link
@ 2021-07-06 18:18 Joe Slater
  2021-07-09 12:07 ` [oe] " Martin Jansa
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Slater @ 2021-07-06 18:18 UTC (permalink / raw)
  To: openembedded-devel; +Cc: joe.slater, randy.macleod

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


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

* Re: [oe] [meta-python2][PATCH 1/1] python: use update-alternatives for python link
  2021-07-06 18:18 [meta-python2][PATCH 1/1] python: use update-alternatives for python link Joe Slater
@ 2021-07-09 12:07 ` Martin Jansa
  2021-07-19 21:45   ` Joe Slater
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Jansa @ 2021-07-09 12:07 UTC (permalink / raw)
  To: Joe Slater; +Cc: openembedded-devel, Randy MacLeod

[-- Attachment #1: Type: text/plain, Size: 1755 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 2633 bytes --]

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

* Re: [oe] [meta-python2][PATCH 1/1] python: use update-alternatives for python link
  2021-07-09 12:07 ` [oe] " Martin Jansa
@ 2021-07-19 21:45   ` Joe Slater
  2021-07-20 13:40     ` Martin Jansa
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Slater @ 2021-07-19 21:45 UTC (permalink / raw)
  To: Martin Jansa; +Cc: openembedded-devel, MacLeod, Randy

[-- Attachment #1: Type: text/plain, Size: 3369 bytes --]

Sorry for the delay, but I your message got put in a folder I don’t look at much.  Some projects, like blktrace, have scripts that work with python2 or python3 and want to leave the shebangs “generic”.  Of course, that won’t work if python3 doesn’t supply “python”.  I admit that wanting to put both python2 and python3 in an image is weird, but we could do it and have both versions supply “python”.

I don’t see any downside to making “python” a u-a link.  It’s already a link.  I admit, though, that there is no guarantee python3 will be allowed to supply a u-a link.

Joe

From: Martin Jansa <martin.jansa@gmail.com>
Sent: Friday, July 9, 2021 5:07 AM
To: Slater, Joseph <joe.slater@windriver.com>
Cc: openembedded-devel <openembedded-devel@lists.openembedded.org>; MacLeod, Randy <Randy.MacLeod@windriver.com>
Subject: Re: [oe] [meta-python2][PATCH 1/1] python: use update-alternatives for python link

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<mailto: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<mailto:joe.slater@windriver.com>>
---
 recipes-devtools/python/python_2.7.18.bb<https://urldefense.com/v3/__http:/python_2.7.18.bb__;!!AjveYdw8EvQ!IzYw73MQjD6zus_YwfXCpL1kV27Ob5bh1iViRVPnJ4yt0eoqSXx8vPwZ9wdWmHEceZ8$> | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/recipes-devtools/python/python_2.7.18.bb<https://urldefense.com/v3/__http:/python_2.7.18.bb__;!!AjveYdw8EvQ!IzYw73MQjD6zus_YwfXCpL1kV27Ob5bh1iViRVPnJ4yt0eoqSXx8vPwZ9wdWmHEceZ8$> b/recipes-devtools/python/python_2.7.18.bb<https://urldefense.com/v3/__http:/python_2.7.18.bb__;!!AjveYdw8EvQ!IzYw73MQjD6zus_YwfXCpL1kV27Ob5bh1iViRVPnJ4yt0eoqSXx8vPwZ9wdWmHEceZ8$>
index 7350562..3faf154 100644
--- a/recipes-devtools/python/python_2.7.18.bb<https://urldefense.com/v3/__http:/python_2.7.18.bb__;!!AjveYdw8EvQ!IzYw73MQjD6zus_YwfXCpL1kV27Ob5bh1iViRVPnJ4yt0eoqSXx8vPwZ9wdWmHEceZ8$>
+++ b/recipes-devtools/python/python_2.7.18.bb<https://urldefense.com/v3/__http:/python_2.7.18.bb__;!!AjveYdw8EvQ!IzYw73MQjD6zus_YwfXCpL1kV27Ob5bh1iViRVPnJ4yt0eoqSXx8vPwZ9wdWmHEceZ8$>
@@ -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




[-- Attachment #2: Type: text/html, Size: 6271 bytes --]

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

* Re: [oe] [meta-python2][PATCH 1/1] python: use update-alternatives for python link
  2021-07-19 21:45   ` Joe Slater
@ 2021-07-20 13:40     ` Martin Jansa
  0 siblings, 0 replies; 4+ messages in thread
From: Martin Jansa @ 2021-07-20 13:40 UTC (permalink / raw)
  To: Joe Slater; +Cc: openembedded-devel, MacLeod, Randy

[-- Attachment #1: Type: text/plain, Size: 4189 bytes --]

Would it make sense to replace shebang in such scripts to explicitly call
python3? As it's not only the u-a for the python symlink, but RDEPENDS of
the package should pull the right interpreter as well. Always installing
supported python3-core for blktrace scripts is IMHO much better than
allowing blktrace script so run with EOL python2 in some weird case when
python2 is in the image and python3 isn't.

At least that's what I'm doing with generic shebangs in meta-ros recipes.

Also as you might have noticed the target python is already blacklisted in
this layer.

On Mon, Jul 19, 2021 at 11:45 PM Joe Slater <joe.slater@windriver.com>
wrote:

> Sorry for the delay, but I your message got put in a folder I don’t look
> at much.  Some projects, like blktrace, have scripts that work with python2
> or python3 and want to leave the shebangs “generic”.  Of course, that won’t
> work if python3 doesn’t supply “python”.  I admit that wanting to put both
> python2 and python3 in an image is weird, but we could do it and have both
> versions supply “python”.
>
>
>
> I don’t see any downside to making “python” a u-a link.  It’s already a
> link.  I admit, though, that there is no guarantee python3 will be allowed
> to supply a u-a link.
>
>
>
> Joe
>
>
>
> *From:* Martin Jansa <martin.jansa@gmail.com>
> *Sent:* Friday, July 9, 2021 5:07 AM
> *To:* Slater, Joseph <joe.slater@windriver.com>
> *Cc:* openembedded-devel <openembedded-devel@lists.openembedded.org>;
> MacLeod, Randy <Randy.MacLeod@windriver.com>
> *Subject:* Re: [oe] [meta-python2][PATCH 1/1] python: use
> update-alternatives for python link
>
>
>
> 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
> <https://urldefense.com/v3/__http:/python_2.7.18.bb__;!!AjveYdw8EvQ!IzYw73MQjD6zus_YwfXCpL1kV27Ob5bh1iViRVPnJ4yt0eoqSXx8vPwZ9wdWmHEceZ8$>
> | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/recipes-devtools/python/python_2.7.18.bb
> <https://urldefense.com/v3/__http:/python_2.7.18.bb__;!!AjveYdw8EvQ!IzYw73MQjD6zus_YwfXCpL1kV27Ob5bh1iViRVPnJ4yt0eoqSXx8vPwZ9wdWmHEceZ8$>
> b/recipes-devtools/python/python_2.7.18.bb
> <https://urldefense.com/v3/__http:/python_2.7.18.bb__;!!AjveYdw8EvQ!IzYw73MQjD6zus_YwfXCpL1kV27Ob5bh1iViRVPnJ4yt0eoqSXx8vPwZ9wdWmHEceZ8$>
> index 7350562..3faf154 100644
> --- a/recipes-devtools/python/python_2.7.18.bb
> <https://urldefense.com/v3/__http:/python_2.7.18.bb__;!!AjveYdw8EvQ!IzYw73MQjD6zus_YwfXCpL1kV27Ob5bh1iViRVPnJ4yt0eoqSXx8vPwZ9wdWmHEceZ8$>
> +++ b/recipes-devtools/python/python_2.7.18.bb
> <https://urldefense.com/v3/__http:/python_2.7.18.bb__;!!AjveYdw8EvQ!IzYw73MQjD6zus_YwfXCpL1kV27Ob5bh1iViRVPnJ4yt0eoqSXx8vPwZ9wdWmHEceZ8$>
> @@ -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
>
>
>
> 
>
>

[-- Attachment #2: Type: text/html, Size: 6451 bytes --]

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

end of thread, other threads:[~2021-07-20 13:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-06 18:18 [meta-python2][PATCH 1/1] python: use update-alternatives for python link Joe Slater
2021-07-09 12:07 ` [oe] " Martin Jansa
2021-07-19 21:45   ` Joe Slater
2021-07-20 13:40     ` Martin Jansa

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.