public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] ebuild : how to check for python version
@ 2020-08-02 14:47 Helmut Jarausch
  2020-08-02 16:15 ` Ramon Fischer
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Helmut Jarausch @ 2020-08-02 14:47 UTC (permalink / raw
  To: gentoo-user

Hi,
in an ebuild I have to apply a patch only if this package is installed  
for python3.9.
The ebuild should work for PYTHON_COMPAT=( python3_{8,9} )

How can I check for Pythons version in src_prepare or similar functions.

Many thanks for a hint,
Helmut


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

* Re: [gentoo-user] ebuild : how to check for python version
  2020-08-02 14:47 [gentoo-user] ebuild : how to check for python version Helmut Jarausch
@ 2020-08-02 16:15 ` Ramon Fischer
  2020-08-02 17:34   ` Helmut Jarausch
  2020-08-02 23:44 ` Alexey Mishustin
  2020-08-11 13:08 ` Mike Gilbert
  2 siblings, 1 reply; 10+ messages in thread
From: Ramon Fischer @ 2020-08-02 16:15 UTC (permalink / raw
  To: gentoo-user

Hi Helmut,

maybe "python_is_python3"[1] will help? I am still new to creating 
ebuilds. :)

-Ramon

[1] 
https://devmanual.gentoo.org/eclass-reference/python-utils-r1.eclass/index.html

On 02/08/2020 16:47, Helmut Jarausch wrote:
> Hi,
> in an ebuild I have to apply a patch only if this package is installed 
> for python3.9.
> The ebuild should work for PYTHON_COMPAT=( python3_{8,9} )
>
> How can I check for Pythons version in src_prepare or similar functions.
>
> Many thanks for a hint,
> Helmut
>



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

* Re: [gentoo-user] ebuild : how to check for python version
  2020-08-02 16:15 ` Ramon Fischer
@ 2020-08-02 17:34   ` Helmut Jarausch
  2020-08-02 20:13     ` james
  0 siblings, 1 reply; 10+ messages in thread
From: Helmut Jarausch @ 2020-08-02 17:34 UTC (permalink / raw
  To: gentoo-user

On 08/02/2020 06:15:12 PM, Ramon Fischer wrote:
> Hi Helmut,
> 
> maybe "python_is_python3"[1] will help? I am still new to creating
> ebuilds. :)
> 
> -Ramon
> 
Thanks Ramon for this hint.
I need to know which version of Python3 ( Python3.8 or Python3.9)
and I could see how python_is_python3 helps here.

Helmut


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

* Re: [gentoo-user] ebuild : how to check for python version
  2020-08-02 17:34   ` Helmut Jarausch
@ 2020-08-02 20:13     ` james
  0 siblings, 0 replies; 10+ messages in thread
From: james @ 2020-08-02 20:13 UTC (permalink / raw
  To: gentoo-user

On 8/2/20 1:34 PM, Helmut Jarausch wrote:
> On 08/02/2020 06:15:12 PM, Ramon Fischer wrote:
>> Hi Helmut,
>>
>> maybe "python_is_python3"[1] will help? I am still new to creating
>> ebuilds. :)
>>
>> -Ramon
>>
> Thanks Ramon for this hint.
> I need to know which version of Python3 ( Python3.8 or Python3.9)
> and I could see how python_is_python3 helps here.
> 
> Helmut
> 

editing

/usr/portage/profiles/base/use.stable.mask

might give you the granularity of control you see, BUT
I have not tested it yet, related to python3_9, so I'd recommend deep 
research and change packages one at a time, regardless of how you choose 
to use  version 3_9.


https://docs.python.org/3.9/whatsnew/3.9.html

just because it is (?) release, does not mean it is stable and ready for 
gentoo beta testing (my speculation).


hth,

James


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

