1 |
Hello, |
2 |
|
3 |
After some thinking, I think I found an optimal solution to |
4 |
implementing various kinds of Python dependencies and PYTHON_USE_WITH*. |
5 |
|
6 |
As a note, all variable names are dirty and not official. Feel free to |
7 |
suggest better ones. |
8 |
|
9 |
1. Add a user-defined variable PYTHON_USE. If user needed any specific |
10 |
flags from a Python dependency, he can set the USE dependency string |
11 |
there. The string will have to follow the general rules for USE |
12 |
dependencies and be correct for every Python implementation specified |
13 |
in PYTHON_COMPAT (this may require USE defaults). For example: |
14 |
|
15 |
PYTHON_USE="ncurses,sqlite" |
16 |
|
17 |
2. Add a eclass-defined variable PYTHON_DEPEND. It will be always |
18 |
exported, and contain a dependency string created using PYTHON_COMPAT |
19 |
and PYTHON_USE -- the most simple and most common one, e.g.: |
20 |
|
21 |
PYTHON_DEPEND=" |
22 |
python_targets_pythonX_Y? |
23 |
( dev-python/python:X.Y[ncurses,sqlite] ) |
24 |
" |
25 |
|
26 |
3. By default, just append PYTHON_DEPEND to DEPEND and RDEPEND. Provide |
27 |
an option to disable that. If user wants optional Python, he can |
28 |
disable it and use ${PYTHON_DEPEND} in his own *DEPEND code. (we could |
29 |
also provide a quick switch to add 'python? ( )' or '$USEFLAG? ( )'). |
30 |
|
31 |
4. Finally, provide a general, parametrized dependency generator |
32 |
function which will be useful in all the remaining non-common cases |
33 |
which can't be handled sanely by any other solution. |
34 |
|
35 |
For example, the following ::progress string: |
36 |
|
37 |
PYTHON_DEPEND="<<[xml]>> database? ( <<[gdbm]>> ) gui? ( <<[tk]>> )" |
38 |
|
39 |
could be obtained using: |
40 |
|
41 |
PYTHON_COMPAT=... |
42 |
PYTHON_USE=xml |
43 |
inherit python-distutils-ng |
44 |
RDEPEND=" |
45 |
${PYTHON_DEPEND} |
46 |
database? ( |
47 |
$(python-gen-depend gdbm ${PYTHON_COMPAT}) |
48 |
) |
49 |
gui? ( |
50 |
$(python-gen-depend tk ${PYTHON_COMPAT}) |
51 |
) |
52 |
" |
53 |
|
54 |
or even hackier (but faster): |
55 |
|
56 |
RDEPEND=" |
57 |
${PYTHON_DEPEND} |
58 |
database? ( |
59 |
${PYTHON_DEPEND//\[xml\]/[gdbm]} |
60 |
) |
61 |
gui? ( |
62 |
${PYTHON_DEPEND//\[xml\]/[tk]} |
63 |
) |
64 |
" |
65 |
|
66 |
-- |
67 |
Best regards, |
68 |
Michał Górny |