summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2015-11-12 17:40:08 +0100
committerMichał Górny <mgorny@gentoo.org>2015-11-12 17:53:37 +0100
commita3421a53b669fd15c6449203700163712532e4f2 (patch)
tree050e5a9e75d880a20a71ca9d8d0d0ed24efb2f17
parentmanpage: Support .lz compression (diff)
downloadeselect-python-a3421a53b669fd15c6449203700163712532e4f2.tar.gz
eselect-python-a3421a53b669fd15c6449203700163712532e4f2.tar.bz2
eselect-python-a3421a53b669fd15c6449203700163712532e4f2.zip
Store selected python[23] version in a file
Use /etc/env.d/python/python[23] file to store the active Python2/3 interpreter rather than /usr/bin/python[23] symlink target. This is simpler, more portable and allows us to replace symlinks with real wrappers.
-rw-r--r--python.eselect.in12
1 files changed, 10 insertions, 2 deletions
diff --git a/python.eselect.in b/python.eselect.in
index 8baa44e..32d9cbf 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -33,6 +33,13 @@ find_targets() {
done
}
+set_python_subver() {
+ local target=${1}
+ local subver=${target%.*}
+ mkdir -p "${ENV_D_PATH}/python"
+ echo "${target}" > "${ENV_D_PATH}/python/${subver}"
+}
+
set_python() {
local symlink="${INTERPRETER_PATH}python" target="${1}"
ln -s python-wrapper "${symlink}"
@@ -119,6 +126,7 @@ set_scripts_and_symlinks() {
pushd "${INTERPRETER_PATH}" 1> /dev/null
ln -nfs "${target}" "${target%.*}"
+ set_python_subver "${target}"
if [[ "${SET_MAIN_ACTIVE_PYTHON_INTERPRETER}" == "1" ]]; then
set_python "${target}"
set_python_config "${target/python/python-config-}"
@@ -205,9 +213,9 @@ do_show() {
fi
if [[ "${python2}" == "1" ]]; then
- interpreter="$(readlink "${INTERPRETER_PATH}python2")"
+ interpreter="$(<"${ENV_D_PATH}/python/python2")"
elif [[ "${python3}" == "1" ]]; then
- interpreter="$(readlink "${INTERPRETER_PATH}python3")"
+ interpreter="$(<"${ENV_D_PATH}/python/python3")"
elif [[ -f "${ENV_D_PATH}/python/config" ]]; then
interpreter="$(<"${ENV_D_PATH}/python/config")"
fi