diff options
author | Arfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org> | 2009-08-04 20:06:29 +0000 |
---|---|---|
committer | Arfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org> | 2009-08-04 20:06:29 +0000 |
commit | 734c632139dc1e1665857e94d0d45830294875f2 (patch) | |
tree | 856697160bd42570fab6d88ee90e0e26230a09d4 | |
parent | Add python.c. (diff) | |
download | eselect-python-734c632139dc1e1665857e94d0d45830294875f2.tar.gz eselect-python-734c632139dc1e1665857e94d0d45830294875f2.tar.bz2 eselect-python-734c632139dc1e1665857e94d0d45830294875f2.zip |
Store Python version in /etc/env.d/python/config.
Patch by: Jonathan Callen
-rw-r--r-- | python.eselect | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/python.eselect b/python.eselect index 413b41f..766d816 100644 --- a/python.eselect +++ b/python.eselect @@ -24,20 +24,13 @@ find_targets() { done } -set_python_script() { - local script="${INTERPRETER_PATH}${1}" target="${2}" - cat << EOF > "${script}" -#!/bin/bash -# Gentoo Python wrapper script - -[[ "\${EPYTHON}" =~ (/|^python\$) ]] && EPYTHON="${target}" -"\${0%/*}/\${EPYTHON:-${target}}" "\$@" -EOF - chmod +x "${script}" +set_python() { + local program="${INTERPRETER_PATH}python" target="${1}" + echo "${target}" > "${ENV_D_PATH}/python/config" } -set_python_config_script() { - local script="${INTERPRETER_PATH}${1}" target="${2}" +set_python_config() { + local script="${INTERPRETER_PATH}python-config" target="${1}" cat << EOF > "${script}" #!/bin/bash # Gentoo python-config wrapper script @@ -52,7 +45,7 @@ EOF # Try to remove python and python.1 symlinks remove_symlinks() { local symlink symlink_target symlink_target_found - rm -f "${INTERPRETER_PATH}"{idle,pydoc,python,python-config} &>/dev/null && \ + rm -f "${INTERPRETER_PATH}"{idle,pydoc,python-config} &>/dev/null && \ rm -f "${MAN_PATH}"python.1{,.gz,.bz2,.lzma,.xz} &>/dev/null for symlink in "${INTERPRETER_PATH}python"?; do [[ ! -L "${symlink}" ]] && continue @@ -87,7 +80,7 @@ set_man_symlink() { popd 1>/dev/null } -# Set python script and appropriate symlinks +# Set python-config script and appropriate symlinks set_scripts_and_symlinks() { local target="${1}" targets=($(find_targets )) if is_number "${target}" && [[ ${target} -ge 1 ]]; then @@ -100,11 +93,11 @@ set_scripts_and_symlinks() { if [[ -f "${INTERPRETER_PATH}${target}" ]]; then remove_symlinks set_man_symlink "${target}" - + pushd "${INTERPRETER_PATH}" 1>/dev/null - set_python_script "python" "${target}" + set_python "${target}" ln -nfs "${target}" "${target%.*}" - set_python_config_script "python-config" "${target/python/python-config-}" + set_python_config "${target/python/python-config-}" ln -nfs "${target/python/pydoc}" pydoc ln -nfs "${target/python/idle}" idle # 2to3 for >=2.6 @@ -138,8 +131,9 @@ describe_show() { } do_show() { - active=$(canonicalise "${INTERPRETER_PATH}python") - echo ${active#${INTERPRETER_PATH}} + if [[ -f "${ENV_D_PATH}/python/config" ]]; then + cat "${ENV_D_PATH}/python/config" + fi } ### list action ### @@ -215,12 +209,12 @@ do_update() { shift done - if [[ -L "${ROOT%/}/usr/bin/python" ]]; then + if [[ -f "${ENV_D_PATH}/python/config" ]]; then ${if_unset} && return fi local targets=( $(cd "${INTERPRETER_PATH}"; ls python?.?|sort -r) ) target - + # Ignore slots for slot in ${ignored_slots[@]}; do targets=( ${targets[@]/python${slot}/} ) |