* Re: [gentoo-user] ebuild : how to check for python version
  2020-08-02 14:47 [gentoo-user] ebuild : how to check for python version Helmut Jarausch
  2020-08-02 16:15 ` Ramon Fischer
@ 2020-08-02 23:44 ` Alexey Mishustin
  2020-08-03  8:05   ` Neil Bothwick
  2020-08-11 13:08 ` Mike Gilbert
  2 siblings, 1 reply; 10+ messages in thread
From: Alexey Mishustin @ 2020-08-02 23:44 UTC (permalink / raw
  To: Gentoo

вс, 2 авг. 2020 г. в 17:48, Helmut Jarausch <jarausch@skynet.be>:
>
> Hi,
> in an ebuild I have to apply a patch only if this package is installed
> for python3.9.
> The ebuild should work for PYTHON_COMPAT=( python3_{8,9} )
>
> How can I check for Pythons version in src_prepare or similar functions.

Hi,

This should check if 3.9 is installed:
if has_version '=dev-lang/python-3.9'; then

But for which python version will the package be installed - isn't it
another question? (still learning too)

-- 
Best regards,
Alex


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

* Re: [gentoo-user] ebuild : how to check for python version
  2020-08-02 23:44 ` Alexey Mishustin
@ 2020-08-03  8:05   ` Neil Bothwick
  2020-08-03  9:57     ` Alexey Mishustin
  0 siblings, 1 reply; 10+ messages in thread
From: Neil Bothwick @ 2020-08-03  8:05 UTC (permalink / raw
  To: gentoo-user

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

On Mon, 3 Aug 2020 02:44:43 +0300, Alexey Mishustin wrote:

> > in an ebuild I have to apply a patch only if this package is installed
> > for python3.9.
> > The ebuild should work for PYTHON_COMPAT=( python3_{8,9} )
> >
> > How can I check for Pythons version in src_prepare or similar
> > functions.  
> 
> This should check if 3.9 is installed:
> if has_version '=dev-lang/python-3.9'; then

Shouldn't that be has_version 'dev-lang/python:3.9' to check for any
version of 3.9?

However, that only checks for which python versions are installed before
the ebuild is invoked. Would it make more sense to check PYTHON_TARGETS
instead? That can also cover the situation of the package being
installed without 3.9 but then 3.9 being installed later as a rebuild
would be triggered by --changed-use.


-- 
Neil Bothwick

"We can't solve problems by using the same kind of thinking we used when
we created them." (Albert Einstein)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [gentoo-user] ebuild : how to check for python version
  2020-08-03  8:05   ` Neil Bothwick
@ 2020-08-03  9:57     ` Alexey Mishustin
  0 siblings, 0 replies; 10+ messages in thread
From: Alexey Mishustin @ 2020-08-03  9:57 UTC (permalink / raw
  To: Gentoo

пн, 3 авг. 2020 г. в 11:05, Neil Bothwick <neil@digimed.co.uk>:
>
> On Mon, 3 Aug 2020 02:44:43 +0300, Alexey Mishustin wrote:
>
> > This should check if 3.9 is installed:
> > if has_version '=dev-lang/python-3.9'; then
>
> Shouldn't that be has_version 'dev-lang/python:3.9' to check for any
> version of 3.9?

Sure! My fault.

> However, that only checks for which python versions are installed before
> the ebuild is invoked. Would it make more sense to check PYTHON_TARGETS
> instead? That can also cover the situation of the package being
> installed without 3.9 but then 3.9 being installed later as a rebuild
> would be triggered by --changed-use.

Looks like it's what Helmut was looking for.

-- 
Best regards,
Alex


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

* Re: [gentoo-user] ebuild : how to check for python version
  2020-08-02 14:47 [gentoo-user] ebuild : how to check for python version Helmut Jarausch
  2020-08-02 16:15 ` Ramon Fischer
  2020-08-02 23:44 ` Alexey Mishustin
@ 2020-08-11 13:08 ` Mike Gilbert
  2020-08-11 13:38   ` Helmut Jarausch
  2 siblings, 1 reply; 10+ messages in thread
From: Mike Gilbert @ 2020-08-11 13:08 UTC (permalink / raw
  To: gentoo-user

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

On Sun, Aug 2, 2020 at 10:47 AM Helmut Jarausch <jarausch@skynet.be> wrote:

> Hi,
> in an ebuild I have to apply a patch only if this package is installed
> for python3.9.
> The ebuild should work for PYTHON_COMPAT=( python3_{8,9} )
>
> How can I check for Pythons version in src_prepare or similar functions.
>
> Many thanks for a hint,
> Helmut
>
> I would suggest creating a patch that can be applied unconditionally
instead.

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

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

* Re: [gentoo-user] ebuild : how to check for python version
  2020-08-11 13:08 ` Mike Gilbert
@ 2020-08-11 13:38   ` Helmut Jarausch
  2020-08-11 14:35     ` Mike Gilbert
  0 siblings, 1 reply; 10+ messages in thread
From: Helmut Jarausch @ 2020-08-11 13:38 UTC (permalink / raw
  To: gentoo-user

On 08/11/2020 03:08:16 PM, Mike Gilbert wrote:
> On Sun, Aug 2, 2020 at 10:47 AM Helmut Jarausch  
> <_\bj_\ba_\br_\ba_\bu_\bs_\bc_\bh_\b@_\bs_\bk_\by_\bn_\be_\bt_\b._\bb_\be> wrote:
>      Hi,
>      in an ebuild I have to apply a patch only if this package is
>      installed  
>      for python3.9.
>      The ebuild should work for PYTHON_COMPAT=( python3_{8,9} )
> 
>      How can I check for Pythons version in src_prepare or similar
>      functions.
> 
>      Many thanks for a hint,
>      Helmut
> 
> I would suggest creating a patch that can be applied unconditionally  
> instead.  
> 

That would imply different function definitions within an 'if / else'  
clause.
I don't like this.


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

* Re: [gentoo-user] ebuild : how to check for python version
  2020-08-11 13:38   ` Helmut Jarausch
@ 2020-08-11 14:35     ` Mike Gilbert
  0 siblings, 0 replies; 10+ messages in thread
From: Mike Gilbert @ 2020-08-11 14:35 UTC (permalink / raw
  To: gentoo-user

On Tue, Aug 11, 2020 at 9:38 AM Helmut Jarausch <jarausch@skynet.be> wrote:
>
> On 08/11/2020 03:08:16 PM, Mike Gilbert wrote:
> > On Sun, Aug 2, 2020 at 10:47 AM Helmut Jarausch
> > <_ j_ a_ r_ a_ u_ s_ c_ h_ @_ s_ k_ y_ n_ e_ t_ ._ b_ e> wrote:
> >      Hi,
> >      in an ebuild I have to apply a patch only if this package is
> >      installed
> >      for python3.9.
> >      The ebuild should work for PYTHON_COMPAT=( python3_{8,9} )
> >
> >      How can I check for Pythons version in src_prepare or similar
> >      functions.
> >
> >      Many thanks for a hint,
> >      Helmut
> >
> > I would suggest creating a patch that can be applied unconditionally
> > instead.
> >
>
> That would imply different function definitions within an 'if / else'
> clause.
> I don't like this.
>

What will you do when someone wants/needs to install it for both
python3.8 and python3.9 simultaneously?

If you want to support both versions, it's better to have code that
actually works with both of them.


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

end of thread, other threads:[~2020-08-11 14:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-02 14:47 [gentoo-user] ebuild : how to check for python version Helmut Jarausch
2020-08-02 16:15 ` Ramon Fischer
2020-08-02 17:34   ` Helmut Jarausch
2020-08-02 20:13     ` james
2020-08-02 23:44 ` Alexey Mishustin
2020-08-03  8:05   ` Neil Bothwick
2020-08-03  9:57     ` Alexey Mishustin
2020-08-11 13:08 ` Mike Gilbert
2020-08-11 13:38   ` Helmut Jarausch
2020-08-11 14:35     ` Mike Gilbert

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