Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 417601 - python-distutils-ng: would use a function to generate USEdeps
Summary: python-distutils-ng: would use a function to generate USEdeps
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-26 09:59 UTC by Michał Górny
Modified: 2013-07-22 10:13 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Test case for calling function in DEPEND (a.bash,482 bytes, text/plain)
2012-05-27 08:27 UTC, Michał Górny
Details
Test case for using a variable in DEPEND (b.bash,393 bytes, text/plain)
2012-05-27 08:27 UTC, Michał Górny
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-05-26 09:59:14 UTC
Writing USE-deps by hand is quite annoying. Especially that they have to be repeated for every Python version in PYTHON_COMPAT. We should probably provide a helper function to handle that. Or just a dumb variable like ${PYTHON_TARGET_USE}.

i.e.:

RDEPEND=">=app-portage/gentoopm-0.2.1[python_targets_python2_6?,python_targets_python2_7?,...]"

to:

RDEPEND=">=app-portage/gentoopm-0.2.1[${PYTHON_TARGET_USE}]"
Comment 1 Krzysztof Pawlik (RETIRED) gentoo-dev 2012-05-26 17:40:06 UTC
Like I've pointed out on ML: feel free to implement.
Comment 2 Mike Gilbert gentoo-dev 2012-05-26 23:47:29 UTC
(In reply to comment #0)

I actually like the approach Arfrever has taken. He has a function called python_abi_depend. You pass a package atom to this function, and it echoes a use-dep back.

For example, if you have this:

DEPEND="$(python_abi_depend dev-python/foo)"

This would generate a dependency string like this:

DEPEND="dev-python/foo[python_abis_2.6?,python_abis_2.7?,...]"

The function also accepts options to include/exclude certain python abis for each dependency; this is handy since python packages sometimes have different dependencies depending on the python version.
Comment 3 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-05-27 06:58:40 UTC
(In reply to comment #2)
> (In reply to comment #0)
> 
> I actually like the approach Arfrever has taken. He has a function called
> python_abi_depend. You pass a package atom to this function, and it echoes a
> use-dep back.
> 
> For example, if you have this:
> 
> DEPEND="$(python_abi_depend dev-python/foo)"

I really dislike the overhead of function calling here, especially that it's going to happen in the global scope and for a number of packages. I'm afraid it's going to make metadata generation a PITA.

I think we should try to keep this simple, or at least provide a simpler variant which would work as well in the most cases.

> The function also accepts options to include/exclude certain python abis for
> each dependency; this is handy since python packages sometimes have
> different dependencies depending on the python version.

Unless it outputs a completely different form, I don't think it's actually useful (i.e. like 'python2_6? ( foo/bar[python2_6?] )'). And if the output is actually like that, I think it'd be saner to create another function for that.
Comment 4 Maxim Koltsov (RETIRED) gentoo-dev 2012-05-27 07:07:05 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > (In reply to comment #0)
> > 
> > I actually like the approach Arfrever has taken. He has a function called
> > python_abi_depend. You pass a package atom to this function, and it echoes a
> > use-dep back.
> > 
> > For example, if you have this:
> > 
> > DEPEND="$(python_abi_depend dev-python/foo)"
> 
> I really dislike the overhead of function calling here, especially that it's
> going to happen in the global scope and for a number of packages. I'm afraid
> it's going to make metadata generation a PITA.
> 
> I think we should try to keep this simple, or at least provide a simpler
> variant which would work as well in the most cases.

You can look at ruby-ng eclass, since our new python-distutils-ng is very close to it. There are functions like ruby_add_bdepend and ruby_add_rdepend for this task. We just can adapt them to python.
And since no one complains for ruby, no one will for python.
Comment 5 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-05-27 07:11:08 UTC
(In reply to comment #4)
> You can look at ruby-ng eclass, since our new python-distutils-ng is very
> close to it. There are functions like ruby_add_bdepend and ruby_add_rdepend
> for this task. We just can adapt them to python.

Monkey see, monkey do?

> And since no one complains for ruby, no one will for python.

Because no-one uses ruby :P.
Comment 6 Maxim Koltsov (RETIRED) gentoo-dev 2012-05-27 07:12:49 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > You can look at ruby-ng eclass, since our new python-distutils-ng is very
> > close to it. There are functions like ruby_add_bdepend and ruby_add_rdepend
> > for this task. We just can adapt them to python.
> 
> Monkey see, monkey do?

Nope. We already have one working approach, no need to invent something new.

> > And since no one complains for ruby, no one will for python.
> 
> Because no-one uses ruby :P.

There are still lots of ruby ebuilds in tree invovled in metadata generation.
Comment 7 Mike Gilbert gentoo-dev 2012-05-27 07:22:57 UTC
(In reply to comment #3)
> I really dislike the overhead of function calling here, especially that it's
> going to happen in the global scope and for a number of packages. I'm afraid
> it's going to make metadata generation a PITA.

I would prefer not to have an argument about performance without any numbers to justify either position. My guess is that it will make a relatively small difference, but again, I have no numbers and do not intend to waste time gathering them.

> Unless it outputs a completely different form, I don't think it's actually
> useful (i.e. like 'python2_6? ( foo/bar[python2_6?] )'). And if the output
> is actually like that, I think it'd be saner to create another function for
> that.

Thinking this out, foo/bar[python2_6?] is equivalent to this:

python2_6? ( foo/bar[python2_6] )
!python2_6? ( foo/bar )

We only want the first line in cases where a dependency is needed only for a subset of python targets.
Comment 8 Mike Gilbert gentoo-dev 2012-05-27 07:30:01 UTC
Also, I personally prefer the concept of a function that echos dependency atoms over the ruby approach of appending to specific variables.

The method used by python_abi_depend can be used for 3 [PR]DEPEND variables, or any other variable the ebuild author happens to use (like COMMON_DEPEND).
Comment 9 Maxim Koltsov (RETIRED) gentoo-dev 2012-05-27 07:31:52 UTC
(In reply to comment #8)
> Also, I personally prefer the concept of a function that echos dependency
> atoms over the ruby approach of appending to specific variables.
> 
> The method used by python_abi_depend can be used for 3 [PR]DEPEND variables,
> or any other variable the ebuild author happens to use (like COMMON_DEPEND).

And also it makes it possible to do thinks like DEPEND="python? ( $(python_abi_depend) )"
Comment 10 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-05-27 08:26:16 UTC
(In reply to comment #7)
> (In reply to comment #3)
> > I really dislike the overhead of function calling here, especially that it's
> > going to happen in the global scope and for a number of packages. I'm afraid
> > it's going to make metadata generation a PITA.
> 
> I would prefer not to have an argument about performance without any numbers
> to justify either position. My guess is that it will make a relatively small
> difference, but again, I have no numbers and do not intend to waste time
> gathering them.

$ bash a.bash 

real	0m7.251s
user	0m1.869s
sys	0m3.566s

$ bash b.bash 

real	0m0.236s
user	0m0.231s
sys	0m0.005s

a.bash 'simulates' 1000 runs with 5 deps; 5 calls of function which just outputs stuff, the same stuff over and over again.

b.bash 'simulates' 1000 runs with 5 deps; 1 call of function to set variable ('source eclass') + 5 uses of that variable.
Comment 11 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-05-27 08:27:27 UTC
Created attachment 313217 [details]
Test case for calling function in DEPEND
Comment 12 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-05-27 08:27:45 UTC
Created attachment 313219 [details]
Test case for using a variable in DEPEND
Comment 13 Mike Gilbert gentoo-dev 2012-05-27 16:09:53 UTC
(In reply to comment #10)

Thanks for that.

Thinking about it, I guess it does make sense to "cache" the most common case in a variable; otherwise we are just regenerating the same string over and over.

So maybe a global variable for the common case, and a function to deal with the others?
Comment 14 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-05-27 16:20:41 UTC
(In reply to comment #13)
> (In reply to comment #10)
> 
> Thanks for that.
> 
> Thinking about it, I guess it does make sense to "cache" the most common
> case in a variable; otherwise we are just regenerating the same string over
> and over.
> 
> So maybe a global variable for the common case, and a function to deal with
> the others?

That's what I said. But I'd just start with the variable, and wait with the function till we know best what it needs to deal.
Comment 15 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2013-07-22 10:13:52 UTC
The eclass is no longer developed.