1 |
--- |
2 |
gx86/eclass/python-r1.eclass | 76 ++++++++++++++++++++++++++++++++++++++++++++ |
3 |
1 file changed, 76 insertions(+) |
4 |
|
5 |
diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass |
6 |
index 44103a8..8907247 100644 |
7 |
--- a/gx86/eclass/python-r1.eclass |
8 |
+++ b/gx86/eclass/python-r1.eclass |
9 |
@@ -677,3 +677,79 @@ python_doscript() { |
10 |
_python_ln_rel "${ED}"/usr/bin/python-exec "${D}/${d}/${oldfn}" || die |
11 |
done |
12 |
} |
13 |
+ |
14 |
+# @ECLASS-VARIABLE: python_moduleroot |
15 |
+# @DEFAULT_UNSET |
16 |
+# @DESCRIPTION: |
17 |
+# The current module root for python_domodule(). The path can be either |
18 |
+# an absolute system path (it must start with a slash, and ${D} will be |
19 |
+# prepended to it) or relative to the implementation's site-packages directory |
20 |
+# (then it must start with a non-slash character). |
21 |
+# |
22 |
+# When unset, the modules will be installed in the site-packages root. |
23 |
+# |
24 |
+# Can be set indirectly through the python_moduleinto() function. |
25 |
+# |
26 |
+# Example: |
27 |
+# @CODE |
28 |
+# src_install() { |
29 |
+# local python_moduleroot=bar |
30 |
+# # installs ${PYTHON_SITEDIR}/bar/baz.py |
31 |
+# python_foreach_impl python_domodule baz.py |
32 |
+# } |
33 |
+# @CODE |
34 |
+ |
35 |
+# @FUNCTION: python_moduleinto |
36 |
+# @USAGE: <new-path> |
37 |
+# @DESCRIPTION: |
38 |
+# Set the current module root. The new value will be stored |
39 |
+# in the 'python_moduleroot' environment variable. The new value need |
40 |
+# be relative to the site-packages root. |
41 |
+# |
42 |
+# Alternatively, you can set the variable directly. |
43 |
+python_moduleinto() { |
44 |
+ debug-print-function ${FUNCNAME} "${@}" |
45 |
+ |
46 |
+ python_moduleroot=${1} |
47 |
+} |
48 |
+ |
49 |
+# @FUNCTION: python_domodule |
50 |
+# @USAGE: <files>... |
51 |
+# @DESCRIPTION: |
52 |
+# Install the given modules (or packages) into the current |
53 |
+# python_moduleroot. The list can mention both modules (files) |
54 |
+# and packages (directories). All listed files will be installed |
55 |
+# for all enabled implementations, and compiled afterwards. |
56 |
+python_domodule() { |
57 |
+ debug-print-function ${FUNCNAME} "${@}" |
58 |
+ |
59 |
+ [[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).' |
60 |
+ |
61 |
+ local d |
62 |
+ if [[ ${python_moduleroot} == /* ]]; then |
63 |
+ # absolute path |
64 |
+ d=${python_moduleroot} |
65 |
+ else |
66 |
+ # relative to site-packages |
67 |
+ local PYTHON_SITEDIR=${PYTHON_SITEDIR} |
68 |
+ [[ ${PYTHON_SITEDIR} ]] || python_export PYTHON_SITEDIR |
69 |
+ |
70 |
+ d=${PYTHON_SITEDIR}/${python_moduleroot} |
71 |
+ fi |
72 |
+ |
73 |
+ local INSDESTTREE |
74 |
+ |
75 |
+ insinto "${d}" |
76 |
+ doins -r "${@}" |
77 |
+ |
78 |
+ # erm, python2.6 can't handle passing files to compileall... |
79 |
+ case "${EPYTHON}" in |
80 |
+ python*) |
81 |
+ "${PYTHON}" -m compileall -q "${D}/${d}" |
82 |
+ "${PYTHON}" -OO -m compileall -q -f "${D}/${d}" |
83 |
+ ;; |
84 |
+ *) |
85 |
+ "${PYTHON}" -m compileall -q "${D}/${d}" |
86 |
+ ;; |
87 |
+ esac |
88 |
+} |
89 |
-- |
90 |
1.8.0 |