1 |
Use /etc/env.d/python/python[23] file to store the active Python2/3 |
2 |
interpreter rather than /usr/bin/python[23] symlink target. This is |
3 |
simpler, more portable and allows us to replace symlinks with real |
4 |
wrappers. |
5 |
--- |
6 |
python.eselect.in | 12 ++++++++++-- |
7 |
1 file changed, 10 insertions(+), 2 deletions(-) |
8 |
|
9 |
diff --git a/python.eselect.in b/python.eselect.in |
10 |
index 8baa44e..32d9cbf 100644 |
11 |
--- a/python.eselect.in |
12 |
+++ b/python.eselect.in |
13 |
@@ -33,6 +33,13 @@ find_targets() { |
14 |
done |
15 |
} |
16 |
|
17 |
+set_python_subver() { |
18 |
+ local target=${1} |
19 |
+ local subver=${target%.*} |
20 |
+ mkdir -p "${ENV_D_PATH}/python" |
21 |
+ echo "${target}" > "${ENV_D_PATH}/python/${subver}" |
22 |
+} |
23 |
+ |
24 |
set_python() { |
25 |
local symlink="${INTERPRETER_PATH}python" target="${1}" |
26 |
ln -s python-wrapper "${symlink}" |
27 |
@@ -119,6 +126,7 @@ set_scripts_and_symlinks() { |
28 |
pushd "${INTERPRETER_PATH}" 1> /dev/null |
29 |
|
30 |
ln -nfs "${target}" "${target%.*}" |
31 |
+ set_python_subver "${target}" |
32 |
if [[ "${SET_MAIN_ACTIVE_PYTHON_INTERPRETER}" == "1" ]]; then |
33 |
set_python "${target}" |
34 |
set_python_config "${target/python/python-config-}" |
35 |
@@ -205,9 +213,9 @@ do_show() { |
36 |
fi |
37 |
|
38 |
if [[ "${python2}" == "1" ]]; then |
39 |
- interpreter="$(readlink "${INTERPRETER_PATH}python2")" |
40 |
+ interpreter="$(<"${ENV_D_PATH}/python/python2")" |
41 |
elif [[ "${python3}" == "1" ]]; then |
42 |
- interpreter="$(readlink "${INTERPRETER_PATH}python3")" |
43 |
+ interpreter="$(<"${ENV_D_PATH}/python/python3")" |
44 |
elif [[ -f "${ENV_D_PATH}/python/config" ]]; then |
45 |
interpreter="$(<"${ENV_D_PATH}/python/config")" |
46 |
fi |
47 |
-- |
48 |
2.6.3 |