[gentoo-commits] proj/eselect-python:pyexec-2.3 commit in: /
commit: 027a224cab2883b8f240b59ec060c39929623100 Author: Michał Górny gentoo org> AuthorDate: Fri Feb 5 20:02:06 2016 + Commit: Michał Górny gentoo org> CommitDate: Fri Feb 5 20:02:06 2016 + URL: https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=027a224c Add edit action python.eselect.in | 12 1 file changed, 12 insertions(+) diff --git a/python.eselect.in b/python.eselect.in index c222460..94d751c 100644 --- a/python.eselect.in +++ b/python.eselect.in @@ -167,6 +167,18 @@ post_update() { set_python_docs "${main_interp}" } +### edit action ### + +describe_edit() { + echo "Edit the interpreter preference list" +} + +do_edit() { + [[ ${EDITOR} ]] || die "EDITOR is not set" + + ${EDITOR} "${CONFIG_PATH}" +} + ### show action ### describe_show() {
[gentoo-commits] proj/eselect-python:pyexec-2.3 commit in: /
commit: ac197657161e95587b22893612e0cf1118376808 Author: Michał Górny gentoo org> AuthorDate: Tue Feb 2 22:02:31 2016 + Commit: Michał Górny gentoo org> CommitDate: Fri Feb 5 19:54:11 2016 + URL: https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=ac197657 Rewrite to use python-exec.conf, and cleanup Use the new preference list configuration format added in python-exec-2.3. While at it, clean up error handling and make the code a bit simpler. Replace the notion of 'main interpreter' with the most preferred installed interpreter. python.eselect.in | 458 -- 1 file changed, 235 insertions(+), 223 deletions(-) diff --git a/python.eselect.in b/python.eselect.in index 3d9b4bc..ee79262 100644 --- a/python.eselect.in +++ b/python.eselect.in @@ -1,163 +1,196 @@ -# Copyright 1999-2014 Gentoo Foundation +# Copyright 1999-2016 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id: $ -DESCRIPTION="Manage active Python interpreter" +DESCRIPTION="Manage Python interpreter preferences" MAINTAINER="pyt...@gentoo.org" -SVN_DATE='$Date$' -VERSION=$(svn_date_to_version "${SVN_DATE}" ) +VERSION=@VERSION@ +CONFIG_PATH="${EROOT%/}/etc/python-exec/python-exec.conf" ENV_D_PATH="${EROOT%/}/etc/env.d" -INTERPRETER_PATH="${EROOT%/}/usr/bin/" -MAN_PATH="${EROOT%/}/usr/share/man/man1/" - -PYTHON_INTERPRETERS_GROUP="" - -# Find a list of Python versions -find_targets() { - local interpreter interpreters="python?.?@EXEEXT@" +INTERPRETER_DIR="${EROOT%/}/usr/bin" +MAN_PATH="${EROOT%/}/usr/share/man/man1" + +# Get list of all installed Python interpreters, in lexical order. +# $1 can be --pyN to filter results to pythonN.?. +get_installed_pythons() { + local exes=( "${INTERPRETER_DIR}"/python?.?@EXEEXT@ ) + local i + for (( i = ${#exes[@]}-1; i >= 0; --i )); do + local exe=${exes[i]} + [[ -x ${exe} ]] || continue + exe=${exe##*/} + exe=${exe%@EXEEXT@} + # apply filters + [[ ${1} == --py? && ${exe} != python${1:4}* ]] && continue + + echo "${exe}" + done +} - if [[ "${PYTHON_INTERPRETERS_GROUP}" == "2" ]]; then - interpreters="python2.?@EXEEXT@" - elif [[ "${PYTHON_INTERPRETERS_GROUP}" == "3" ]]; then - interpreters="python3.?@EXEEXT@" - fi +# Get list of all preference values from python-exec.conf. This +# includes both preferred implementations (in preference order) +# and disabled interpreters. +get_all_preferences() { + local l + while read l; do + # skip comments + [[ ${l} == '#'* ]] && continue + + # note: empty lines are stripped through word splitting + echo "${l}" + done <"${CONFIG_PATH}" +} - # Think twice before adding jython to this list. /usr/bin/jython - # is a bash wrapper that calls java-config, which is a Python - # script, so you need a valid /usr/bin/python to start jython. - for interpreter in "${INTERPRETER_PATH}"${interpreters}; do - if [[ -f "${interpreter}" ]]; then - echo ${interpreter#${INTERPRETER_PATH}} - fi +# Get list of preferred Python interpreters, from python-exec.conf, +# in preference order. +# $1 can be --pyN to filter results to pythonN.?. +get_preferred_pythons() { + local i + for i in $(get_all_preferences); do + # skip negative entries + [[ ${i} == -* ]] && continue + # apply filters + [[ ${1} == --py? && ${i} != python${1:4}* ]] && continue + + echo "${i}" done } -set_python_subver() { - local target=${1} - local subver=${target%.*} - mkdir -p "${ENV_D_PATH}/python" - echo "${target}" > "${ENV_D_PATH}/python/${subver}" +# Get list of explicitly disabled Python interpreters, from +# python-exec.conf, in file order. +get_disabled_pythons() { + local i + for i in $(get_all_preferences); do + # process only negative entries + [[ ${i} == -* ]] || continue + + echo "${i#-}" + done } -set_python() { - local target="${1}" - mkdir -p "${ENV_D_PATH}/python" - echo "${target}" > "${ENV_D_PATH}/python/config" +# Get combined list of preferred, installed and disabled Python +# interpreters, in preference order. +# $1 can be --pyN to filter results to pythonN.?. +get_all_pythons() { + local targets=( $(get_installed_pythons "${@}") ) + local preferred=( $(get_preferred_pythons "${@}") ) + local disabled=( $(get_disabled_pythons "${@}") ) + local i + + # preferred first + for i in "${preferred[@]}"; do + echo "${i}" + done + # active then + for i in "${targets[@]}"; do + has
[gentoo-commits] proj/eselect-python:pyexec-2.3 commit in: /
commit: 488a692b45d1279f0c8955965d809621bf4388b5 Author: Michał Górny gentoo org> AuthorDate: Thu Feb 4 22:02:39 2016 + Commit: Michał Górny gentoo org> CommitDate: Fri Feb 5 19:54:11 2016 + URL: https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=488a692b Set open enough umask before writing updates python.eselect.in | 1 + 1 file changed, 1 insertion(+) diff --git a/python.eselect.in b/python.eselect.in index ee79262..c222460 100644 --- a/python.eselect.in +++ b/python.eselect.in @@ -327,6 +327,7 @@ do_set() { # need to do this outta loop in case no pref matches prefs=( "${prefs[@]:0:target_idx}" "${target}" "${prefs[@]:target_idx}" ) + umask 022 write_preferences "${prefs[@]}" post_update }
[gentoo-commits] proj/eselect-python:pyexec-2.3 commit in: /
commit: ce0d0242419fd7369d7febf2544d65f0e701c7ad Author: Michał Górny gentoo org> AuthorDate: Tue Feb 2 22:02:31 2016 + Commit: Michał Górny gentoo org> CommitDate: Fri Feb 5 20:36:30 2016 + URL: https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=ce0d0242 Rewrite to use python-exec.conf, and cleanup Use the new preference list configuration format added in python-exec-2.3. While at it, clean up error handling and make the code a bit simpler. Replace the notion of 'main interpreter' with the most preferred installed interpreter. python.eselect.in | 465 -- 1 file changed, 243 insertions(+), 222 deletions(-) diff --git a/python.eselect.in b/python.eselect.in index 3d9b4bc..aa4eaa7 100644 --- a/python.eselect.in +++ b/python.eselect.in @@ -1,163 +1,200 @@ -# Copyright 1999-2014 Gentoo Foundation +# Copyright 1999-2016 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id: $ -DESCRIPTION="Manage active Python interpreter" +DESCRIPTION="Manage Python interpreter preferences" MAINTAINER="pyt...@gentoo.org" -SVN_DATE='$Date$' -VERSION=$(svn_date_to_version "${SVN_DATE}" ) +VERSION=@VERSION@ +CONFIG_PATH="${EROOT%/}/etc/python-exec/python-exec.conf" ENV_D_PATH="${EROOT%/}/etc/env.d" -INTERPRETER_PATH="${EROOT%/}/usr/bin/" -MAN_PATH="${EROOT%/}/usr/share/man/man1/" - -PYTHON_INTERPRETERS_GROUP="" - -# Find a list of Python versions -find_targets() { - local interpreter interpreters="python?.?@EXEEXT@" +INTERPRETER_DIR="${EROOT%/}/usr/bin" +MAN_PATH="${EROOT%/}/usr/share/man/man1" + +# Get list of all installed Python interpreters, in lexical order. +# $1 can be --pyN to filter results to pythonN.?. +get_installed_pythons() { + local exes=( "${INTERPRETER_DIR}"/python?.?@EXEEXT@ ) + local i + for (( i = ${#exes[@]}-1; i >= 0; --i )); do + local exe=${exes[i]} + [[ -x ${exe} ]] || continue + exe=${exe##*/} + exe=${exe%@EXEEXT@} + # apply filters + [[ ${1} == --py? && ${exe} != python${1:4}* ]] && continue + + echo "${exe}" + done +} - if [[ "${PYTHON_INTERPRETERS_GROUP}" == "2" ]]; then - interpreters="python2.?@EXEEXT@" - elif [[ "${PYTHON_INTERPRETERS_GROUP}" == "3" ]]; then - interpreters="python3.?@EXEEXT@" - fi +# Get list of all preference values from python-exec.conf. This +# includes both preferred implementations (in preference order) +# and disabled interpreters. +get_all_preferences() { + local l + while read l; do + # skip comments + [[ ${l} == '#'* ]] && continue + + # note: empty lines are stripped through word splitting + echo "${l}" + done <"${CONFIG_PATH}" +} - # Think twice before adding jython to this list. /usr/bin/jython - # is a bash wrapper that calls java-config, which is a Python - # script, so you need a valid /usr/bin/python to start jython. - for interpreter in "${INTERPRETER_PATH}"${interpreters}; do - if [[ -f "${interpreter}" ]]; then - echo ${interpreter#${INTERPRETER_PATH}} - fi +# Get list of preferred Python interpreters, from python-exec.conf, +# in preference order. +# $1 can be --pyN to filter results to pythonN.?. +get_preferred_pythons() { + local i + for i in $(get_all_preferences); do + # skip negative entries + [[ ${i} == -* ]] && continue + # apply filters + [[ ${1} == --py? && ${i} != python${1:4}* ]] && continue + + echo "${i}" done } -set_python_subver() { - local target=${1} - local subver=${target%.*} - mkdir -p "${ENV_D_PATH}/python" - echo "${target}" > "${ENV_D_PATH}/python/${subver}" +# Get list of explicitly disabled Python interpreters, from +# python-exec.conf, in file order. +get_disabled_pythons() { + local i + for i in $(get_all_preferences); do + # process only negative entries + [[ ${i} == -* ]] || continue + + echo "${i#-}" + done } -set_python() { - local target="${1}" - mkdir -p "${ENV_D_PATH}/python" - echo "${target}" > "${ENV_D_PATH}/python/config" +# Get combined list of preferred, installed and disabled Python +# interpreters, in preference order. +# $1 can be --pyN to filter results to pythonN.?. +get_all_pythons() { + local targets=( $(get_installed_pythons "${@}") ) + local preferred=( $(get_preferred_pythons "${@}") ) + local disabled=( $(get_disabled_pythons "${@}") ) + local i + + # preferred first + for i in "${preferred[@]}"; do + echo "${i}" + done + # active then + for i in "${targets[@]}"; do + has
[gentoo-commits] proj/eselect-python:pyexec-2.3 commit in: /
commit: bfce7d731ce9c41c6bc3e5b8acf26f4d2ec53e32 Author: Michał Górny gentoo org> AuthorDate: Fri Feb 5 20:02:06 2016 + Commit: Michał Górny gentoo org> CommitDate: Fri Feb 5 20:36:30 2016 + URL: https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=bfce7d73 Add edit action python.eselect.in | 12 1 file changed, 12 insertions(+) diff --git a/python.eselect.in b/python.eselect.in index d84f1ef..bbe024f 100644 --- a/python.eselect.in +++ b/python.eselect.in @@ -167,6 +167,18 @@ post_update() { set_python_docs "${main_interp}" } +### edit action ### + +describe_edit() { + echo "Edit the interpreter preference list" +} + +do_edit() { + [[ ${EDITOR} ]] || die "EDITOR is not set" + + ${EDITOR} "${CONFIG_PATH}" +} + ### show action ### describe_show() {
[gentoo-commits] proj/eselect-python:pyexec-2.3 commit in: /
commit: 808be74d51901c942fce1ddd0bb69d910b2a5d9c Author: Michał Górny gentoo org> AuthorDate: Thu Feb 4 22:02:39 2016 + Commit: Michał Górny gentoo org> CommitDate: Fri Feb 5 20:36:30 2016 + URL: https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=808be74d Set open enough umask before writing updates python.eselect.in | 1 + 1 file changed, 1 insertion(+) diff --git a/python.eselect.in b/python.eselect.in index aa4eaa7..d84f1ef 100644 --- a/python.eselect.in +++ b/python.eselect.in @@ -336,6 +336,7 @@ do_set() { # need to do this outta loop in case no pref matches prefs=( "${prefs[@]:0:target_idx}" "${target}" "${prefs[@]:target_idx}" ) + umask 022 write_preferences "${prefs[@]}" post_update }
[gentoo-commits] proj/eselect-python:pyexec-2.3 commit in: /
commit: e244f5dc8742446047c0292fe224c422577a8afa Author: Michał Górny gentoo org> AuthorDate: Thu Feb 4 21:52:51 2016 + Commit: Michał Górny gentoo org> CommitDate: Thu Feb 4 21:52:51 2016 + URL: https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=e244f5dc big cleanup python.eselect.in | 96 +++ 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/python.eselect.in b/python.eselect.in index d1e2836..2680d69 100644 --- a/python.eselect.in +++ b/python.eselect.in @@ -9,7 +9,7 @@ VERSION=20160202 CONFIG_PATH="${EROOT%/}/etc/python-exec/python-exec.conf" ENV_D_PATH="${EROOT%/}/etc/env.d" INTERPRETER_DIR="${EROOT%/}/usr/bin" -MAN_PATH="${EROOT%/}/usr/share/man/man1/" +MAN_PATH="${EROOT%/}/usr/share/man/man1" # Get list of all installed Python interpreters, in lexical order. # $1 can be --pyN to filter results to pythonN.?. @@ -74,6 +74,7 @@ get_all_pythons() { local targets=( $(get_installed_pythons "${@}") ) local preferred=( $(get_preferred_pythons "${@}") ) local disabled=( $(get_disabled_pythons "${@}") ) + local i # preferred first for i in "${preferred[@]}"; do @@ -104,25 +105,23 @@ write_preferences() { # Set a man page symlink set_man_symlink() { - local target="${1}" x extension + local target=${1} x suffix - rm -f "${MAN_PATH}"python.1{,.gz,.bz2,.lzma,.xz,.lz} + rm -f "${MAN_PATH}"/python.1{,.gz,.bz2,.lzma,.xz,.lz} || die - for x in ".1" ".1.bz2" ".1.gz" ".1.lzma" ".1.xz" ".1.lz"; do - if [[ -e "${MAN_PATH}${target}${x}" ]]; then - extension="${x}" + for x in .1{,.gz,.bz2,.lzma,.xz,.lz}; do + if [[ -e "${MAN_PATH}/${target}${x}" ]]; then + suffix=${x} break fi done - if [[ -z "${extension}" ]]; then + if [[ ! ${suffix} ]]; then echo "Couldn't find a man page for ${target}; skipping." 1>&2 return 1 fi - pushd "${MAN_PATH}" 1> /dev/null - ln -nfs "${target}${extension}" "python${extension}" - popd 1> /dev/null + ln -nfs "${target}${extension}" "${MAN_PATH}/python${extension}" || die } # Set OSX framework symlinks @@ -130,22 +129,22 @@ set_osx_framework() { local target=${1} # Files of Mac OS X framework - local framework_dir="${INTERPRETER_PATH%/bin/}/lib/Python.framework" - if [[ -d "${framework_dir}" ]]; then - local version="${target#python}" - pushd "${framework_dir}" 1> /dev/null - rm -f Headers Python Resources - ln -nfs "Versions/${version}/Headers" - ln -nfs "Versions/${version}/Python" - ln -nfs "Versions/${version}/Resources" - popd 1> /dev/null + local framework_dir="${INTERPRETER_DIR%/bin}"/lib/Python.framework + if [[ -d ${framework_dir} ]]; then + local version=${target#python} + pushd "${framework_dir}" >/dev/null || die + rm -f Headers Python Resources || die + ln -nfs "Versions/${version}/Headers" || die + ln -nfs "Versions/${version}/Python" || die + ln -nfs "Versions/${version}/Resources" || die + popd >/dev/null || die fi } # Set the content of /etc/env.d/65python-docs set_python_docs() { - local path target="${1#python}" variable - rm -f "${ENV_D_PATH}/65python-docs" + local path target=${1#python} variable + rm -f "${ENV_D_PATH}/65python-docs" || die if [[ -f ${ENV_D_PATH}/60python-docs-${target} ]]; then variable="PYTHONDOCS_${target//./_}" path="$(. "${ENV_D_PATH}/60python-docs-${target}"; echo "${!variable}")" @@ -169,21 +168,21 @@ post_update() { ### show action ### describe_show() { - echo "Show main active Python interpreter" + echo "Show the most preferred Python interpreter" } describe_show_options() { - echo "--ABI : Show Python ABI in format of PYTHON_ABI variable" - echo "--python2 : Show active Python 2 interpreter" - echo "--python3 : Show active Python 3 interpreter" + echo "--ABI : use PYTHON_ABI variable format (deprecated)" + echo "--python2 : show the preferred version of Python 2" + echo "--python3 : show the preferred version of Python 3" } do_show() { - local ABI filter interpreter - while [[ $# > 0 ]]; do - case "$1" in + local abi filter interpreter + while [[ ${#} -gt 0 ]]; do + case ${1} in --ABI) - ABI=1 + abi=1 ;; --python2|--py2)
[gentoo-commits] proj/eselect-python:pyexec-2.3 commit in: /
commit: 59630bedc0360d027b9b7d45a097bd7326e90871 Author: Michał Górny gentoo org> AuthorDate: Thu Feb 4 22:02:39 2016 + Commit: Michał Górny gentoo org> CommitDate: Thu Feb 4 22:02:39 2016 + URL: https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=59630bed Set open enough umask before writing updates python.eselect.in | 1 + 1 file changed, 1 insertion(+) diff --git a/python.eselect.in b/python.eselect.in index 2680d69..2e857bd 100644 --- a/python.eselect.in +++ b/python.eselect.in @@ -322,6 +322,7 @@ do_set() { # need to do this outta loop in case no pref matches prefs=( "${prefs[@]:0:target_idx}" "${target}" "${prefs[@]:target_idx}" ) + umask 022 write_preferences "${prefs[@]}" post_update }