1 |
A semi-replacement for _python-distutils-ng_very_long_name... |
2 |
|
3 |
Unlike the forementioned function, it returns just the binary name |
4 |
and not the complete path. Thus, the executable rewrite in p-d-ng has |
5 |
been changed to use #!/usr/bin/env. |
6 |
--- |
7 |
gx86/eclass/python-distutils-ng.eclass | 28 ++++------------------------ |
8 |
gx86/eclass/python-r1.eclass | 20 ++++++++++++++++++++ |
9 |
2 files changed, 24 insertions(+), 24 deletions(-) |
10 |
|
11 |
diff --git a/gx86/eclass/python-distutils-ng.eclass b/gx86/eclass/python-distutils-ng.eclass |
12 |
index 34717aa..33d183c 100644 |
13 |
--- a/gx86/eclass/python-distutils-ng.eclass |
14 |
+++ b/gx86/eclass/python-distutils-ng.eclass |
15 |
@@ -54,26 +54,6 @@ EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install |
16 |
|
17 |
DEPEND="${DEPEND} !<sys-apps/portage-2.1.10.58" |
18 |
|
19 |
-# @FUNCTION: _python-distutils-ng_get_binary_for_implementation |
20 |
-# @USAGE: implementation |
21 |
-# @RETURN: Full path to Python binary for given implementation. |
22 |
-# @DESCRIPTION: |
23 |
-# This function returns full path for Python binary for given implementation. |
24 |
-# |
25 |
-# Binary returned by this function should be used instead of simply calling |
26 |
-# `python'. |
27 |
-_python-distutils-ng_get_binary_for_implementation() { |
28 |
- local impl="${1/_/.}" |
29 |
- case "${impl}" in |
30 |
- python?.?|jython?.?) |
31 |
- echo "/usr/bin/${impl}" ;; |
32 |
- pypy?.?) |
33 |
- echo "/usr/bin/pypy-c${impl: -3}" ;; |
34 |
- *) |
35 |
- die "Unsupported implementation: ${1}" ;; |
36 |
- esac |
37 |
-} |
38 |
- |
39 |
RDEPEND=${PYTHON_DEPS} |
40 |
DEPEND=${PYTHON_DEPS} |
41 |
|
42 |
@@ -90,7 +70,7 @@ _python-distutils-ng_run_for_impl() { |
43 |
local command="${2}" |
44 |
|
45 |
local S="${WORKDIR}/impl_${impl}/${_PACKAGE_SPECIFIC_S}" |
46 |
- PYTHON="$(_python-distutils-ng_get_binary_for_implementation "${impl}")" |
47 |
+ PYTHON="$(python_get_PYTHON "${impl}")" |
48 |
EPYTHON="${impl/_/.}" |
49 |
|
50 |
einfo "Running ${command} in ${S} for ${impl}" |
51 |
@@ -147,10 +127,10 @@ python-distutils-ng_rewrite_hashbang() { |
52 |
[[ -n "${1}" ]] || die "Missing file name" |
53 |
[[ -n "${2}" ]] || die "Missing implementation" |
54 |
local file_name="${1}" |
55 |
- local binary="$(_python-distutils-ng_get_binary_for_implementation "${2}")" |
56 |
+ local binary="$(python_get_PYTHON "${2}")" |
57 |
[[ $(head -n 1 "${file_name}") == '#!'*(python|jython|pypy-c)* ]] || \ |
58 |
die "Missing or invalid #! line in ${file_name}" |
59 |
- sed -i -e "1c#!${binary}" "${file_name}" || die |
60 |
+ sed -i -e "1c#!/usr/bin/env ${binary}" "${file_name}" || die |
61 |
} |
62 |
|
63 |
# @FUNCTION: python-distutils-ng_redoscript |
64 |
@@ -253,7 +233,7 @@ python-distutils-ng_src_prepare() { |
65 |
# Try to run binary for each implementation: |
66 |
for impl in ${PYTHON_COMPAT[@]}; do |
67 |
use "python_targets_${impl}" ${PYTHON_COMPAT[@]} || continue |
68 |
- $(_python-distutils-ng_get_binary_for_implementation "${impl}") \ |
69 |
+ $(python_get_PYTHON "${impl}") \ |
70 |
-c "import sys" || die |
71 |
done |
72 |
|
73 |
diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass |
74 |
index 68b5c38..4c4d69d 100644 |
75 |
--- a/gx86/eclass/python-r1.eclass |
76 |
+++ b/gx86/eclass/python-r1.eclass |
77 |
@@ -118,3 +118,23 @@ _python_set_globals() { |
78 |
done |
79 |
} |
80 |
_python_set_globals |
81 |
+ |
82 |
+# @FUNCTION: python_get_PYTHON |
83 |
+# @USAGE: <impl> |
84 |
+# @DESCRIPTION: |
85 |
+# Get the Python executable name for the given implementation. |
86 |
+python_get_PYTHON() { |
87 |
+ local impl=${1/_/.} |
88 |
+ |
89 |
+ case "${impl}" in |
90 |
+ python*|jython*) |
91 |
+ echo ${impl} |
92 |
+ ;; |
93 |
+ pypy*) |
94 |
+ echo pypy-c${impl#pypy} |
95 |
+ ;; |
96 |
+ *) |
97 |
+ die "Invalid argument to python_get_PYTHON: ${1}" |
98 |
+ ;; |
99 |
+ esac |
100 |
+} |
101 |
-- |
102 |
1.7.12 |