1 |
commit: 7c2f42d899fd102798dcf4e30343aba20fd3bb3d |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Dec 22 22:18:16 2015 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Dec 31 14:52:03 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7c2f42d8 |
7 |
|
8 |
python-single-r1.eclass: Add python_gen_impl_dep, alike in python-r1 |
9 |
|
10 |
eclass/python-single-r1.eclass | 58 ++++++++++++++++++++++++++++++++++++++++++ |
11 |
1 file changed, 58 insertions(+) |
12 |
|
13 |
diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass |
14 |
index 4d5026f..9e80866 100644 |
15 |
--- a/eclass/python-single-r1.eclass |
16 |
+++ b/eclass/python-single-r1.eclass |
17 |
@@ -411,6 +411,64 @@ python_gen_cond_dep() { |
18 |
echo "${matches[@]}" |
19 |
} |
20 |
|
21 |
+# @FUNCTION: python_gen_impl_dep |
22 |
+# @USAGE: [<requested-use-flags> [<impl-pattern>...]] |
23 |
+# @DESCRIPTION: |
24 |
+# Output a dependency on Python implementations with the specified USE |
25 |
+# dependency string appended, or no USE dependency string if called |
26 |
+# without the argument (or with empty argument). If any implementation |
27 |
+# patterns are passed, the output dependencies will be generated only |
28 |
+# for the implementations matching them. |
29 |
+# |
30 |
+# Use this function when you need to request different USE flags |
31 |
+# on the Python interpreter depending on package's USE flags. If you |
32 |
+# only need a single set of interpreter USE flags, just set |
33 |
+# PYTHON_REQ_USE and use ${PYTHON_DEPS} globally. |
34 |
+# |
35 |
+# Example: |
36 |
+# @CODE |
37 |
+# PYTHON_COMPAT=( python{2_7,3_{3,4}} pypy ) |
38 |
+# RDEPEND="foo? ( $(python_gen_impl_dep 'xml(+)') )" |
39 |
+# @CODE |
40 |
+# |
41 |
+# It will cause the variable to look like: |
42 |
+# @CODE |
43 |
+# RDEPEND="foo? ( |
44 |
+# python_single_target_python2_7? ( |
45 |
+# dev-lang/python:2.7[xml(+)] ) |
46 |
+# python_single_target_pypy? ( |
47 |
+# dev-python/pypy[xml(+)] ) )" |
48 |
+# @CODE |
49 |
+python_gen_impl_dep() { |
50 |
+ debug-print-function ${FUNCNAME} "${@}" |
51 |
+ |
52 |
+ local impl pattern |
53 |
+ local matches=() |
54 |
+ |
55 |
+ if [[ ${#_PYTHON_SUPPORTED_IMPLS[@]} -eq 1 ]]; then |
56 |
+ flag_prefix=python_targets |
57 |
+ else |
58 |
+ flag_prefix=python_single_target |
59 |
+ fi |
60 |
+ |
61 |
+ local PYTHON_REQ_USE=${1} |
62 |
+ shift |
63 |
+ |
64 |
+ local patterns=( "${@-*}" ) |
65 |
+ for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do |
66 |
+ for pattern in "${patterns[@]}"; do |
67 |
+ if [[ ${impl} == ${pattern} ]]; then |
68 |
+ local PYTHON_PKG_DEP |
69 |
+ python_export "${impl}" PYTHON_PKG_DEP |
70 |
+ matches+=( "${flag_prefix}_${impl}? ( ${PYTHON_PKG_DEP} )" ) |
71 |
+ break |
72 |
+ fi |
73 |
+ done |
74 |
+ done |
75 |
+ |
76 |
+ echo "${matches[@]}" |
77 |
+} |
78 |
+ |
79 |
# @FUNCTION: python_setup |
80 |
# @DESCRIPTION: |
81 |
# Determine what the selected Python implementation is and set |