public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2013-12-09 18:52 Mike Gilbert
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Gilbert @ 2013-12-09 18:52 UTC (permalink / raw
  To: gentoo-commits

commit:     48eb1a6c8bf14da51cdff94f6b04dac57ab13d22
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Mon Dec  9 18:51:55 2013 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Mon Dec  9 18:51:55 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/eselect-python.git;a=commit;h=48eb1a6c

Create /etc/env.d/python in set_python(), bug 380569.

---
 python.eselect | 1 +
 1 file changed, 1 insertion(+)

diff --git a/python.eselect b/python.eselect
index f72e5cc..9c58391 100644
--- a/python.eselect
+++ b/python.eselect
@@ -36,6 +36,7 @@ find_targets() {
 set_python() {
 	local symlink="${INTERPRETER_PATH}python" target="${1}"
 	ln -s python-wrapper "${symlink}"
+	mkdir -p "${ENV_D_PATH}/python"
 	echo "${target}" > "${ENV_D_PATH}/python/config"
 }
 


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2014-01-19  1:57 Mike Gilbert
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Gilbert @ 2014-01-19  1:57 UTC (permalink / raw
  To: gentoo-commits

commit:     2c3be0bbbfa5f443c2afe7c4dfc1d703987cda5d
Author:     mchiang <phidias.chiang <AT> gmail <DOT> com>
AuthorDate: Thu Jan 16 03:26:14 2014 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 01:50:59 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/eselect-python.git;a=commit;h=2c3be0bb

Support Windows binaries via @EXEEXT@, bug 337601

---
 Makefile.am                         |  2 +-
 configure.ac                        |  4 ++--
 python.eselect => python.eselect.in | 14 +++++++-------
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index e92a315..69fd8d8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
 bin_PROGRAMS = python-wrapper
 
 eselectdir = $(datadir)/eselect/modules
-dist_eselect_DATA = python.eselect
+nodist_eselect_DATA = python.eselect

diff --git a/configure.ac b/configure.ac
index c49e7d5..c85be38 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([eselect-python], [20131210])
+AC_INIT([eselect-python], [20140115])
 AM_INIT_AUTOMAKE([-Wall foreign no-dist-gzip dist-bzip2])
 
 AC_PROG_CC
@@ -31,6 +31,6 @@ CFLAGS="${old_CFLAGS}"
 
 # Create output files.
 AC_CONFIG_HEADERS([config.h])
-AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([Makefile python.eselect])
 
 AC_OUTPUT

diff --git a/python.eselect b/python.eselect.in
similarity index 96%
rename from python.eselect
rename to python.eselect.in
index 9c58391..9a52791 100644
--- a/python.eselect
+++ b/python.eselect.in
@@ -1,4 +1,4 @@
-# Copyright 1999-2010 Gentoo Foundation
+# Copyright 1999-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id: $
 
@@ -15,12 +15,12 @@ PYTHON_INTERPRETERS_GROUP=""
 
 # Find a list of Python versions
 find_targets() {
-	local interpreter interpreters="python?.?"
+	local interpreter interpreters="python?.?@EXEEXT@"
 
 	if [[ "${PYTHON_INTERPRETERS_GROUP}" == "2" ]]; then
-		interpreters="python2.?"
+		interpreters="python2.?@EXEEXT@"
 	elif [[ "${PYTHON_INTERPRETERS_GROUP}" == "3" ]]; then
-		interpreters="python3.?"
+		interpreters="python3.?@EXEEXT@"
 	fi
 
 	# Think twice before adding jython to this list. /usr/bin/jython
@@ -349,7 +349,7 @@ describe_update_options() {
 }
 
 do_update() {
-	local if_unset="0" ignored_slots=() interpreters="python?.?" python2="0" python3="0" python_version_option= slot= target targets=()
+	local if_unset="0" ignored_slots=() interpreters="python?.?@EXEEXT@" python2="0" python3="0" python_version_option= slot= target targets=()
 	while [[ $# > 0 ]]; do
 		case "$1" in
 			--if-unset)
@@ -388,9 +388,9 @@ do_update() {
 	fi
 
 	if [[ "${python2}" == "1" ]]; then
-		interpreters="python2.?"
+		interpreters="python2.?@EXEEXT@"
 	elif [[ "${python3}" == "1" ]]; then
-		interpreters="python3.?"
+		interpreters="python3.?@EXEEXT@"
 	fi
 
 	targets=($(cd "${INTERPRETER_PATH}"; ls ${interpreters} 2> /dev/null | sort -r))


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2014-01-19  1:57 Mike Gilbert
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Gilbert @ 2014-01-19  1:57 UTC (permalink / raw
  To: gentoo-commits

commit:     2d05734a0cbd2729af8366d6555be9e68b4a7c3d
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 10 16:42:09 2013 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Tue Dec 10 16:42:09 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/eselect-python.git;a=commit;h=2d05734a

Update version

---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 6ee6606..c49e7d5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([eselect-python], [20111108])
+AC_INIT([eselect-python], [20131210])
 AM_INIT_AUTOMAKE([-Wall foreign no-dist-gzip dist-bzip2])
 
 AC_PROG_CC


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2014-01-19  8:33 Mike Gilbert
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Gilbert @ 2014-01-19  8:33 UTC (permalink / raw
  To: gentoo-commits

commit:     4c49cdcea51b8369e7b1a54ded2ab290b241a317
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 08:32:49 2014 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 08:32:49 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/eselect-python.git;a=commit;h=4c49cdce

Respect EPREFIX in python-wrapper when reading config, bug 498356 by jlec.

---
 Makefile.am      | 1 +
 python-wrapper.c | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index 69fd8d8..06f7d1c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,5 @@
 bin_PROGRAMS = python-wrapper
+python_wrapper_CPPFLAGS = -DENVD='"$(sysconfdir)/env.d"'
 
 eselectdir = $(datadir)/eselect/modules
 nodist_eselect_DATA = python.eselect

diff --git a/python-wrapper.c b/python-wrapper.c
index 6596c30..75a1de4 100644
--- a/python-wrapper.c
+++ b/python-wrapper.c
@@ -12,7 +12,11 @@
 #include <unistd.h>
 #include <sys/stat.h>
 
-#define ENVD_CONFIG "/etc/env.d/python/config"
+#ifndef ENVD
+#define ENVD "/etc/env.d"
+#endif
+
+#define ENVD_CONFIG ENVD "/python/config"
 
 /* 127 is the standard return code for "command not found" */
 #define EXIT_ERROR 127


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2014-01-25 17:04 Mike Gilbert
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Gilbert @ 2014-01-25 17:04 UTC (permalink / raw
  To: gentoo-commits

commit:     b6b49b17ba16ca1b5ec6dcb729b9cbe6507678ca
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 25 16:57:41 2014 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Sat Jan 25 16:57:41 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/eselect-python.git;a=commit;h=b6b49b17

Bump version.

---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index c85be38..dc142ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([eselect-python], [20140115])
+AC_INIT([eselect-python], [20140125])
 AM_INIT_AUTOMAKE([-Wall foreign no-dist-gzip dist-bzip2])
 
 AC_PROG_CC


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2015-11-17 18:36 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2015-11-17 18:36 UTC (permalink / raw
  To: gentoo-commits

commit:     bb5b98cacf492697f74d9dde87dc974b541b79ad
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 12 16:53:25 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Nov 12 16:53:37 2015 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=bb5b98ca

manpage: Support .lz compression

 python.eselect.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/python.eselect.in b/python.eselect.in
index 9a52791..8baa44e 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -58,7 +58,7 @@ remove_symlinks() {
 	local symlink symlink_target symlink_target_found
 	if [[ "${SET_MAIN_ACTIVE_PYTHON_INTERPRETER}" == "1" ]]; then
 		rm -f "${INTERPRETER_PATH}"{idle,pydoc,python,python-config,pythonw} &> /dev/null || return 1
-		rm -f "${MAN_PATH}"python.1{,.gz,.bz2,.lzma,.xz} &> /dev/null || return 1
+		rm -f "${MAN_PATH}"python.1{,.gz,.bz2,.lzma,.xz,.lz} &> /dev/null || return 1
 	fi
 
 	for symlink in "${INTERPRETER_PATH}python"?; do
@@ -80,7 +80,7 @@ remove_symlinks() {
 set_man_symlink() {
 	local target="${1}" x extension
 
-	for x in ".1" ".1.bz2" ".1.gz" ".1.lzma" ".1.xz"; do
+	for x in ".1" ".1.bz2" ".1.gz" ".1.lzma" ".1.xz" ".1.lz"; do
 		if [[ -e "${MAN_PATH}${target}${x}" ]]; then
 			extension="${x}"
 			break


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2015-11-17 18:36 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2015-11-17 18:36 UTC (permalink / raw
  To: gentoo-commits

commit:     cf186abf6240fc116f4a38d74cf8d627de57da6d
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 12 17:06:32 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Nov 12 17:06:32 2015 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=cf186abf

Stop creating symlinks to interpreters and the wrapper

 python.eselect.in | 60 ++++++++++---------------------------------------------
 1 file changed, 11 insertions(+), 49 deletions(-)

diff --git a/python.eselect.in b/python.eselect.in
index 32d9cbf..3d9b4bc 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -2,7 +2,7 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id: $
 
-DESCRIPTION="Manage Python symlinks"
+DESCRIPTION="Manage active Python interpreter"
 MAINTAINER="python@gentoo.org"
 SVN_DATE='$Date$'
 VERSION=$(svn_date_to_version "${SVN_DATE}" )
@@ -41,44 +41,18 @@ set_python_subver() {
 }
 
 set_python() {
-	local symlink="${INTERPRETER_PATH}python" target="${1}"
-	ln -s python-wrapper "${symlink}"
+	local target="${1}"
 	mkdir -p "${ENV_D_PATH}/python"
 	echo "${target}" > "${ENV_D_PATH}/python/config"
 }
 
-set_python_config() {
-	local script="${INTERPRETER_PATH}python-config" target="${1}"
-	cat << EOF > "${script}"
-#!/usr/bin/env bash
-# Gentoo python-config wrapper script
-
-[[ "\${EPYTHON}" =~ (/|^python\$) ]] && EPYTHON="${target/-config-/}"
-python_config="\${EPYTHON/python/python-config-}"
-"\${0%/*}/\${python_config:-${target}}" "\$@"
-EOF
-	chmod a+rx "${script}"
-}
-
 # Try to remove python and python.1 symlinks
 remove_symlinks() {
 	local symlink symlink_target symlink_target_found
 	if [[ "${SET_MAIN_ACTIVE_PYTHON_INTERPRETER}" == "1" ]]; then
-		rm -f "${INTERPRETER_PATH}"{idle,pydoc,python,python-config,pythonw} &> /dev/null || return 1
 		rm -f "${MAN_PATH}"python.1{,.gz,.bz2,.lzma,.xz,.lz} &> /dev/null || return 1
 	fi
 
-	for symlink in "${INTERPRETER_PATH}python"?; do
-		[[ ! -L "${symlink}" ]] && continue
-		symlink_target_found=0
-		for symlink_target in "${symlink}".?; do
-			[[ -f "${symlink_target}" ]] && symlink_target_found=1
-		done
-		if [[ "${symlink_target_found}" -eq 0 ]]; then
-			rm -f "${symlink}"
-		fi
-	done
-
 	# Files of Mac OS X framework
 	rm -f "${INTERPRETER_PATH%/bin/}/lib/Python.framework}"/{Headers,Python,Resources}
 }
@@ -125,25 +99,9 @@ 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-}"
-			ln -nfs "${target/python/pydoc}" pydoc
-			# idle is optionally installed
-			if [[ -f "${target/python/idle}" ]]; then
-				ln -nfs "${target/python/idle}" idle
-			fi
-			# 2to3 for >=2.6
-			if [[ -f "${target/python/2to3-}" ]]; then
-				ln -nfs "${target/python/2to3-}" 2to3
-			fi
-
-			# Wrapper for graphical applications on Mac OS X
-			if [[ -f "${target/python/pythonw}" ]] ; then
-				ln -nfs "${target/python/pythonw}" pythonw
-			fi
 
 			# Files of Mac OS X framework
 			local framework_dir="${INTERPRETER_PATH%/bin/}/lib/Python.framework"
@@ -213,9 +171,13 @@ do_show() {
 	fi
 
 	if [[ "${python2}" == "1" ]]; then
-		interpreter="$(<"${ENV_D_PATH}/python/python2")"
+		if [[ -f ${ENV_D_PATH}/python/python2 ]]; then
+			interpreter="$(<"${ENV_D_PATH}/python/python2")"
+		fi
 	elif [[ "${python3}" == "1" ]]; then
-		interpreter="$(<"${ENV_D_PATH}/python/python3")"
+		if [[ -f ${ENV_D_PATH}/python/python3 ]]; then
+			interpreter="$(<"${ENV_D_PATH}/python/python3")"
+		fi
 	elif [[ -f "${ENV_D_PATH}/python/config" ]]; then
 		interpreter="$(<"${ENV_D_PATH}/python/config")"
 	fi
@@ -385,10 +347,10 @@ do_update() {
 		die -q "'--python2' and '--python3' options cannot be specified simultaneously"
 	fi
 
-	if [[ "${if_unset}" == "1" && -f "${INTERPRETER_PATH}python" && -f "${ENV_D_PATH}/python/config" ]]; then
-		if [[ "${python2}" == "1" && -f "${INTERPRETER_PATH}python2" ]]; then
+	if [[ "${if_unset}" == "1" && -f "${ENV_D_PATH}/python/config" ]]; then
+		if [[ "${python2}" == "1" && -f "${ENV_D_PATH}/python/python2" ]]; then
 			return
-		elif [[ "${python3}" == "1" && -f "${INTERPRETER_PATH}python3" ]]; then
+		elif [[ "${python3}" == "1" && -f "${ENV_D_PATH}/python/python3" ]]; then
 			return
 		elif [[ "${python2}" == "0" && "${python3}" == "0" ]]; then
 			return


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
  2015-11-12 16:53 [gentoo-commits] proj/eselect-python:mgornys-hackery " Michał Górny
@ 2015-11-17 18:36 ` Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2015-11-17 18:36 UTC (permalink / raw
  To: gentoo-commits

commit:     a3421a53b669fd15c6449203700163712532e4f2
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 12 16:40:08 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Nov 12 16:53:37 2015 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=a3421a53

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.

 python.eselect.in | 12 ++++++++++--
 1 file 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


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2015-11-17 18:36 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2015-11-17 18:36 UTC (permalink / raw
  To: gentoo-commits

commit:     6824d7d6841536d153cb56a350c6f89708725777
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 12 17:07:35 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Nov 17 12:59:04 2015 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=6824d7d6

Remove python-wrapper

 Makefile.am      |   3 -
 configure.ac     |  26 +-----
 python-wrapper.c | 244 -------------------------------------------------------
 3 files changed, 1 insertion(+), 272 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 06f7d1c..beb4029 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,2 @@
-bin_PROGRAMS = python-wrapper
-python_wrapper_CPPFLAGS = -DENVD='"$(sysconfdir)/env.d"'
-
 eselectdir = $(datadir)/eselect/modules
 nodist_eselect_DATA = python.eselect

diff --git a/configure.ac b/configure.ac
index dc142ae..d9a6461 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,36 +1,12 @@
 AC_INIT([eselect-python], [20140125])
 AM_INIT_AUTOMAKE([-Wall foreign no-dist-gzip dist-bzip2])
 
+# note: we need AC_PROG_CC to determine EXEEXT (AC_EXEEXT does not work)
 AC_PROG_CC
 AC_PATH_PROG(INSTALL, install)
 AC_PROG_MKDIR_P
 
-AC_USE_SYSTEM_EXTENSIONS
-
-# setenv() was introduced in POSIX.1-2008.
-# strtok_r() was introduced in POSIX.1-2001.
-AC_CHECK_FUNCS([setenv strtok_r])
-
-# strndup() was introduced in POSIX.1-2008 and is also an implicitly declared built-in function in GCC.
-AC_MSG_CHECKING([for strndup])
-old_CFLAGS="${CFLAGS}"
-CFLAGS="${CFLAGS} -Wall -Werror -Wextra"
-AC_LINK_IFELSE([AC_LANG_SOURCE([[#include <string.h>
-int main()
-{
-  strndup("", 0);
-  return 0;
-}]])], [have_strndup="1"], [have_strndup="0"])
-if test "${have_strndup}" = "1"; then
-  AC_MSG_RESULT([yes])
-  AC_DEFINE([HAVE_STRNDUP], [1], [Define to 1 if you have the 'strndup' function.])
-else
-  AC_MSG_RESULT([no])
-fi
-CFLAGS="${old_CFLAGS}"
-
 # Create output files.
-AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_FILES([Makefile python.eselect])
 
 AC_OUTPUT

diff --git a/python-wrapper.c b/python-wrapper.c
deleted file mode 100644
index 75a1de4..0000000
--- a/python-wrapper.c
+++ /dev/null
@@ -1,244 +0,0 @@
-/* Copyright 1999-2010 Gentoo Foundation
- * Distributed under the terms of the GNU General Public License v2
- */
-
-#include "config.h"
-
-#include <dirent.h>
-#include <limits.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/stat.h>
-
-#ifndef ENVD
-#define ENVD "/etc/env.d"
-#endif
-
-#define ENVD_CONFIG ENVD "/python/config"
-
-/* 127 is the standard return code for "command not found" */
-#define EXIT_ERROR 127
-
-char* dir_cat(const char* dir, const char* file)
-{
-	size_t dir_len = strlen(dir);
-	char* abs = malloc(dir_len + strlen(file) + 2);
-	strcpy(abs, dir);
-	abs[dir_len] = '/';
-	abs[dir_len + 1] = 0;
-	return strcat(abs, file);
-}
-
-const char* find_path(const char* exe)
-{
-	const char* last_slash = strrchr(exe, '/');
-	if (last_slash)
-	{
-#ifdef HAVE_STRNDUP
-		return strndup(exe, last_slash - exe);
-#else
-		size_t len = last_slash - exe;
-		char* ret = malloc(sizeof(char) * (len + 1));
-		memcpy(ret, exe, len);
-		ret[len] = '\0';
-		return(ret);
-#endif
-	}
-	const char* PATH = getenv("PATH");
-	if (! PATH)
-	{
-		/* If PATH is unset, then it defaults to ":/bin:/usr/bin", per
-		 * execvp(3).
-		 */
-		PATH = ":/bin:/usr/bin";
-	}
-	char* path = strdup(PATH);
-#ifdef HAVE_STRTOK_R
-	char* state = NULL;
-	const char* token = strtok_r(path, ":", &state);
-#else
-	const char* token = strtok(path, ":");
-#endif
-	while (token)
-	{
-		/* If an element of PATH is empty ("::"), then it is "." */
-		if (! *token)
-		{
-			token = ".";
-		}
-		struct stat sbuf;
-		char* str = dir_cat(token, exe);
-		if (stat(str, &sbuf) == 0 && (S_ISREG(sbuf.st_mode) || S_ISLNK(sbuf.st_mode)))
-		{
-			return token;
-		}
-#ifdef HAVE_STRTOK_R
-		token = strtok_r(NULL, ":", &state);
-#else
-		token = strtok(NULL, ":");
-#endif
-	}
-	return NULL;
-}
-
-/* True if a valid file name, and not "python" */
-int valid_interpreter(const char* name)
-{
-	if (! name || ! *name || (strcmp(name, "python") == 0))
-	{
-		return 0;
-	}
-	return 1;
-}
-
-int get_version(const char* name)
-{
-	/* Only find files beginning with "python" - this is a fallback,
-	 * so we only want CPython
-	 */
-	if (! valid_interpreter(name) || strncmp(name, "python", 6) != 0)
-		return -1;
-	int pos = 6;
-	int major = 0;
-	int minor = 0;
-	if (name[pos] < '0' || name[pos] > '9')
-		return -1;
-	do
-	{
-		major = major * 10 + name[pos] - '0';
-		if (! name[++pos])
-			return -1;
-	}
-	while (name[pos] >= '0' && name[pos] <= '9');
-	if (name[pos++] != '.')
-		return -1;
-	if (name[pos] < '0' || name[pos] > '9')
-		return -1;
-	do
-	{
-		minor = minor * 10 + name[pos] - '0';
-		if (! name[++pos])
-			return (major << 8) | minor;
-	}
-	while (name[pos] >= '0' && name[pos] <= '9');
-	return -1;
-}
-
-int filter_python(const struct dirent* file)
-{
-	return get_version(file->d_name) != -1;
-}
-
-/* This implements a version sort, such that the following order applies:
- *    <invalid file names> (should never be seen)
- *    python2.6
- *    python2.9
- *    python2.10
- *    python3.0
- *    python3.1
- *    python3.2
- *    python9.1
- *    python9.9
- *    python9.10
- *    python10.1
- *    python10.9
- *    python10.10
- */
-int sort_python(const struct dirent**f1, const struct dirent** f2)
-{
-	int ver1 = get_version((*f1)->d_name);
-	int ver2 = get_version((*f2)->d_name);
-	return ver1 - ver2;
-}
-
-const char* find_latest(const char* exe)
-{
-	const char* path = find_path(exe);
-	if (! path || ! *path)
-	{
-		path = "/usr/bin";
-	}
-	struct dirent** namelist;
-	int n = scandir(path, &namelist, filter_python, sort_python);
-	const char* ret = NULL;
-	if (n < 0)
-	{
-		return NULL;
-	}
-	/* Walk backwards through the list. */
-	while (n--)
-	{
-		if (! ret)
-			ret = strdup(namelist[n]->d_name);
-		free(namelist[n]);
-	}
-	free(namelist);
-	return ret;
-}
-
-int main(int argc, char** argv)
-{
-	const char* EPYTHON = getenv("EPYTHON");
-	int script_name_index = -1;
-	if (! valid_interpreter(EPYTHON))
-	{
-		FILE* f = fopen(ENVD_CONFIG, "r");
-		if (f)
-		{
-			struct stat st;
-			fstat(fileno(f), &st);
-			size_t size = st.st_size;
-			char* cont = malloc(size + 1);
-			cont = fgets(cont, size + 1, f);
-			fclose(f);
-			size_t len = strlen(cont);
-			if (len && cont[len - 1] == '\n')
-				cont[len - 1] = 0;
-			EPYTHON = cont;
-		}
-	}
-
-	if (! valid_interpreter(EPYTHON))
-		EPYTHON = find_latest(argv[0]);
-
-	if (! EPYTHON)
-		return EXIT_ERROR;
-
-	if (strchr(EPYTHON, '/'))
-	{
-		fprintf(stderr, "Invalid value of EPYTHON variable or invalid configuration of Python wrapper\n");
-		return EXIT_ERROR;
-	}
-
-	/* Set GENTOO_PYTHON_PROCESS_NAME environmental variable, if a script with a Python shebang is probably being executed.
-	 * argv[0] can be "python", when "#!/usr/bin/env python" shebang is used. */
-	if (argc >= 2 && (argv[0][0] == '/' || strcmp(argv[0], "python") == 0) && (argv[1][0] == '/' || strncmp(argv[1], "./", 2) == 0))
-		script_name_index = 1;
-	else if (argc >= 3 && argv[0][0] == '/' && argv[1][0] == '-' && (argv[2][0] == '/' || strncmp(argv[2], "./", 2) == 0))
-		script_name_index = 2;
-	if (script_name_index > 0)
-	{
-		char* script_name = strrchr(argv[script_name_index], '/') + 1;
-#ifdef HAVE_SETENV
-		setenv("GENTOO_PYTHON_PROCESS_NAME", script_name, 1);
-#else
-		char* script_name_variable = malloc(sizeof(char) * (strlen("GENTOO_PYTHON_PROCESS_NAME=") + strlen(script_name)));
-		sprintf(script_name_variable, "GENTOO_PYTHON_PROCESS_NAME=%s", script_name);
-		putenv(script_name_variable);
-#endif
-	}
-
-	const char* path = find_path(argv[0]);
-	if (path)
-	{
-		argv[0] = dir_cat(path, EPYTHON);
-		execv(argv[0], argv);
-		/* If this failed, then just search the PATH. */
-	}
-
-	argv[0] = (char*) EPYTHON;
-	execvp(EPYTHON, argv);
-	return EXIT_ERROR;
-}


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2015-11-17 18:43 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2015-11-17 18:43 UTC (permalink / raw
  To: gentoo-commits

commit:     9b97b9aec5f673398b225e7bad1a16f420b00366
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 17 18:38:19 2015 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Nov 17 18:38:19 2015 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=9b97b9ae

Bump version

 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index d9a6461..eda7882 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([eselect-python], [20140125])
+AC_INIT([eselect-python], [20151117])
 AM_INIT_AUTOMAKE([-Wall foreign no-dist-gzip dist-bzip2])
 
 # note: we need AC_PROG_CC to determine EXEEXT (AC_EXEEXT does not work)


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2016-02-06  9:00 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2016-02-06  9:00 UTC (permalink / raw
  To: gentoo-commits

commit:     bfce7d731ce9c41c6bc3e5b8acf26f4d2ec53e32
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Feb  5 20:02:06 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Feb  5 20:36:30 2016 +0000
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() {


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
  2016-02-05 20:36 [gentoo-commits] proj/eselect-python:pyexec-2.3 " Michał Górny
@ 2016-02-06  9:00 ` Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2016-02-06  9:00 UTC (permalink / raw
  To: gentoo-commits

commit:     808be74d51901c942fce1ddd0bb69d910b2a5d9c
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Feb  4 22:02:39 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Feb  5 20:36:30 2016 +0000
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
 }


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
  2016-02-05 20:36 [gentoo-commits] proj/eselect-python:pyexec-2.3 " Michał Górny
@ 2016-02-06  9:00 ` Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2016-02-06  9:00 UTC (permalink / raw
  To: gentoo-commits

commit:     ce0d0242419fd7369d7febf2544d65f0e701c7ad
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Feb  2 22:02:31 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Feb  5 20:36:30 2016 +0000
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="python@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 "${i}" "${preferred[@]}" && continue
+		has "${i}" "${disabled[@]}" && continue
+		echo "${i}"
+	done
+	# disabled last
+	for i in "${targets[@]}"; do
+		has "${i}" "${disabled[@]}" || continue
+		echo "${i}"
+	done
 }
 
-# Try to remove python and python.1 symlinks
-remove_symlinks() {
-	local symlink symlink_target symlink_target_found
-	if [[ "${SET_MAIN_ACTIVE_PYTHON_INTERPRETER}" == "1" ]]; then
-		rm -f "${MAN_PATH}"python.1{,.gz,.bz2,.lzma,.xz,.lz} &> /dev/null || return 1
-	fi
+# Write new preference list. Preferences need to be passed
+# as parameters (${@}).
+write_preferences() {
+	sed -n -e '/^#/p' "${CONFIG_PATH}" > "${CONFIG_PATH}".new || die
+	local IFS=$'\n'
+	echo "${*}" >> "${CONFIG_PATH}".new || die
 
-	# Files of Mac OS X framework
-	rm -f "${INTERPRETER_PATH%/bin/}/lib/Python.framework}"/{Headers,Python,Resources}
+	mv "${CONFIG_PATH}".new "${CONFIG_PATH}" || die
 }
 
 # Set a man page symlink
 set_man_symlink() {
-	local target="${1}" x extension
+	local target=${1} x suffix
 
-	for x in ".1" ".1.bz2" ".1.gz" ".1.lzma" ".1.xz" ".1.lz"; do
-		if [[ -e "${MAN_PATH}${target}${x}" ]]; then
-			extension="${x}"
+	rm -f "${MAN_PATH}"/python.1{,.gz,.bz2,.lzma,.xz,.lz} || die
+
+	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 python-config script and appropriate symlinks
-set_scripts_and_symlinks() {
-	local target="${1}" targets=($(find_targets))
-	if is_number "${target}" && [[ ${target} -ge 1 ]]; then
-		target=${targets[$((${target} - 1))]}
-	fi
-
-	if ! has ${target} "${targets[@]}"; then
-		die -q "Invalid target ${target}"
-	fi
-	if [[ -f "${INTERPRETER_PATH}${target}" ]]; then
-		if ! remove_symlinks; then
-			die -q "Cannot remove symlinks"
-		fi
-
-		if [[ "${SET_MAIN_ACTIVE_PYTHON_INTERPRETER}" == "1" ]]; then
-			set_man_symlink "${target}"
-		fi
-
-		pushd "${INTERPRETER_PATH}" 1> /dev/null
-
-		set_python_subver "${target}"
-		if [[ "${SET_MAIN_ACTIVE_PYTHON_INTERPRETER}" == "1" ]]; then
-			set_python "${target}"
-
-			# 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
-				ln -nfs "Versions/${version}/Headers"
-				ln -nfs "Versions/${version}/Python"
-				ln -nfs "Versions/${version}/Resources"
-				popd 1> /dev/null
-			fi
-		fi
+# Set OSX framework symlinks
+set_osx_framework() {
+	local target=${1}
 
-		popd 1> /dev/null
-	else
-		die -q "Target \"${1}\" doesn't appear to be valid!"
+	# Files of Mac OS X framework
+	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"
-	if [[ -f "${ENV_D_PATH}/60python-docs-${target}" ]]; then
+	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 -n "${!variable}")"
-		if [[ -d "${path}" ]]; then
+		path="$(. "${ENV_D_PATH}/60python-docs-${target}"; echo "${!variable}")"
+		if [[ -d ${path} ]]; then
 			echo "PYTHONDOCS=\"${path}\"" > "${ENV_D_PATH}/65python-docs"
 		fi
 	fi
 }
 
+# Perform all necessary updates following preference list change.
+post_update() {
+	local main_interp=$(do_show)
+
+	# TODO: update only when necessary
+
+	set_man_symlink "${main_interp}"
+	set_osx_framework "${main_interp}"
+	set_python_docs "${main_interp}"
+}
+
 ### 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 "--pref-only   : consider only explicitly preferred impls"
+	echo "--python2     : show the preferred version of Python 2"
+	echo "--python3     : show the preferred version of Python 3"
 }
 
 do_show() {
-	local ABI="0" interpreter python2="0" python3="0"
-	while [[ $# > 0 ]]; do
-		case "$1" in
+	local abi filter interpreter pref_only
+	while [[ ${#} -gt 0 ]]; do
+		case ${1} in
 			--ABI)
-				ABI="1"
+				abi=1
+				;;
+			--pref-only)
+				pref_only=1
 				;;
-			--python2)
-				python2="1"
+			--python2|--py2)
+				filter=--py2
 				;;
-			--python3)
-				python3="1"
+			--python3|--py3)
+				filter=--py3
 				;;
 			*)
 				die -q "Unrecognized argument '$1'"
@@ -166,30 +203,25 @@ do_show() {
 		shift
 	done
 
-	if [[ "${python2}" == "1" && "${python3}" == "1" ]]; then
-		die -q "'--python2' and '--python3' options cannot be specified simultaneously"
+	local preferred=( $(get_preferred_pythons ${filter}) )
+	local installed=()
+	if [[ ! ${pref_only} ]]; then
+		installed=( $(get_installed_pythons ${filter}) )
 	fi
 
-	if [[ "${python2}" == "1" ]]; then
-		if [[ -f ${ENV_D_PATH}/python/python2 ]]; then
-			interpreter="$(<"${ENV_D_PATH}/python/python2")"
-		fi
-	elif [[ "${python3}" == "1" ]]; then
-		if [[ -f ${ENV_D_PATH}/python/python3 ]]; then
-			interpreter="$(<"${ENV_D_PATH}/python/python3")"
-		fi
-	elif [[ -f "${ENV_D_PATH}/python/config" ]]; then
-		interpreter="$(<"${ENV_D_PATH}/python/config")"
-	fi
+	# preferred are preferred, but fall back to anything
+	local i
+	for i in "${preferred[@]}" "${installed[@]}"; do
+		# skip if not installed
+		has "${i}" "${installed[@]}" || continue
+		interpreter=${i}
+		break
+	done
 
-	if [[ "${ABI}" == "1" ]]; then
-		echo -n "${interpreter#python}"
+	if [[ ${abi} ]]; then
+		echo "${interpreter#python}"
 	else
-		echo -n "${interpreter}"
-	fi
-
-	if [[ -n "${interpreter}" ]]; then
-		echo
+		echo "${interpreter}"
 	fi
 }
 
@@ -200,25 +232,19 @@ describe_list() {
 }
 
 describe_list_options() {
-	echo "--python2     : List installed Python 2 interpreters"
-	echo "--python3     : List installed Python 3 interpreters"
+	echo "--python2     : list only Python 2 interpreters"
+	echo "--python3     : list only Python 3 interpreters"
 }
 
 do_list() {
-	local active i python_descriptive_name="Python" python_version_option= python2="0" python3="0" targets=()
-	while [[ $# > 0 ]]; do
-		case "$1" in
-			--python2)
-				python2="1"
-				python_descriptive_name="Python 2"
-				python_version_option="--python2"
-				PYTHON_INTERPRETERS_GROUP="2"
+	local filter
+	while [[ ${#} -gt 0 ]]; do
+		case ${1} in
+			--python2|--py2)
+				filter=--py2
 				;;
-			--python3)
-				python3="1"
-				python_descriptive_name="Python 3"
-				python_version_option="--python3"
-				PYTHON_INTERPRETERS_GROUP="3"
+			--python3|--py3)
+				filter=--py3
 				;;
 			*)
 				die -q "Unrecognized argument '$1'"
@@ -227,32 +253,31 @@ do_list() {
 		shift
 	done
 
-	if [[ "${python2}" == "1" && "${python3}" == "1" ]]; then
-		die -q "'--python2' and '--python3' options cannot be specified simultaneously"
-	fi
+	local all=( $(get_all_pythons ${filter}) )
+	local preferred=( $(get_preferred_pythons ${filter}) )
+	local disabled=( $(get_disabled_pythons) )
 
-	targets=($(find_targets))
+	write_list_start "Available Python${filter+ ${filter#--py}} interpreters, in order of preference:"
 
-	write_list_start "Available ${python_descriptive_name} interpreters:"
-
-	active="$(do_show ${python_version_option})"
-	for ((i = 0; i < ${#targets[@]}; i++)); do
-		if [[ ${targets[${i}]} == ${active} ]]; then
-			targets[${i}]="$(highlight_marker "${targets[${i}]}")"
+	for (( i = 0; i < ${#all[@]}; ++i )); do
+		if has "${all[i]}" "${preferred[@]}"; then
+			all[i]=$(highlight_marker "${all[i]}")
+		elif has "${all[i]}" "${disabled[@]}"; then
+			all[i]=$(highlight_marker "${all[i]}" "$(highlight_warning -)")
 		fi
 	done
-	write_numbered_list -m "(none found)" "${targets[@]}"
+	write_numbered_list -m "(none found)" "${all[@]}"
 }
 
 ### set action ###
 
 describe_set() {
-	echo "Set main active Python interpreter"
+	echo "Set the preferred Python interpreter"
 }
 
 describe_set_options() {
-	echo "--python2     : Set active Python 2 interpreter without setting of main active Python interpreter if it is not set to Python 2"
-	echo "--python3     : Set active Python 3 interpreter without setting of main active Python interpreter if it is not set to Python 3"
+	echo "--python2     : update preference for Python 2 versions only"
+	echo "--python3     : update preference for Python 3 versions only"
 }
 
 describe_set_parameters() {
@@ -260,17 +285,14 @@ describe_set_parameters() {
 }
 
 do_set() {
-	local main_active_python_interpreter python2="0" python3="0"
-	SET_MAIN_ACTIVE_PYTHON_INTERPRETER="1"
-	while [[ $# > 0 ]]; do
-		case "$1" in
-			--python2)
-				python2="1"
-				PYTHON_INTERPRETERS_GROUP="2"
+	local filter
+	while [[ ${#} -gt 0 ]]; do
+		case ${1} in
+			--python2|--py2)
+				filter=--py2
 				;;
-			--python3)
-				python3="1"
-				PYTHON_INTERPRETERS_GROUP="3"
+			--python3|--py3)
+				filter=--py3
 				;;
 			*)
 				break
@@ -279,62 +301,74 @@ do_set() {
 		shift
 	done
 
-	if [[ "${python2}" == "1" && "${python3}" == "1" ]]; then
-		die -q "'--python2' and '--python3' options cannot be specified simultaneously"
+	[[ ${#} -eq 1 ]] || die "Usage: eselect python set <interpreter>"
+
+	local target=${1}
+	local targets=( $(get_all_pythons ${filter}) )
+	if is_number "${target}" \
+		&& [[ ${target} -ge 1 && ${target} -le ${#targets[@]} ]]
+	then
+		target=${targets[target-1]}
 	fi
 
-	if [[ $# -lt 1 ]]; then
-		die -q "'eselect python set' requires Python interpreter filename"
-	elif [[ $# -gt 1 ]]; then
-		die -q "'eselect python set' requires 1 argument"
-	else
-		main_active_python_interpreter="$(do_show)"
-		if [[ "${python2}" == "1" && "${main_active_python_interpreter}" != "python2."* ]]; then
-			SET_MAIN_ACTIVE_PYTHON_INTERPRETER="0"
-		elif [[ "${python3}" == "1" && "${main_active_python_interpreter}" != "python3."* ]]; then
-			SET_MAIN_ACTIVE_PYTHON_INTERPRETER="0"
-		fi
+	has "${target}" "${targets[@]}" || die "Invalid target: ${target}"
 
-		if ! set_scripts_and_symlinks "${1}"; then
-			die -q "Can't set new provider"
-		fi
+	local prefs=( $(get_all_preferences) )
 
-		if [[ "${SET_MAIN_ACTIVE_PYTHON_INTERPRETER}" == "1" ]]; then
-			set_python_docs "${1}"
+	local i target_idx
+	for (( i = 0; i < ${#prefs[@]}; ++i )); do
+		# find first positive preference matching the filter
+		if [[ ! ${target_idx} ]]; then
+			if [[ ( ${filter} == --py? && ${prefs[i]} == python${filter:4}* ) \
+				|| ( ! ${filter} && ${prefs[i]} != -* ) ]]
+			then
+				target_idx=${i}
+			fi
 		fi
-	fi
+
+		# remove all duplicate positive and negative entries for target
+		[[ ${prefs[i]#-} == ${target} ]] && unset 'prefs[i]'
+	done
+	# if none matched, add to the bottom
+	: "${target_idx=${#prefs[@]}}"
+
+	# add between remaining preferences, before the one matching
+	# need to do this outta loop in case no pref matches
+	prefs=( "${prefs[@]:0:target_idx}" "${target}" "${prefs[@]:target_idx}" )
+
+	write_preferences "${prefs[@]}"
+	post_update
 }
 
 ### update action ###
 
 describe_update() {
-	echo "Switch to the most recent CPython interpreter"
+	echo "Switch to the most recent Python interpreter"
 }
 
 describe_update_options() {
-	echo "--if-unset    : Do not override existing implementation"
-	echo "--ignore SLOT : Ignore SLOT when setting symlinks"
-	echo "--python2     : Set active Python 2 interpreter without setting of main active Python interpreter if it is not set to Python 2"
-	echo "--python3     : Set active Python 3 interpreter without setting of main active Python interpreter if it is not set to Python 3"
+	echo "--if-unset    : do not alter preferences unless there is no valid preference set"
+	echo "--ignore SLOT : ignore specified Python slots"
+	echo "--python2     : update only Python 2 preferences"
+	echo "--python3     : update only Python 3 preferences"
 }
 
 do_update() {
-	local if_unset="0" ignored_slots=() interpreters="python?.?@EXEEXT@" python2="0" python3="0" python_version_option= slot= target targets=()
-	while [[ $# > 0 ]]; do
-		case "$1" in
+	local if_unset ignored_slots=() filter
+	while [[ ${#} -gt 0 ]]; do
+		case ${1} in
 			--if-unset)
-				if_unset="1"
+				if_unset=1
 				;;
 			--ignore)
-				ignored_slots+=("${2}")
-				shift;;
-			--python2)
-				python2="1"
-				python_version_option="--python2"
+				ignored_slots+=( "${2}" )
+				shift
 				;;
-			--python3)
-				python3="1"
-				python_version_option="--python3"
+			--python2|--py2)
+				filter=--py2
+				;;
+			--python3|--py3)
+				filter=--py3
 				;;
 			*)
 				die -q "Unrecognized argument '$1'"
@@ -343,37 +377,24 @@ do_update() {
 		shift
 	done
 
-	if [[ "${python2}" == "1" && "${python3}" == "1" ]]; then
-		die -q "'--python2' and '--python3' options cannot be specified simultaneously"
-	fi
-
-	if [[ "${if_unset}" == "1" && -f "${ENV_D_PATH}/python/config" ]]; then
-		if [[ "${python2}" == "1" && -f "${ENV_D_PATH}/python/python2" ]]; then
-			return
-		elif [[ "${python3}" == "1" && -f "${ENV_D_PATH}/python/python3" ]]; then
-			return
-		elif [[ "${python2}" == "0" && "${python3}" == "0" ]]; then
-			return
-		fi
-	fi
+	if [[ ${if_unset} ]]; then
+		local current=$(do_show ${filter} --pref-only)
 
-	if [[ "${python2}" == "1" ]]; then
-		interpreters="python2.?@EXEEXT@"
-	elif [[ "${python3}" == "1" ]]; then
-		interpreters="python3.?@EXEEXT@"
+		[[ ${current} ]] && return
 	fi
 
-	targets=($(cd "${INTERPRETER_PATH}"; ls ${interpreters} 2> /dev/null | sort -r))
+	local targets=( $(get_installed_pythons ${filter}) )
 
 	# Ignore slots
+	local slot
 	for slot in ${ignored_slots[@]}; do
-		targets=(${targets[@]/python${slot}/})
+		targets=( ${targets[@]/python${slot}/} )
 	done
 
-	if [[ ${#targets[@]} -gt 0 ]]; then
-		target=${targets[0]}
+	if [[ ${targets[@]} ]]; then
+		local target=${targets[0]}
 		echo "Switching to ${target}"
-		do_set ${python_version_option} ${target}
+		do_set ${filter} "${target}"
 	else
 		die -q "No Python interpreter available"
 	fi


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2016-02-06  9:29 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2016-02-06  9:29 UTC (permalink / raw
  To: gentoo-commits

commit:     9cd3e07fc522120bcfe57353e30d185926da0891
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Feb  6 09:29:30 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Feb  6 09:29:30 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=9cd3e07f

show: Fix --pref-only

 python.eselect.in | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/python.eselect.in b/python.eselect.in
index bbe024f..2bf6e30 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -216,14 +216,14 @@ do_show() {
 	done
 
 	local preferred=( $(get_preferred_pythons ${filter}) )
-	local installed=()
-	if [[ ! ${pref_only} ]]; then
-		installed=( $(get_installed_pythons ${filter}) )
-	fi
+	local installed=( $(get_installed_pythons ${filter}) )
 
+	local all=( "${preferred[@]}" )
 	# preferred are preferred, but fall back to anything
+	[[ ${pref_only} ]] || all+=( "${installed[@]}" )
+
 	local i
-	for i in "${preferred[@]}" "${installed[@]}"; do
+	for i in "${all[@]}"; do
 		# skip if not installed
 		has "${i}" "${installed[@]}" || continue
 		interpreter=${i}


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2016-02-06  9:49 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2016-02-06  9:49 UTC (permalink / raw
  To: gentoo-commits

commit:     d86d8200817ee4b77e5d7a4bc552ec4711ed8638
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Feb  6 09:48:54 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Feb  6 09:48:54 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=d86d8200

update: Ignore Python 2 preference update requests

 python.eselect.in | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/python.eselect.in b/python.eselect.in
index 2bf6e30..e05bff1 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -362,7 +362,7 @@ describe_update() {
 describe_update_options() {
 	echo "--if-unset    : do not alter preferences unless there is no valid preference set"
 	echo "--ignore SLOT : ignore specified Python slots"
-	echo "--python2     : update only Python 2 preferences"
+	echo "--python2     : update only Python 2 preferences (ignored)"
 	echo "--python3     : update only Python 3 preferences"
 }
 
@@ -379,6 +379,8 @@ do_update() {
 				;;
 			--python2|--py2)
 				filter=--py2
+				echo "Ignoring Python 2 preference update as non-meaningful"
+				return 0
 				;;
 			--python3|--py3)
 				filter=--py3


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2016-02-06  9:50 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2016-02-06  9:50 UTC (permalink / raw
  To: gentoo-commits

commit:     0b3b8e4b89cd272fd84bce442345c0bbc2c601e8
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Feb  6 09:50:13 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Feb  6 09:50:13 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=0b3b8e4b

Handle missing configuration file gracefully

 python.eselect.in | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/python.eselect.in b/python.eselect.in
index e05bff1..0945c63 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -32,6 +32,8 @@ get_installed_pythons() {
 # includes both preferred implementations (in preference order)
 # and disabled interpreters.
 get_all_preferences() {
+	[[ -e ${CONFIG_PATH} ]] || return
+
 	local l
 	while read l; do
 		# skip comments
@@ -98,7 +100,10 @@ get_all_pythons() {
 # Write new preference list. Preferences need to be passed
 # as parameters (${@}).
 write_preferences() {
-	sed -n -e '/^#/p' "${CONFIG_PATH}" > "${CONFIG_PATH}".new || die
+	if [[ -e ${CONFIG_PATH} ]]; then
+		sed -n -e '/^#/p' "${CONFIG_PATH}" > "${CONFIG_PATH}".new || die
+	fi
+
 	local IFS=$'\n'
 	echo "${*}" >> "${CONFIG_PATH}".new || die
 


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2016-02-06 21:30 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2016-02-06 21:30 UTC (permalink / raw
  To: gentoo-commits

commit:     6b28659d519a7e2ea91109702f0d85e5dfac0364
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Feb  6 21:00:28 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Feb  6 21:00:28 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=6b28659d

edit: Run post_update after editing the file

 python.eselect.in | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/python.eselect.in b/python.eselect.in
index 0945c63..cc2f672 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -182,6 +182,8 @@ do_edit() {
 	[[ ${EDITOR} ]] || die "EDITOR is not set"
 
 	${EDITOR} "${CONFIG_PATH}"
+
+	post_update
 }
 
 ### show action ###


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2016-02-06 21:30 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2016-02-06 21:30 UTC (permalink / raw
  To: gentoo-commits

commit:     59862908e0557b7ed34a9cbf0b83de0690c4276d
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Feb  6 21:06:45 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Feb  6 21:06:45 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=59862908

Add --cpython filter to filter out non-CPython preferences

 python.eselect.in | 36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/python.eselect.in b/python.eselect.in
index cc2f672..5f22614 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -22,7 +22,7 @@ get_installed_pythons() {
 		exe=${exe##*/}
 		exe=${exe%@EXEEXT@}
 		# apply filters
-		[[ ${1} == --py? && ${exe} != python${1:4}* ]] && continue
+		[[ ${1} == --py* && ${exe} != python${1:4}* ]] && continue
 
 		echo "${exe}"
 	done
@@ -53,7 +53,7 @@ get_preferred_pythons() {
 		# skip negative entries
 		[[ ${i} == -* ]] && continue
 		# apply filters
-		[[ ${1} == --py? && ${i} != python${1:4}* ]] && continue
+		[[ ${1} == --py* && ${i} != python${1:4}* ]] && continue
 
 		echo "${i}"
 	done
@@ -194,9 +194,10 @@ describe_show() {
 
 describe_show_options() {
 	echo "--ABI         : use PYTHON_ABI variable format (deprecated)"
+	echo "--cpython     : show the preferred version of CPython"
 	echo "--pref-only   : consider only explicitly preferred impls"
-	echo "--python2     : show the preferred version of Python 2"
-	echo "--python3     : show the preferred version of Python 3"
+	echo "--python2     : show the preferred version of CPython 2"
+	echo "--python3     : show the preferred version of CPython 3"
 }
 
 do_show() {
@@ -206,6 +207,9 @@ do_show() {
 			--ABI)
 				abi=1
 				;;
+			--cpython|--py)
+				filter=--py
+				;;
 			--pref-only)
 				pref_only=1
 				;;
@@ -251,14 +255,18 @@ describe_list() {
 }
 
 describe_list_options() {
-	echo "--python2     : list only Python 2 interpreters"
-	echo "--python3     : list only Python 3 interpreters"
+	echo "--cpython     : list only CPython interpreters"
+	echo "--python2     : list only CPython 2 interpreters"
+	echo "--python3     : list only CPython 3 interpreters"
 }
 
 do_list() {
 	local filter
 	while [[ ${#} -gt 0 ]]; do
 		case ${1} in
+			--cpython|--py)
+				filter=--py
+				;;
 			--python2|--py2)
 				filter=--py2
 				;;
@@ -295,8 +303,9 @@ describe_set() {
 }
 
 describe_set_options() {
-	echo "--python2     : update preference for Python 2 versions only"
-	echo "--python3     : update preference for Python 3 versions only"
+	echo "--cpython     : update preference for CPython versions only"
+	echo "--python2     : update preference for CPython 2 versions only"
+	echo "--python3     : update preference for CPython 3 versions only"
 }
 
 describe_set_parameters() {
@@ -307,6 +316,9 @@ do_set() {
 	local filter
 	while [[ ${#} -gt 0 ]]; do
 		case ${1} in
+			--cpython|--py)
+				filter=--py
+				;;
 			--python2|--py2)
 				filter=--py2
 				;;
@@ -369,8 +381,9 @@ describe_update() {
 describe_update_options() {
 	echo "--if-unset    : do not alter preferences unless there is no valid preference set"
 	echo "--ignore SLOT : ignore specified Python slots"
-	echo "--python2     : update only Python 2 preferences (ignored)"
-	echo "--python3     : update only Python 3 preferences"
+	echo "--cpython     : update only CPython preferences"
+	echo "--python2     : update only CPython 2 preferences (ignored)"
+	echo "--python3     : update only CPython 3 preferences"
 }
 
 do_update() {
@@ -384,6 +397,9 @@ do_update() {
 				ignored_slots+=( "${2}" )
 				shift
 				;;
+			--cpython|--py)
+				filter=--py
+				;;
 			--python2|--py2)
 				filter=--py2
 				echo "Ignoring Python 2 preference update as non-meaningful"


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2016-02-06 21:30 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2016-02-06 21:30 UTC (permalink / raw
  To: gentoo-commits

commit:     f3ef3c17ac1fb2bb53050a28a0e409c30282c5d2
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Feb  6 21:07:09 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Feb  6 21:07:09 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=f3ef3c17

post_update: Use only CPython for manpages, frameworks and python-docs

 python.eselect.in | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/python.eselect.in b/python.eselect.in
index 5f22614..37a824c 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -163,13 +163,13 @@ set_python_docs() {
 
 # Perform all necessary updates following preference list change.
 post_update() {
-	local main_interp=$(do_show)
+	local main_cpython=$(do_show --cpython)
 
 	# TODO: update only when necessary
 
-	set_man_symlink "${main_interp}"
-	set_osx_framework "${main_interp}"
-	set_python_docs "${main_interp}"
+	set_man_symlink "${main_cpython}"
+	set_osx_framework "${main_cpython}"
+	set_python_docs "${main_cpython}"
 }
 
 ### edit action ###


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2016-02-06 21:30 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2016-02-06 21:30 UTC (permalink / raw
  To: gentoo-commits

commit:     b70420d4010d3f7bae763faaea3fc4020fd6b12d
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Feb  6 21:30:08 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Feb  6 21:30:08 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=b70420d4

Support PyPy & Jython

 python.eselect.in | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/python.eselect.in b/python.eselect.in
index 37a824c..e542f5e 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -14,7 +14,14 @@ 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 exes=(
+		# note: order *matters*
+		# TODO: get them outta python-exec
+		"${INTERPRETER_DIR}"/jython?.?@EXEEXT@
+		"${INTERPRETER_DIR}"/pypy{,3}@EXEEXT@
+		"${INTERPRETER_DIR}"/python?.?@EXEEXT@
+	)
+
 	local i
 	for (( i = ${#exes[@]}-1; i >= 0; --i )); do
 		local exe=${exes[i]}


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2016-02-22 21:41 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2016-02-22 21:41 UTC (permalink / raw
  To: gentoo-commits

commit:     4d6e160eda2eda8065b079047860ba08ca5a59eb
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Feb  7 17:58:02 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Feb  7 17:58:02 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=4d6e160e

Bump to 20160207

 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index eda7882..6ea1742 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([eselect-python], [20151117])
+AC_INIT([eselect-python], [20160207])
 AM_INIT_AUTOMAKE([-Wall foreign no-dist-gzip dist-bzip2])
 
 # note: we need AC_PROG_CC to determine EXEEXT (AC_EXEEXT does not work)


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2016-02-22 21:41 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2016-02-22 21:41 UTC (permalink / raw
  To: gentoo-commits

commit:     8ff5406d6d20b69f7ca05b3f760b72b92fe54f34
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 22 21:34:36 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Feb 22 21:41:52 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=8ff5406d

set_man_symlink: fix variables

 python.eselect.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/python.eselect.in b/python.eselect.in
index e542f5e..701c02b 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -135,7 +135,7 @@ set_man_symlink() {
 		return 1
 	fi
 
-	ln -nfs "${target}${extension}" "${MAN_PATH}/python${extension}" || die
+	ln -nfs "${target}${suffix}" "${MAN_PATH}/python${suffix}" || die
 }
 
 # Set OSX framework symlinks


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2016-02-22 21:41 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2016-02-22 21:41 UTC (permalink / raw
  To: gentoo-commits

commit:     c7fe39df97de287a029c3e10058c8719655f8dc0
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 22 21:13:06 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Feb 22 21:41:52 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=c7fe39df

list: Use a more readable (verbose) output format

 python.eselect.in | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/python.eselect.in b/python.eselect.in
index 701c02b..e9390ec 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -294,10 +294,10 @@ do_list() {
 	write_list_start "Available Python${filter+ ${filter#--py}} interpreters, in order of preference:"
 
 	for (( i = 0; i < ${#all[@]}; ++i )); do
-		if has "${all[i]}" "${preferred[@]}"; then
-			all[i]=$(highlight_marker "${all[i]}")
-		elif has "${all[i]}" "${disabled[@]}"; then
-			all[i]=$(highlight_marker "${all[i]}" "$(highlight_warning -)")
+		if has "${all[i]}" "${disabled[@]}"; then
+			all[i]=$(highlight_marker "${all[i]}" "$(highlight_warning "(disabled)")")
+		elif ! has "${all[i]}" "${preferred[@]}"; then
+			all[i]=$(highlight_marker "${all[i]}" "(fallback)")
 		fi
 	done
 	write_numbered_list -m "(none found)" "${all[@]}"


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2016-02-23 22:16 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2016-02-23 22:16 UTC (permalink / raw
  To: gentoo-commits

commit:     d462dcb4dc47e090b87b2947f0bacfee485c483e
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 22 21:32:14 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Feb 22 21:42:02 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=d462dcb4

Obtain supported implementations list from python-exec2c

 configure.ac      |  2 --
 python.eselect.in | 26 +++++++++-----------------
 2 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6ea1742..1e836e3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,8 +1,6 @@
 AC_INIT([eselect-python], [20160207])
 AM_INIT_AUTOMAKE([-Wall foreign no-dist-gzip dist-bzip2])
 
-# note: we need AC_PROG_CC to determine EXEEXT (AC_EXEEXT does not work)
-AC_PROG_CC
 AC_PATH_PROG(INSTALL, install)
 AC_PROG_MKDIR_P
 

diff --git a/python.eselect.in b/python.eselect.in
index e9390ec..196140e 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -14,25 +14,17 @@ 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=(
-		# note: order *matters*
-		# TODO: get them outta python-exec
-		"${INTERPRETER_DIR}"/jython?.?@EXEEXT@
-		"${INTERPRETER_DIR}"/pypy{,3}@EXEEXT@
-		"${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
+	# get complete list from python-exec
+	while read i; do
+		# filter by type
+		[[ ${1} == --py* && ${i} != python${1:4}* ]] && continue
+		# filter to installed only
+		if type -P "${i}" &>/dev/null; then
+			echo "${i}"
+		fi
+	done < <(python-exec2c -l)
 }
 
 # Get list of all preference values from python-exec.conf. This


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2016-02-28 17:03 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2016-02-28 17:03 UTC (permalink / raw
  To: gentoo-commits

commit:     ac632af5d4f055be85ea57e6ee95da8795175e0b
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 25 18:06:05 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Feb 25 18:07:43 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=ac632af5

Bump to 20160222

 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 406acd8..e8ddfb4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([eselect-python], [20160207])
+AC_INIT([eselect-python], [20160222])
 AM_INIT_AUTOMAKE([-Wall foreign no-dist-gzip dist-bzip2])
 
 # Create output files.


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2016-02-28 17:03 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2016-02-28 17:03 UTC (permalink / raw
  To: gentoo-commits

commit:     1e83cc3cf19be2a8bbc87f4f9e2f2e7cdb6a32af
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 25 18:05:43 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Feb 25 18:05:43 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=1e83cc3c

build: Remove unused macros

 configure.ac | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1e836e3..406acd8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,9 +1,6 @@
 AC_INIT([eselect-python], [20160207])
 AM_INIT_AUTOMAKE([-Wall foreign no-dist-gzip dist-bzip2])
 
-AC_PATH_PROG(INSTALL, install)
-AC_PROG_MKDIR_P
-
 # Create output files.
 AC_CONFIG_FILES([Makefile python.eselect])
 


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2016-05-16 16:38 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2016-05-16 16:38 UTC (permalink / raw
  To: gentoo-commits

commit:     f5e16983117b9fb44c4121a65ce4ced93f432c2c
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon May 16 16:37:35 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon May 16 16:37:35 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=f5e16983

Respect EPYTHON when looking for installed intepreters

 python.eselect.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/python.eselect.in b/python.eselect.in
index 196140e..7edcb96 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -21,7 +21,7 @@ get_installed_pythons() {
 		# filter by type
 		[[ ${1} == --py* && ${i} != python${1:4}* ]] && continue
 		# filter to installed only
-		if type -P "${i}" &>/dev/null; then
+		if [[ -x ${INTERPRETER_PATH}/${i} ]]; then
 			echo "${i}"
 		fi
 	done < <(python-exec2c -l)


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2016-05-16 16:38 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2016-05-16 16:38 UTC (permalink / raw
  To: gentoo-commits

commit:     fa1f72249c96647568cd176ca4393b161f477bb8
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon May 16 16:38:20 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon May 16 16:38:20 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=fa1f7224

Respect EROOT when spawning python-exec2c for interpreter list

 python.eselect.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/python.eselect.in b/python.eselect.in
index 7edcb96..8a21ab1 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -24,7 +24,7 @@ get_installed_pythons() {
 		if [[ -x ${INTERPRETER_PATH}/${i} ]]; then
 			echo "${i}"
 		fi
-	done < <(python-exec2c -l)
+	done < <("${INTERPRETER_DIR}"/python-exec2c -l)
 }
 
 # Get list of all preference values from python-exec.conf. This


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2016-05-16 16:47 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2016-05-16 16:47 UTC (permalink / raw
  To: gentoo-commits

commit:     7c5a9f01c5f9846a7d2b3b9d9e9ce103115c2519
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon May 16 16:47:44 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon May 16 16:47:44 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=7c5a9f01

Fix typo in INTERPRETER_DIR var ref

 python.eselect.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/python.eselect.in b/python.eselect.in
index 8a21ab1..a3720ee 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -21,7 +21,7 @@ get_installed_pythons() {
 		# filter by type
 		[[ ${1} == --py* && ${i} != python${1:4}* ]] && continue
 		# filter to installed only
-		if [[ -x ${INTERPRETER_PATH}/${i} ]]; then
+		if [[ -x ${INTERPRETER_DIR}/${i} ]]; then
 			echo "${i}"
 		fi
 	done < <("${INTERPRETER_DIR}"/python-exec2c -l)


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2016-05-16 18:04 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2016-05-16 18:04 UTC (permalink / raw
  To: gentoo-commits

commit:     043fc5dc46cfca254923a1aabd2164928f1f348d
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon May 16 18:03:46 2016 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon May 16 18:03:46 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=043fc5dc

Revert "Respect EROOT when spawning python-exec2c for interpreter list"

This could break cross-compilation.

 python.eselect.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/python.eselect.in b/python.eselect.in
index a3720ee..451529d 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -24,7 +24,7 @@ get_installed_pythons() {
 		if [[ -x ${INTERPRETER_DIR}/${i} ]]; then
 			echo "${i}"
 		fi
-	done < <("${INTERPRETER_DIR}"/python-exec2c -l)
+	done < <(python-exec2c -l)
 }
 
 # Get list of all preference values from python-exec.conf. This


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2016-08-03 15:44 Mike Gilbert
  0 siblings, 0 replies; 39+ messages in thread
From: Mike Gilbert @ 2016-08-03 15:44 UTC (permalink / raw
  To: gentoo-commits

commit:     6a6e67093c565fd9c3b9ebfc8999111070c457de
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Wed Aug  3 15:40:22 2016 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Wed Aug  3 15:40:22 2016 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=6a6e6709

Upadate version to 20160516

 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index e8ddfb4..6adddb3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([eselect-python], [20160222])
+AC_INIT([eselect-python], [20160516])
 AM_INIT_AUTOMAKE([-Wall foreign no-dist-gzip dist-bzip2])
 
 # Create output files.


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2017-12-03 12:20 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2017-12-03 12:20 UTC (permalink / raw
  To: gentoo-commits

commit:     c35ddadceeca65d617c3e1254d9c0a96dd9cfb5c
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Dec  3 12:17:17 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Dec  3 12:20:13 2017 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=c35ddadc

list: Mark uninstalled Pythons as such

Bug: https://bugs.gentoo.org/639578

 python.eselect.in | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/python.eselect.in b/python.eselect.in
index 451529d..bfb126a 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -280,6 +280,7 @@ do_list() {
 	done
 
 	local all=( $(get_all_pythons ${filter}) )
+	local installed=( $(get_installed_pythons ${filter}) )
 	local preferred=( $(get_preferred_pythons ${filter}) )
 	local disabled=( $(get_disabled_pythons) )
 
@@ -288,6 +289,8 @@ do_list() {
 	for (( i = 0; i < ${#all[@]}; ++i )); do
 		if has "${all[i]}" "${disabled[@]}"; then
 			all[i]=$(highlight_marker "${all[i]}" "$(highlight_warning "(disabled)")")
+		elif ! has "${all[i]}" "${installed[@]}"; then
+			all[i]=$(highlight_marker "${all[i]}" "$(highlight_warning "(uninstalled)")")
 		elif ! has "${all[i]}" "${preferred[@]}"; then
 			all[i]=$(highlight_marker "${all[i]}" "(fallback)")
 		fi


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2017-12-03 13:23 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2017-12-03 13:23 UTC (permalink / raw
  To: gentoo-commits

commit:     a818ba77f72aff31d82badf7cb9b4cbd50cdbdf2
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Dec  3 13:21:51 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Dec  3 13:21:51 2017 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=a818ba77

Add a 'cleanup' action to remove stale preferences

 python.eselect.in | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 86 insertions(+)

diff --git a/python.eselect.in b/python.eselect.in
index bfb126a..e9378d4 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -171,6 +171,92 @@ post_update() {
 	set_python_docs "${main_cpython}"
 }
 
+### cleanup action ###
+
+describe_cleanup() {
+	echo "Remove stale implementations from list"
+}
+
+do_cleanup() {
+	local installed=( $(get_installed_pythons) )
+	local prefs=( $(get_all_preferences) )
+
+	local i target_idx
+	for (( i = 0; i < ${#prefs[@]}; ++i )); do
+		# remove preferences for uninstalled interpreters
+		if ! has "${prefs[i]#-}" "${installed[@]}"; then
+			unset 'prefs[i]'
+		fi
+	done
+
+	umask 022
+	write_preferences "${prefs[@]}"
+
+	post_update
+}
+
+### show action ###
+
+describe_show() {
+	echo "Show the most preferred Python interpreter"
+}
+
+describe_show_options() {
+	echo "--ABI         : use PYTHON_ABI variable format (deprecated)"
+	echo "--cpython     : show the preferred version of CPython"
+	echo "--pref-only   : consider only explicitly preferred impls"
+	echo "--python2     : show the preferred version of CPython 2"
+	echo "--python3     : show the preferred version of CPython 3"
+}
+
+do_show() {
+	local abi filter interpreter pref_only
+	while [[ ${#} -gt 0 ]]; do
+		case ${1} in
+			--ABI)
+				abi=1
+				;;
+			--cpython|--py)
+				filter=--py
+				;;
+			--pref-only)
+				pref_only=1
+				;;
+			--python2|--py2)
+				filter=--py2
+				;;
+			--python3|--py3)
+				filter=--py3
+				;;
+			*)
+				die -q "Unrecognized argument '$1'"
+				;;
+		esac
+		shift
+	done
+
+	local preferred=( $(get_preferred_pythons ${filter}) )
+	local installed=( $(get_installed_pythons ${filter}) )
+
+	local all=( "${preferred[@]}" )
+	# preferred are preferred, but fall back to anything
+	[[ ${pref_only} ]] || all+=( "${installed[@]}" )
+
+	local i
+	for i in "${all[@]}"; do
+		# skip if not installed
+		has "${i}" "${installed[@]}" || continue
+		interpreter=${i}
+		break
+	done
+
+	if [[ ${abi} ]]; then
+		echo "${interpreter#python}"
+	else
+		echo "${interpreter}"
+	fi
+}
+
 ### edit action ###
 
 describe_edit() {


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2017-12-03 13:24 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2017-12-03 13:24 UTC (permalink / raw
  To: gentoo-commits

commit:     cea78aa151cdca1b2c824d8db44a352d4ec88e51
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Dec  3 13:23:45 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Dec  3 13:23:45 2017 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=cea78aa1

Remove obsolete '--ABI' option

 python.eselect.in | 24 ++++--------------------
 1 file changed, 4 insertions(+), 20 deletions(-)

diff --git a/python.eselect.in b/python.eselect.in
index e9378d4..2f7ff8f 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -202,7 +202,6 @@ describe_show() {
 }
 
 describe_show_options() {
-	echo "--ABI         : use PYTHON_ABI variable format (deprecated)"
 	echo "--cpython     : show the preferred version of CPython"
 	echo "--pref-only   : consider only explicitly preferred impls"
 	echo "--python2     : show the preferred version of CPython 2"
@@ -210,12 +209,9 @@ describe_show_options() {
 }
 
 do_show() {
-	local abi filter interpreter pref_only
+	local filter interpreter pref_only
 	while [[ ${#} -gt 0 ]]; do
 		case ${1} in
-			--ABI)
-				abi=1
-				;;
 			--cpython|--py)
 				filter=--py
 				;;
@@ -250,11 +246,7 @@ do_show() {
 		break
 	done
 
-	if [[ ${abi} ]]; then
-		echo "${interpreter#python}"
-	else
-		echo "${interpreter}"
-	fi
+	echo "${interpreter}"
 }
 
 ### edit action ###
@@ -278,7 +270,6 @@ describe_show() {
 }
 
 describe_show_options() {
-	echo "--ABI         : use PYTHON_ABI variable format (deprecated)"
 	echo "--cpython     : show the preferred version of CPython"
 	echo "--pref-only   : consider only explicitly preferred impls"
 	echo "--python2     : show the preferred version of CPython 2"
@@ -286,12 +277,9 @@ describe_show_options() {
 }
 
 do_show() {
-	local abi filter interpreter pref_only
+	local filter interpreter pref_only
 	while [[ ${#} -gt 0 ]]; do
 		case ${1} in
-			--ABI)
-				abi=1
-				;;
 			--cpython|--py)
 				filter=--py
 				;;
@@ -326,11 +314,7 @@ do_show() {
 		break
 	done
 
-	if [[ ${abi} ]]; then
-		echo "${interpreter#python}"
-	else
-		echo "${interpreter}"
-	fi
+	echo "${interpreter}"
 }
 
 ### list action ###


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2017-12-04 17:32 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2017-12-04 17:32 UTC (permalink / raw
  To: gentoo-commits

commit:     88df47fb1e6366a681e40a2cd22fef473d9b2498
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Dec  4 17:29:34 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Dec  4 17:29:34 2017 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=88df47fb

Bump version to 20171204

 configure.ac      | 2 +-
 python.eselect.in | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6adddb3..e67babb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([eselect-python], [20160516])
+AC_INIT([eselect-python], [20171204])
 AM_INIT_AUTOMAKE([-Wall foreign no-dist-gzip dist-bzip2])
 
 # Create output files.

diff --git a/python.eselect.in b/python.eselect.in
index 2f7ff8f..8c48b09 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -1,4 +1,4 @@
-# Copyright 1999-2016 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id: $
 


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2019-04-17 10:47 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2019-04-17 10:47 UTC (permalink / raw
  To: gentoo-commits

commit:     cb7db35b2863967c327d76b1f8ec4dc77493ed7b
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Apr 17 10:46:33 2019 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Apr 17 10:47:11 2019 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=cb7db35b

Fix mismatched indexes when looping over old impls

Bug: https://bugs.gentoo.org/683178
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 python.eselect.in | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/python.eselect.in b/python.eselect.in
index 8c48b09..98b8cc9 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -182,7 +182,8 @@ do_cleanup() {
 	local prefs=( $(get_all_preferences) )
 
 	local i target_idx
-	for (( i = 0; i < ${#prefs[@]}; ++i )); do
+	local num_prefs=${#prefs[@]}
+	for (( i = 0; i < num_prefs; ++i )); do
 		# remove preferences for uninstalled interpreters
 		if ! has "${prefs[i]#-}" "${installed[@]}"; then
 			unset 'prefs[i]'
@@ -419,7 +420,8 @@ do_set() {
 	local prefs=( $(get_all_preferences) )
 
 	local i target_idx
-	for (( i = 0; i < ${#prefs[@]}; ++i )); do
+	local num_prefs=${#prefs[@]}
+	for (( i = 0; i < num_prefs; ++i )); do
 		# find first positive preference matching the filter
 		if [[ ! ${target_idx} ]]; then
 			if [[ ( ${filter} == --py? && ${prefs[i]} == python${filter:4}* ) \
@@ -433,7 +435,7 @@ do_set() {
 		[[ ${prefs[i]#-} == ${target} ]] && unset 'prefs[i]'
 	done
 	# if none matched, add to the bottom
-	: "${target_idx=${#prefs[@]}}"
+	: "${target_idx=${num_prefs}}"
 
 	# add between remaining preferences, before the one matching
 	# need to do this outta loop in case no pref matches


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2019-04-17 12:26 Michał Górny
  0 siblings, 0 replies; 39+ messages in thread
From: Michał Górny @ 2019-04-17 12:26 UTC (permalink / raw
  To: gentoo-commits

commit:     3b84419cf67d31b97c9b6b56184c2fd73df70dfe
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Apr 17 12:24:25 2019 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Apr 17 12:24:25 2019 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=3b84419c

Bump version to 20190417

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index e67babb..91cc7af 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([eselect-python], [20171204])
+AC_INIT([eselect-python], [20190417])
 AM_INIT_AUTOMAKE([-Wall foreign no-dist-gzip dist-bzip2])
 
 # Create output files.


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2020-07-19 20:20 Patrick McLean
  0 siblings, 0 replies; 39+ messages in thread
From: Patrick McLean @ 2020-07-19 20:20 UTC (permalink / raw
  To: gentoo-commits

commit:     e1e4f5df30ab46a3787f4cdfb4a6092c2a3544d2
Author:     Patrick McLean <chutzpah <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 19 19:26:39 2020 +0000
Commit:     Patrick McLean <chutzpah <AT> gentoo <DOT> org>
CommitDate: Sun Jul 19 19:45:34 2020 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=e1e4f5df

Handle zstd man pages, use .so format rather than a symlink

Handling removing .zst{,d} compressed man pages. Move to using .so reference
rather than a symlink to have "man python" point to the right implementation.

Signed-off-by: Patrick McLean <chutzpah <AT> gentoo.org>

 python.eselect.in | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/python.eselect.in b/python.eselect.in
index 98b8cc9..5fa0fb1 100644
--- a/python.eselect.in
+++ b/python.eselect.in
@@ -111,23 +111,10 @@ write_preferences() {
 
 # Set a man page symlink
 set_man_symlink() {
-	local target=${1} x suffix
-
-	rm -f "${MAN_PATH}"/python.1{,.gz,.bz2,.lzma,.xz,.lz} || die
-
-	for x in .1{,.gz,.bz2,.lzma,.xz,.lz}; do
-		if [[ -e "${MAN_PATH}/${target}${x}" ]]; then
-			suffix=${x}
-			break
-		fi
-	done
-
-	if [[ ! ${suffix} ]]; then
-		echo "Couldn't find a man page for ${target}; skipping." 1>&2
-		return 1
-	fi
+	local target=${1}
 
-	ln -nfs "${target}${suffix}" "${MAN_PATH}/python${suffix}" || die
+	rm -f "${MAN_PATH}"/python.1{,.{gz,bz2,lzma,xz,lz,zst{,d}}} || die
+	echo ".so ${target}.1" > "${MAN_PATH}"/python.1 || die
 }
 
 # Set OSX framework symlinks


^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [gentoo-commits] proj/eselect-python:master commit in: /
@ 2020-07-19 20:20 Patrick McLean
  0 siblings, 0 replies; 39+ messages in thread
From: Patrick McLean @ 2020-07-19 20:20 UTC (permalink / raw
  To: gentoo-commits

commit:     054104e864fc1ccacef3a7bbc151b423ae5debb6
Author:     Patrick McLean <chutzpah <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 19 19:46:57 2020 +0000
Commit:     Patrick McLean <chutzpah <AT> gentoo <DOT> org>
CommitDate: Sun Jul 19 20:20:31 2020 +0000
URL:        https://gitweb.gentoo.org/proj/eselect-python.git/commit/?id=054104e8

Bump version to 20200719

Signed-off-by: Patrick McLean <chutzpah <AT> gentoo.org>

 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 91cc7af..001a2ca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([eselect-python], [20190417])
+AC_INIT([eselect-python], [20200719])
 AM_INIT_AUTOMAKE([-Wall foreign no-dist-gzip dist-bzip2])
 
 # Create output files.


^ permalink raw reply related	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2020-07-19 20:21 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-06 21:30 [gentoo-commits] proj/eselect-python:master commit in: / Michał Górny
  -- strict thread matches above, loose matches on Subject: below --
2020-07-19 20:20 Patrick McLean
2020-07-19 20:20 Patrick McLean
2019-04-17 12:26 Michał Górny
2019-04-17 10:47 Michał Górny
2017-12-04 17:32 Michał Górny
2017-12-03 13:24 Michał Górny
2017-12-03 13:23 Michał Górny
2017-12-03 12:20 Michał Górny
2016-08-03 15:44 Mike Gilbert
2016-05-16 18:04 Michał Górny
2016-05-16 16:47 Michał Górny
2016-05-16 16:38 Michał Górny
2016-05-16 16:38 Michał Górny
2016-02-28 17:03 Michał Górny
2016-02-28 17:03 Michał Górny
2016-02-23 22:16 Michał Górny
2016-02-22 21:41 Michał Górny
2016-02-22 21:41 Michał Górny
2016-02-22 21:41 Michał Górny
2016-02-06 21:30 Michał Górny
2016-02-06 21:30 Michał Górny
2016-02-06 21:30 Michał Górny
2016-02-06  9:50 Michał Górny
2016-02-06  9:49 Michał Górny
2016-02-06  9:29 Michał Górny
2016-02-06  9:00 Michał Górny
2016-02-05 20:36 [gentoo-commits] proj/eselect-python:pyexec-2.3 " Michał Górny
2016-02-06  9:00 ` [gentoo-commits] proj/eselect-python:master " Michał Górny
2016-02-05 20:36 [gentoo-commits] proj/eselect-python:pyexec-2.3 " Michał Górny
2016-02-06  9:00 ` [gentoo-commits] proj/eselect-python:master " Michał Górny
2015-11-17 18:43 Michał Górny
2015-11-17 18:36 Michał Górny
2015-11-17 18:36 Michał Górny
2015-11-17 18:36 Michał Górny
2015-11-12 16:53 [gentoo-commits] proj/eselect-python:mgornys-hackery " Michał Górny
2015-11-17 18:36 ` [gentoo-commits] proj/eselect-python:master " Michał Górny
2014-01-25 17:04 Mike Gilbert
2014-01-19  8:33 Mike Gilbert
2014-01-19  1:57 Mike Gilbert
2014-01-19  1:57 Mike Gilbert
2013-12-09 18:52 Mike Gilbert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox