1 |
Hello, |
2 |
|
3 |
Right now, there are two variables which are set per-implementation -- |
4 |
PYTHON & EPYTHON. However, one of our users (sorry for not remembering |
5 |
who) requested an ability to get Python libdir, site-packages directory |
6 |
as well. This raises a question on the interface which should be used |
7 |
to get those values. |
8 |
|
9 |
The common interface in Gentoo is to use 'getter' functions. Since bash |
10 |
doesn't have any real concept of return values, those functions use |
11 |
output capturing -- and that involves subshelling which is pretty bad |
12 |
for commonly used functions. An alternative is to use an 'export' |
13 |
function like tc-export() in toolchain-funcs. |
14 |
|
15 |
I'd like to shortly point out advantages and disadvantages of each |
16 |
solution. |
17 |
|
18 |
|
19 |
1) getter functions |
20 |
- python_get_PYTHON [<impl>] |
21 |
- python_get_EPYTHON <impl> |
22 |
- python_get_sitedir [<impl>] |
23 |
|
24 |
+ clear separation between variables |
25 |
-> especially useful to keep docs clear and short |
26 |
|
27 |
- one subshell (and function call) for each variable, for each |
28 |
implementation |
29 |
-> that makes it 2 * n-impls for each phase function in distutils-r1 |
30 |
|
31 |
|
32 |
2) a single export function |
33 |
- python_export [<impl>] <var>... |
34 |
e.g. python_export python2_7 PYTHON EPYTHON PYTHON_SITEDIR |
35 |
|
36 |
+ no subshelling |
37 |
|
38 |
+ multiple variables can be set in a single function call |
39 |
|
40 |
- potential for variable conflicts |
41 |
-> e.g. when PYTHON_SITEDIR is used differently by the build system, |
42 |
the ebuild would need to 'move' it (unlikely but possible) |
43 |
|
44 |
- mixing of implementation and variables in parameters (optional first |
45 |
parameter) |
46 |
-> technically it's acceptable but looks a bit bad. |
47 |
|
48 |
|
49 |
What are your thoughts? |
50 |
|
51 |
-- |
52 |
Best regards, |
53 |
Michał Górny |