Hello, all. If I recall correctly, jlec lately mentioned he'd like to use python-any-r1 and python-single-r1. A particularly inevitable use case for this would be ebuilds using waf, so I'll use that as an example.
The idea is pretty simple. Since the ebuilds in question use waf that
is in Python, the waf-utils.eclass inherits python-any-r1. However,
some of the ebuilds may install Python modules as well, and that asks
for python-single-r1. So the issue is how to make the two work together.
Possible solution: hierarchical eclass overrides
------------------------------------------------
Idea: if both python-any-r1 and python-single-r1 are inherited,
the latter transparently overrides the former. More specifically,
implementation selected for python-single-r1 is used for code designed
for python-any-r1.
Details:
1. PYTHON_COMPAT is declared before the inherits, so it should be always
set by ebuild. If we feel like the eclass needs to provide
the default, it may only do so if ebuild doesn't set its own
PYTHON_COMPAT. The eclass may also need to check ebuild's
PYTHON_COMPAT for conflicts with own supported impls (and die in that
case).
2. PYTHON_REQ_USE likewise. The eclass may append to it (but careful
with that).
3. ${PYTHON_DEPS}:
a. if python-single-r1 is inherited before python-any-r1 (waf-utils),
PYTHON_DEPS is set by the former and the latter doesn't change
it. Both waf-utils and the ebuild add PYTHON_DEPS, so the same
deps get added twice but there's no functional difference from
python-single-r1,
b. if python-single-r1 is inherited after waf-utils, the latter adds
dependency based on python-any-r1 and then the ebuild adds
another based on python-single-r1. With a bit of luck or good
programming, everything works fine. Worst case, additional
version of Python may get pulled build-time as a result of
any-of dep.
4. python_setup() gets exported (overriden) by python-single-r1. Since
it is called after the complete inherit chain, the correct version
is used.
5. python-any-r1_pkg_setup() just calls python-single-r1_pkg_setup().
6. python_check_deps() is not used.
7. python_gen_any_dep() is an issue I don't know how to solve:
a. if python-single-r1 is inherited before python-any-r1, it could
override it so that it generates just a single dependency
matching the syntax used for python-single-r1,
b. but if waf-utils is inherited first, the dep strings will be
generated before python-single-r1 is inherited,
c. possibly we could just ban python_gen_any_dep() and make it
export magical variable that will cause python-single-r1 inherit
to die.
Your thoughts?
--
Best regards,
Michał Górny
signature.asc
Description: PGP signature
