public inbox for gentoo-python@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-python] Clean up of python eclasses and support for python-exec:2
@ 2013-09-13 18:58 Michał Górny
  2013-09-13 18:58 ` [gentoo-python] [PATCH 1/8] Add PYTHON_SCRIPTDIR for script installation path Michał Górny
                   ` (8 more replies)
  0 siblings, 9 replies; 20+ messages in thread
From: Michał Górny @ 2013-09-13 18:58 UTC (permalink / raw
  To: gentoo-python; +Cc: python

Hello, folks.

I'm sending a new patch batch aimed at python-exec:2 support. First 7
patches do a generic cleanup and add support facilities that are going
to help supporting both versions of python-exec. The last commit adds
actual python-exec:2 support.

You can find those patches applied at my gx86-working tree repo,
python-script-location-r3 branch:

https://bitbucket.org/mgorny/gx86-working-tree/commits/branch/python-script-location-r3

Please review, test and approve.



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

* [gentoo-python] [PATCH 1/8] Add PYTHON_SCRIPTDIR for script installation path.
  2013-09-13 18:58 [gentoo-python] Clean up of python eclasses and support for python-exec:2 Michał Górny
@ 2013-09-13 18:58 ` Michał Górny
  2013-09-13 18:58 ` [gentoo-python] [PATCH 2/8] Clean up python_replicate_script() Michał Górny
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 20+ messages in thread
From: Michał Górny @ 2013-09-13 18:58 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

---
 gx86/eclass/python-utils-r1.eclass   | 30 ++++++++++++++++++++++++++++++
 gx86/eclass/tests/python-utils-r1.sh |  4 ++++
 2 files changed, 34 insertions(+)

diff --git a/gx86/eclass/python-utils-r1.eclass b/gx86/eclass/python-utils-r1.eclass
index 3a1c4ee..6cc07bd 100644
--- a/gx86/eclass/python-utils-r1.eclass
+++ b/gx86/eclass/python-utils-r1.eclass
@@ -195,6 +195,18 @@ _python_impl_supported() {
 # dev-lang/python:2.7[xml]
 # @CODE
 
+# @ECLASS-VARIABLE: PYTHON_SCRIPTDIR
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# The location where Python scripts must be installed for current impl.
+#
+# Set and exported on request using python_export().
+#
+# Example value:
+# @CODE
+# /usr/lib/python-exec/python2.7
+# @CODE
+
 # @FUNCTION: python_export
 # @USAGE: [<impl>] <variables>...
 # @DESCRIPTION:
@@ -359,6 +371,11 @@ python_export() {
 				export PYTHON_PKG_DEP
 				debug-print "${FUNCNAME}: PYTHON_PKG_DEP = ${PYTHON_PKG_DEP}"
 				;;
+			PYTHON_SCRIPTDIR)
+				local dir
+				export PYTHON_SCRIPTDIR=${EPREFIX}/usr/lib/python-exec/${impl}
+				debug-print "${FUNCNAME}: PYTHON_SCRIPTDIR = ${PYTHON_SCRIPTDIR}"
+				;;
 			*)
 				die "python_export: unknown variable ${var}"
 		esac
@@ -475,6 +492,19 @@ python_get_LIBS() {
 	echo "${PYTHON_LIBS}"
 }
 
+# @FUNCTION: python_get_scriptdir
+# @USAGE: [<impl>]
+# @DESCRIPTION:
+# Obtain and print the script install path for the given
+# implementation. If no implementation is provided, ${EPYTHON} will
+# be used.
+python_get_scriptdir() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	python_export "${@}" PYTHON_SCRIPTDIR
+	echo "${PYTHON_SCRIPTDIR}"
+}
+
 # @FUNCTION: _python_rewrite_shebang
 # @USAGE: [<EPYTHON>] <path>...
 # @INTERNAL
diff --git a/gx86/eclass/tests/python-utils-r1.sh b/gx86/eclass/tests/python-utils-r1.sh
index d4f8dae..1e8fe1a 100755
--- a/gx86/eclass/tests/python-utils-r1.sh
+++ b/gx86/eclass/tests/python-utils-r1.sh
@@ -38,6 +38,7 @@ test_var PYTHON_SITEDIR python2_7 /usr/lib/python2.7/site-packages
 test_var PYTHON_INCLUDEDIR python2_7 /usr/include/python2.7
 test_var PYTHON_LIBPATH python2_7 /usr/lib/libpython2.7$(get_libname)
 test_var PYTHON_PKG_DEP python2_7 dev-lang/python:2.7
+test_var PYTHON_SCRIPTDIR python2_7 /usr/lib/python-exec/python2.7
 
 test_var EPYTHON python3_3 python3.3
 test_var PYTHON python3_3 /usr/bin/python3.3
@@ -45,17 +46,20 @@ test_var PYTHON_SITEDIR python3_3 /usr/lib/python3.3/site-packages
 test_var PYTHON_INCLUDEDIR python3_3 /usr/include/python3.3
 test_var PYTHON_LIBPATH python3_3 /usr/lib/libpython3.3$(get_libname)
 test_var PYTHON_PKG_DEP python3_3 dev-lang/python:3.3
+test_var PYTHON_SCRIPTDIR python3_3 /usr/lib/python-exec/python3.3
 
 test_var EPYTHON jython2_7 jython2.7
 test_var PYTHON jython2_7 /usr/bin/jython2.7
 test_var PYTHON_SITEDIR jython2_7 /usr/share/jython-2.7/Lib/site-packages
 test_var PYTHON_PKG_DEP jython2_7 dev-java/jython:2.7
+test_var PYTHON_SCRIPTDIR jython2_7 /usr/lib/python-exec/jython2.7
 
 test_var EPYTHON pypy2_0 pypy-c2.0
 test_var PYTHON pypy2_0 /usr/bin/pypy-c2.0
 test_var PYTHON_SITEDIR pypy2_0 /usr/lib/pypy2.0/site-packages
 test_var PYTHON_INCLUDEDIR pypy2_0 /usr/lib/pypy2.0/include
 test_var PYTHON_PKG_DEP pypy2_0 virtual/pypy:2.0
+test_var PYTHON_SCRIPTDIR pypy2_0 /usr/lib/python-exec/pypy-c2.0
 
 test_is python_is_python3 python2.7 1
 test_is python_is_python3 python3.2 0
-- 
1.8.3.2



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

* [gentoo-python] [PATCH 2/8] Clean up python_replicate_script().
  2013-09-13 18:58 [gentoo-python] Clean up of python eclasses and support for python-exec:2 Michał Górny
  2013-09-13 18:58 ` [gentoo-python] [PATCH 1/8] Add PYTHON_SCRIPTDIR for script installation path Michał Górny
@ 2013-09-13 18:58 ` Michał Górny
  2013-09-15 17:11   ` [gentoo-python] " Mike Gilbert
  2013-09-13 18:58 ` [gentoo-python] [PATCH 3/8] Clean up python_newscript() Michał Górny
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 20+ messages in thread
From: Michał Górny @ 2013-09-13 18:58 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

---
 gx86/eclass/python-r1.eclass | 30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass
index 6994952..e006744 100644
--- a/gx86/eclass/python-r1.eclass
+++ b/gx86/eclass/python-r1.eclass
@@ -741,28 +741,22 @@ python_export_best() {
 python_replicate_script() {
 	debug-print-function ${FUNCNAME} "${@}"
 
-	local suffixes=()
-
-	_add_suffix() {
-		suffixes+=( "${EPYTHON}" )
-	}
-	python_foreach_impl _add_suffix
-	debug-print "${FUNCNAME}: suffixes = ( ${suffixes[@]} )"
-
-	local f suffix
-	for suffix in "${suffixes[@]}"; do
-		for f; do
-			local newf=${f}-${suffix}
-
-			debug-print "${FUNCNAME}: ${f} -> ${newf}"
-			cp "${f}" "${newf}" || die
+	_python_replicate_script() {
+		local f
+		for f in "${files[@]}"; do
+			cp -p "${f}" "${f}-${EPYTHON}" || die
 		done
+		_python_rewrite_shebang "${EPYTHON}" \
+			"${files[@]/%/-${EPYTHON}}"
+	}
 
-		_python_rewrite_shebang "${suffix}" "${@/%/-${suffix}}"
-	done
+	local files=( "${@}" )
+	python_foreach_impl _python_replicate_script
 
+	# install the wrappers
+	local f
 	for f; do
-		_python_ln_rel "${ED}"/usr/bin/python-exec "${f}" || die
+		_python_ln_rel "${ED%/}"/usr/bin/python-exec "${f}" || die
 	done
 }
 
-- 
1.8.3.2



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

* [gentoo-python] [PATCH 3/8] Clean up python_newscript().
  2013-09-13 18:58 [gentoo-python] Clean up of python eclasses and support for python-exec:2 Michał Górny
  2013-09-13 18:58 ` [gentoo-python] [PATCH 1/8] Add PYTHON_SCRIPTDIR for script installation path Michał Górny
  2013-09-13 18:58 ` [gentoo-python] [PATCH 2/8] Clean up python_replicate_script() Michał Górny
@ 2013-09-13 18:58 ` Michał Górny
  2013-09-13 18:58 ` [gentoo-python] [PATCH 4/8] distutils-r1: rework script install/wrapping Michał Górny
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 20+ messages in thread
From: Michał Górny @ 2013-09-13 18:58 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

---
 gx86/eclass/python-utils-r1.eclass | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/gx86/eclass/python-utils-r1.eclass b/gx86/eclass/python-utils-r1.eclass
index 6cc07bd..6cf23f0 100644
--- a/gx86/eclass/python-utils-r1.eclass
+++ b/gx86/eclass/python-utils-r1.eclass
@@ -756,22 +756,21 @@ python_newscript() {
 	[[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>"
 
 	local d=${python_scriptroot:-${DESTTREE}/bin}
-	local INSDESTTREE INSOPTIONS
-
-	insinto "${d}"
-	insopts -m755
 
 	local f=${1}
 	local barefn=${2}
 
 	local newfn=${barefn}-${EPYTHON}
 
-	debug-print "${FUNCNAME}: ${f} -> ${d}/${newfn}"
-	newins "${f}" "${newfn}" || die
-	_python_rewrite_shebang "${ED}/${d}/${newfn}"
+	(
+		exeinto "${d}"
+		newexe "${f}" "${newfn}" || die
+	)
+	_python_rewrite_shebang "${ED%/}/${d}/${newfn}"
 
 	# install the wrapper
-	_python_ln_rel "${ED}"/usr/bin/python-exec "${ED}/${d}/${barefn}" || die
+	_python_ln_rel "${ED%/}"/usr/bin/python-exec \
+		"${ED%/}/${d}/${barefn}" || die
 }
 
 # @ECLASS-VARIABLE: python_moduleroot
-- 
1.8.3.2



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

* [gentoo-python] [PATCH 4/8] distutils-r1: rework script install/wrapping.
  2013-09-13 18:58 [gentoo-python] Clean up of python eclasses and support for python-exec:2 Michał Górny
                   ` (2 preceding siblings ...)
  2013-09-13 18:58 ` [gentoo-python] [PATCH 3/8] Clean up python_newscript() Michał Górny
@ 2013-09-13 18:58 ` Michał Górny
  2013-09-13 18:58 ` [gentoo-python] [PATCH 5/8] distutils-r1: disable sub-root merging Michał Górny
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 20+ messages in thread
From: Michał Górny @ 2013-09-13 18:58 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

Now scripts are installed to ${PYTHON_SCRIPTDIR} initially, and then are
moved to /usr/bin.
---
 gx86/eclass/distutils-r1.eclass | 47 +++++++++++++++++++++++++----------------
 1 file changed, 29 insertions(+), 18 deletions(-)

diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
index c2872b3..7102c58 100644
--- a/gx86/eclass/distutils-r1.eclass
+++ b/gx86/eclass/distutils-r1.eclass
@@ -409,39 +409,43 @@ distutils-r1_python_test() {
 	:
 }
 
-# @FUNCTION: _distutils-r1_rename_scripts
+# @FUNCTION: _distutils-r1_wrap_scripts
 # @USAGE: <path>
 # @INTERNAL
 # @DESCRIPTION:
-# Renames installed Python scripts to be implementation-suffixed.
-# ${EPYTHON} needs to be set to the implementation name.
-#
-# All executable scripts having shebang referencing ${EPYTHON}
-# in given path will be renamed.
-_distutils-r1_rename_scripts() {
+# Moves and wraps all Python scripts installed to PYTHON_SCRIPTDIR
+# as necessary.
+_distutils-r1_wrap_scripts() {
 	debug-print-function ${FUNCNAME} "${@}"
 
 	local path=${1}
 	[[ ${path} ]] || die "${FUNCNAME}: no path given"
 
+	mkdir -p "${path}/usr/bin" || die
 	local f
 	while IFS= read -r -d '' f; do
-		debug-print "${FUNCNAME}: found executable at ${f#${D}/}"
+		local basename=${f##*/}
+		debug-print "${FUNCNAME}: found executable at ${f#${path}/}"
 
 		local shebang
 		read -r shebang < "${f}"
-		if [[ ${shebang} == '#!'*${EPYTHON}* ]]
-		then
+		if [[ ${shebang} == '#!'*${EPYTHON}* ]]; then
 			debug-print "${FUNCNAME}: matching shebang: ${shebang}"
 
-			local newf=${f}-${EPYTHON}
-			debug-print "${FUNCNAME}: renaming to ${newf#${D}/}"
-			mv "${f}" "${newf}" || die
+			local newfn=${basename}-${EPYTHON}
+			debug-print "${FUNCNAME}: renaming to /usr/bin/${newfn}"
+			mv "${f}" "${ED%/}/usr/bin/${newfn}" || die
+
+			debug-print "${FUNCNAME}: installing wrapper at /usr/bin/${basename}"
+			_python_ln_rel "${path}${EPREFIX}"/usr/bin/python-exec \
+				"${path}${EPREFIX}/usr/bin/${basename}" || die
+		else
+			debug-print "${FUNCNAME}: non-matching shebang: ${shebang}"
 
-			debug-print "${FUNCNAME}: installing wrapper at ${f#${D}/}"
-			_python_ln_rel "${path}${EPREFIX}"/usr/bin/python-exec "${f}" || die
+			debug-print "${FUNCNAME}: moving to /usr/bin/${basename}"
+			mv "${f}" "${ED%/}/usr/bin/${basename}" || die
 		fi
-	done < <(find "${path}" -type f -executable -print0)
+	done < <(find "${path}/${PYTHON_SCRIPTDIR}" -type f -print0)
 }
 
 # @FUNCTION: distutils-r1_python_install
@@ -474,15 +478,22 @@ distutils-r1_python_install() {
 
 	local root=${D}/_${EPYTHON}
 	[[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D}
+	flags+=( --root="${root}" )
+
+	if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
+		local PYTHON_SCRIPTDIR
+		python_export PYTHON_SCRIPTDIR
+		flags+=( --install-scripts="${PYTHON_SCRIPTDIR}" )
+	fi
 
-	esetup.py install "${flags[@]}" --root="${root}" "${@}"
+	esetup.py install "${flags[@]}" "${@}"
 
 	if [[ -d ${root}$(python_get_sitedir)/tests ]]; then
 		die "Package installs 'tests' package, file collisions likely."
 	fi
 
 	if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
-		_distutils-r1_rename_scripts "${root}"
+		_distutils-r1_wrap_scripts "${root}"
 		multibuild_merge_root "${root}" "${D}"
 	fi
 }
-- 
1.8.3.2



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

* [gentoo-python] [PATCH 5/8] distutils-r1: disable sub-root merging.
  2013-09-13 18:58 [gentoo-python] Clean up of python eclasses and support for python-exec:2 Michał Górny
                   ` (3 preceding siblings ...)
  2013-09-13 18:58 ` [gentoo-python] [PATCH 4/8] distutils-r1: rework script install/wrapping Michał Górny
@ 2013-09-13 18:58 ` Michał Górny
  2013-09-14 22:16   ` [gentoo-python] " Mike Gilbert
  2013-09-13 18:58 ` [gentoo-python] [PATCH 6/8] _distutils-r1_wrap_scripts(): do not pass root path explicitly Michał Górny
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 20+ messages in thread
From: Michał Górny @ 2013-09-13 18:58 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

The sub-roots are no longer necessary since we're installing scripts to
per-impl directories initially.
---
 gx86/eclass/distutils-r1.eclass | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
index 7102c58..5fcb55e 100644
--- a/gx86/eclass/distutils-r1.eclass
+++ b/gx86/eclass/distutils-r1.eclass
@@ -476,9 +476,7 @@ distutils-r1_python_install() {
 	addpredict "$(python_get_sitedir)"
 	addpredict /usr/lib/portage/pym
 
-	local root=${D}/_${EPYTHON}
-	[[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D}
-	flags+=( --root="${root}" )
+	flags+=( --root="${D}" )
 
 	if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
 		local PYTHON_SCRIPTDIR
@@ -488,13 +486,12 @@ distutils-r1_python_install() {
 
 	esetup.py install "${flags[@]}" "${@}"
 
-	if [[ -d ${root}$(python_get_sitedir)/tests ]]; then
+	if [[ -d ${D}$(python_get_sitedir)/tests ]]; then
 		die "Package installs 'tests' package, file collisions likely."
 	fi
 
 	if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
-		_distutils-r1_wrap_scripts "${root}"
-		multibuild_merge_root "${root}" "${D}"
+		_distutils-r1_wrap_scripts "${D}"
 	fi
 }
 
-- 
1.8.3.2



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

* [gentoo-python] [PATCH 6/8] _distutils-r1_wrap_scripts(): do not pass root path explicitly.
  2013-09-13 18:58 [gentoo-python] Clean up of python eclasses and support for python-exec:2 Michał Górny
                   ` (4 preceding siblings ...)
  2013-09-13 18:58 ` [gentoo-python] [PATCH 5/8] distutils-r1: disable sub-root merging Michał Górny
@ 2013-09-13 18:58 ` Michał Górny
  2013-09-13 18:58 ` [gentoo-python] [PATCH 7/8] Replace _python_ln_rel() with _python_symlink_wrapper() Michał Górny
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 20+ messages in thread
From: Michał Górny @ 2013-09-13 18:58 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

---
 gx86/eclass/distutils-r1.eclass | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
index 5fcb55e..7b119bf 100644
--- a/gx86/eclass/distutils-r1.eclass
+++ b/gx86/eclass/distutils-r1.eclass
@@ -410,7 +410,6 @@ distutils-r1_python_test() {
 }
 
 # @FUNCTION: _distutils-r1_wrap_scripts
-# @USAGE: <path>
 # @INTERNAL
 # @DESCRIPTION:
 # Moves and wraps all Python scripts installed to PYTHON_SCRIPTDIR
@@ -418,14 +417,11 @@ distutils-r1_python_test() {
 _distutils-r1_wrap_scripts() {
 	debug-print-function ${FUNCNAME} "${@}"
 
-	local path=${1}
-	[[ ${path} ]] || die "${FUNCNAME}: no path given"
-
-	mkdir -p "${path}/usr/bin" || die
+	mkdir -p "${ED}/usr/bin" || die
 	local f
 	while IFS= read -r -d '' f; do
 		local basename=${f##*/}
-		debug-print "${FUNCNAME}: found executable at ${f#${path}/}"
+		debug-print "${FUNCNAME}: found executable at ${f#${D%/}}"
 
 		local shebang
 		read -r shebang < "${f}"
@@ -437,15 +433,15 @@ _distutils-r1_wrap_scripts() {
 			mv "${f}" "${ED%/}/usr/bin/${newfn}" || die
 
 			debug-print "${FUNCNAME}: installing wrapper at /usr/bin/${basename}"
-			_python_ln_rel "${path}${EPREFIX}"/usr/bin/python-exec \
-				"${path}${EPREFIX}/usr/bin/${basename}" || die
+			_python_ln_rel "${D}${EPREFIX}"/usr/bin/python-exec \
+				"${ED%/}/usr/bin/${basename}" || die
 		else
 			debug-print "${FUNCNAME}: non-matching shebang: ${shebang}"
 
 			debug-print "${FUNCNAME}: moving to /usr/bin/${basename}"
 			mv "${f}" "${ED%/}/usr/bin/${basename}" || die
 		fi
-	done < <(find "${path}/${PYTHON_SCRIPTDIR}" -type f -print0)
+	done < <(find "${D%/}/${PYTHON_SCRIPTDIR}" -type f -print0)
 }
 
 # @FUNCTION: distutils-r1_python_install
@@ -491,7 +487,7 @@ distutils-r1_python_install() {
 	fi
 
 	if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
-		_distutils-r1_wrap_scripts "${D}"
+		_distutils-r1_wrap_scripts
 	fi
 }
 
-- 
1.8.3.2



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

* [gentoo-python] [PATCH 7/8] Replace _python_ln_rel() with _python_symlink_wrapper().
  2013-09-13 18:58 [gentoo-python] Clean up of python eclasses and support for python-exec:2 Michał Górny
                   ` (5 preceding siblings ...)
  2013-09-13 18:58 ` [gentoo-python] [PATCH 6/8] _distutils-r1_wrap_scripts(): do not pass root path explicitly Michał Górny
@ 2013-09-13 18:58 ` Michał Górny
  2013-09-15 17:27   ` [gentoo-python] " Mike Gilbert
  2013-09-13 18:58 ` [gentoo-python] [PATCH 8/8] Support python-exec:2 Michał Górny
  2013-09-15  9:03 ` [gentoo-python] Clean up of python eclasses and support for python-exec:2, r2 Michał Górny
  8 siblings, 1 reply; 20+ messages in thread
From: Michał Górny @ 2013-09-13 18:58 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

This will allow us to easily avoid repeating path to python-exec.
---
 gx86/eclass/distutils-r1.eclass    |  3 +--
 gx86/eclass/python-r1.eclass       |  2 +-
 gx86/eclass/python-utils-r1.eclass | 19 +++++++++----------
 3 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
index 7b119bf..0517bbb 100644
--- a/gx86/eclass/distutils-r1.eclass
+++ b/gx86/eclass/distutils-r1.eclass
@@ -433,8 +433,7 @@ _distutils-r1_wrap_scripts() {
 			mv "${f}" "${ED%/}/usr/bin/${newfn}" || die
 
 			debug-print "${FUNCNAME}: installing wrapper at /usr/bin/${basename}"
-			_python_ln_rel "${D}${EPREFIX}"/usr/bin/python-exec \
-				"${ED%/}/usr/bin/${basename}" || die
+			_python_symlink_wrapper "${ED%/}/usr/bin/${basename}"
 		else
 			debug-print "${FUNCNAME}: non-matching shebang: ${shebang}"
 
diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass
index e006744..d1b2143 100644
--- a/gx86/eclass/python-r1.eclass
+++ b/gx86/eclass/python-r1.eclass
@@ -756,7 +756,7 @@ python_replicate_script() {
 	# install the wrappers
 	local f
 	for f; do
-		_python_ln_rel "${ED%/}"/usr/bin/python-exec "${f}" || die
+		_python_symlink_wrapper "${f}"
 	done
 }
 
diff --git a/gx86/eclass/python-utils-r1.eclass b/gx86/eclass/python-utils-r1.eclass
index 6cf23f0..dd1ce0b 100644
--- a/gx86/eclass/python-utils-r1.eclass
+++ b/gx86/eclass/python-utils-r1.eclass
@@ -575,16 +575,16 @@ _python_rewrite_shebang() {
 	done
 }
 
-# @FUNCTION: _python_ln_rel
-# @USAGE: <from> <to>
+# @FUNCTION: _python_symlink_wrapper
+# @USAGE: <to>
 # @INTERNAL
 # @DESCRIPTION:
-# Create a relative symlink.
-_python_ln_rel() {
+# Create a relative symlink to the proper version of python-exec.
+_python_symlink_wrapper() {
 	debug-print-function ${FUNCNAME} "${@}"
 
-	local from=${1}
-	local to=${2}
+	local from=${ED%/}/usr/bin/python-exec
+	local to=${1}
 
 	local frpath=${from%/*}/
 	local topath=${to%/*}/
@@ -607,12 +607,12 @@ _python_ln_rel() {
 			rel_path=../${rel_path}${frseg:+${frseg}/}
 		fi
 	done
-	rel_path+=${frpath}${1##*/}
+	rel_path+=${frpath}${from##*/}
 
 	debug-print "${FUNCNAME}: ${from} -> ${to}"
 	debug-print "${FUNCNAME}: rel_path = ${rel_path}"
 
-	ln -fs "${rel_path}" "${to}"
+	ln -fs "${rel_path}" "${to}" || die
 }
 
 # @FUNCTION: python_optimize
@@ -769,8 +769,7 @@ python_newscript() {
 	_python_rewrite_shebang "${ED%/}/${d}/${newfn}"
 
 	# install the wrapper
-	_python_ln_rel "${ED%/}"/usr/bin/python-exec \
-		"${ED%/}/${d}/${barefn}" || die
+	_python_symlink_wrapper "${ED%/}/${d}/${barefn}"
 }
 
 # @ECLASS-VARIABLE: python_moduleroot
-- 
1.8.3.2



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

* [gentoo-python] [PATCH 8/8] Support python-exec:2.
  2013-09-13 18:58 [gentoo-python] Clean up of python eclasses and support for python-exec:2 Michał Górny
                   ` (6 preceding siblings ...)
  2013-09-13 18:58 ` [gentoo-python] [PATCH 7/8] Replace _python_ln_rel() with _python_symlink_wrapper() Michał Górny
@ 2013-09-13 18:58 ` Michał Górny
  2013-09-15  9:03 ` [gentoo-python] Clean up of python eclasses and support for python-exec:2, r2 Michał Górny
  8 siblings, 0 replies; 20+ messages in thread
From: Michał Górny @ 2013-09-13 18:58 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

---
 gx86/eclass/distutils-r1.eclass     |  8 +++++---
 gx86/eclass/python-r1.eclass        | 36 +++++++++++++++++++++++++--------
 gx86/eclass/python-single-r1.eclass |  8 +++++++-
 gx86/eclass/python-utils-r1.eclass  | 40 ++++++++++++++++++++++++++++++++++---
 4 files changed, 77 insertions(+), 15 deletions(-)

diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
index 0517bbb..1e04bd4 100644
--- a/gx86/eclass/distutils-r1.eclass
+++ b/gx86/eclass/distutils-r1.eclass
@@ -428,9 +428,11 @@ _distutils-r1_wrap_scripts() {
 		if [[ ${shebang} == '#!'*${EPYTHON}* ]]; then
 			debug-print "${FUNCNAME}: matching shebang: ${shebang}"
 
-			local newfn=${basename}-${EPYTHON}
-			debug-print "${FUNCNAME}: renaming to /usr/bin/${newfn}"
-			mv "${f}" "${ED%/}/usr/bin/${newfn}" || die
+			if ! _python_want_python_exec2; then
+				local newfn=${basename}-${EPYTHON}
+				debug-print "${FUNCNAME}: renaming to /usr/bin/${newfn}"
+				mv "${f}" "${ED%/}/usr/bin/${newfn}" || die
+			fi
 
 			debug-print "${FUNCNAME}: installing wrapper at /usr/bin/${basename}"
 			_python_symlink_wrapper "${ED%/}/usr/bin/${basename}"
diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass
index d1b2143..f146f91 100644
--- a/gx86/eclass/python-r1.eclass
+++ b/gx86/eclass/python-r1.eclass
@@ -122,7 +122,7 @@ fi
 #
 # Example value:
 # @CODE
-# dev-python/python-exec:0
+# dev-python/python-exec:=
 # python_targets_python2_6? ( dev-lang/python:2.6[gdbm] )
 # python_targets_python2_7? ( dev-lang/python:2.7[gdbm] )
 # @CODE
@@ -203,7 +203,13 @@ _python_set_globals() {
 	# but no point in making this overcomplex, BDEP doesn't hurt anyone
 	# 2) python-exec should be built with all targets forced anyway
 	# but if new targets were added, we may need to force a rebuild
-	PYTHON_DEPS+="dev-python/python-exec:0[${PYTHON_USEDEP}]"
+	# 3) use whichever python-exec slot installed in EAPI 5. For EAPI 4,
+	# just fix :0 for now since := deps are not supported.
+	if [[ ${EAPI} != 4 ]]; then
+		PYTHON_DEPS+="dev-python/python-exec:=[${PYTHON_USEDEP}]"
+	else
+		PYTHON_DEPS+="dev-python/python-exec:0[${PYTHON_USEDEP}]"
+	fi
 }
 _python_set_globals
 
@@ -742,12 +748,26 @@ python_replicate_script() {
 	debug-print-function ${FUNCNAME} "${@}"
 
 	_python_replicate_script() {
-		local f
-		for f in "${files[@]}"; do
-			cp -p "${f}" "${f}-${EPYTHON}" || die
-		done
-		_python_rewrite_shebang "${EPYTHON}" \
-			"${files[@]/%/-${EPYTHON}}"
+		if _python_want_python_exec2; then
+			local PYTHON_SCRIPTDIR
+			python_export PYTHON_SCRIPTDIR
+
+			(
+				exeinto "${PYTHON_SCRIPTDIR#${EPREFIX}}"
+				doexe "${files[@]}"
+			)
+
+			_python_rewrite_shebang "${EPYTHON}" \
+				"${files[@]/*\//${D%/}/${PYTHON_SCRIPTDIR}/}"
+		else
+			local f
+			for f in "${files[@]}"; do
+				cp -p "${f}" "${f}-${EPYTHON}" || die
+			done
+
+			_python_rewrite_shebang "${EPYTHON}" \
+				"${files[@]/%/-${EPYTHON}}"
+		fi
 	}
 
 	local files=( "${@}" )
diff --git a/gx86/eclass/python-single-r1.eclass b/gx86/eclass/python-single-r1.eclass
index 2b099c3..46786ea 100644
--- a/gx86/eclass/python-single-r1.eclass
+++ b/gx86/eclass/python-single-r1.eclass
@@ -193,7 +193,13 @@ _python_single_set_globals() {
 	# but no point in making this overcomplex, BDEP doesn't hurt anyone
 	# 2) python-exec should be built with all targets forced anyway
 	# but if new targets were added, we may need to force a rebuild
-	PYTHON_DEPS+="dev-python/python-exec:0[${PYTHON_USEDEP}]"
+	# 3) use whichever python-exec slot installed in EAPI 5. For EAPI 4,
+	# just fix :0 for now since := deps are not supported.
+	if [[ ${EAPI} != 4 ]]; then
+		PYTHON_DEPS+="dev-python/python-exec:=[${PYTHON_USEDEP}]"
+	else
+		PYTHON_DEPS+="dev-python/python-exec:0[${PYTHON_USEDEP}]"
+	fi
 }
 _python_single_set_globals
 
diff --git a/gx86/eclass/python-utils-r1.eclass b/gx86/eclass/python-utils-r1.eclass
index dd1ce0b..bacfc70 100644
--- a/gx86/eclass/python-utils-r1.eclass
+++ b/gx86/eclass/python-utils-r1.eclass
@@ -583,7 +583,11 @@ _python_rewrite_shebang() {
 _python_symlink_wrapper() {
 	debug-print-function ${FUNCNAME} "${@}"
 
-	local from=${ED%/}/usr/bin/python-exec
+	if _python_want_python_exec2; then
+		local from=${ED%/}/usr/lib/python-exec/python-exec2
+	else
+		local from=${ED%/}/usr/bin/python-exec
+	fi
 	local to=${1}
 
 	local frpath=${from%/*}/
@@ -756,20 +760,30 @@ python_newscript() {
 	[[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>"
 
 	local d=${python_scriptroot:-${DESTTREE}/bin}
+	local wrapd=${d}
 
 	local f=${1}
 	local barefn=${2}
+	local newfn
 
-	local newfn=${barefn}-${EPYTHON}
+	if _python_want_python_exec2; then
+		local PYTHON_SCRIPTDIR
+		python_export PYTHON_SCRIPTDIR
+		d=${PYTHON_SCRIPTDIR#${EPREFIX}}
+		newfn=${barefn}
+	else
+		newfn=${barefn}-${EPYTHON}
+	fi
 
 	(
+		dodir "${wrapd}"
 		exeinto "${d}"
 		newexe "${f}" "${newfn}" || die
 	)
 	_python_rewrite_shebang "${ED%/}/${d}/${newfn}"
 
 	# install the wrapper
-	_python_symlink_wrapper "${ED%/}/${d}/${barefn}"
+	_python_symlink_wrapper "${ED%/}/${wrapd}/${barefn}"
 }
 
 # @ECLASS-VARIABLE: python_moduleroot
@@ -984,5 +998,25 @@ python_is_python3() {
 	[[ ${impl} == python3* ]]
 }
 
+# @FUNCTION: _python_want_python_exec2
+# @INTERNAL
+# @DESCRIPTION:
+# Check whether we should be using python-exec:2.
+_python_want_python_exec2() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	# EAPI 4 lacks slot operators, so just fix it on python-exec:0.
+	[[ ${EAPI} == 4 ]] && return 1
+
+	# Check if we cached the result, or someone put an override.
+	if [[ ! ${_PYTHON_WANT_PYTHON_EXEC2+1} ]]; then
+		has_version 'dev-python/python-exec:2'
+		_PYTHON_WANT_PYTHON_EXEC2=$(( ! ${?} ))
+	fi
+
+	# Non-zero means 'yes', zero means 'no'.
+	[[ ${_PYTHON_WANT_PYTHON_EXEC2} != 0 ]]
+}
+
 _PYTHON_UTILS_R1=1
 fi
-- 
1.8.3.2



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

* [gentoo-python] Re: [PATCH 5/8] distutils-r1: disable sub-root merging.
  2013-09-13 18:58 ` [gentoo-python] [PATCH 5/8] distutils-r1: disable sub-root merging Michał Górny
@ 2013-09-14 22:16   ` Mike Gilbert
  2013-09-14 22:38     ` Michał Górny
  0 siblings, 1 reply; 20+ messages in thread
From: Mike Gilbert @ 2013-09-14 22:16 UTC (permalink / raw
  To: Michał Górny; +Cc: gentoo-python, Gentoo Python Project

On Fri, Sep 13, 2013 at 2:58 PM, Michał Górny <mgorny@gentoo.org> wrote:
> The sub-roots are no longer necessary since we're installing scripts to
> per-impl directories initially.
> ---
>  gx86/eclass/distutils-r1.eclass | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
> index 7102c58..5fcb55e 100644
> --- a/gx86/eclass/distutils-r1.eclass
> +++ b/gx86/eclass/distutils-r1.eclass
> @@ -476,9 +476,7 @@ distutils-r1_python_install() {
>         addpredict "$(python_get_sitedir)"
>         addpredict /usr/lib/portage/pym
>
> -       local root=${D}/_${EPYTHON}
> -       [[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D}
> -       flags+=( --root="${root}" )
> +       flags+=( --root="${D}" )
>
>         if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
>                 local PYTHON_SCRIPTDIR
> @@ -488,13 +486,12 @@ distutils-r1_python_install() {
>
>         esetup.py install "${flags[@]}" "${@}"
>
> -       if [[ -d ${root}$(python_get_sitedir)/tests ]]; then
> +       if [[ -d ${D}$(python_get_sitedir)/tests ]]; then
>                 die "Package installs 'tests' package, file collisions likely."
>         fi
>
>         if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
> -               _distutils-r1_wrap_scripts "${root}"
> -               multibuild_merge_root "${root}" "${D}"
> +               _distutils-r1_wrap_scripts "${D}"
>         fi
>  }
>
> --
> 1.8.3.2
>

I believe this patch causes a race condition which causes
java-config's ebuild to fail.

running install_data
running install_egg_info
Writing /tmp/portage/dev-java/java-config-2.2.0/image/usr/lib64/python2.7/site-packages/java_config-
2.2.0-py2.7.egg-info
error: /tmp/portage/dev-java/java-config-2.2.0/image//usr/share/java-config-2/config/:
File exists


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

* Re: [gentoo-python] Re: [PATCH 5/8] distutils-r1: disable sub-root merging.
  2013-09-14 22:16   ` [gentoo-python] " Mike Gilbert
@ 2013-09-14 22:38     ` Michał Górny
  2013-09-14 23:33       ` Mike Gilbert
  0 siblings, 1 reply; 20+ messages in thread
From: Michał Górny @ 2013-09-14 22:38 UTC (permalink / raw
  To: Mike Gilbert; +Cc: gentoo-python, Gentoo Python Project

[-- Attachment #1: Type: text/plain, Size: 2289 bytes --]

Dnia 2013-09-14, o godz. 18:16:33
Mike Gilbert <floppym@gentoo.org> napisał(a):

> On Fri, Sep 13, 2013 at 2:58 PM, Michał Górny <mgorny@gentoo.org> wrote:
> > The sub-roots are no longer necessary since we're installing scripts to
> > per-impl directories initially.
> > ---
> >  gx86/eclass/distutils-r1.eclass | 9 +++------
> >  1 file changed, 3 insertions(+), 6 deletions(-)
> >
> > diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
> > index 7102c58..5fcb55e 100644
> > --- a/gx86/eclass/distutils-r1.eclass
> > +++ b/gx86/eclass/distutils-r1.eclass
> > @@ -476,9 +476,7 @@ distutils-r1_python_install() {
> >         addpredict "$(python_get_sitedir)"
> >         addpredict /usr/lib/portage/pym
> >
> > -       local root=${D}/_${EPYTHON}
> > -       [[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D}
> > -       flags+=( --root="${root}" )
> > +       flags+=( --root="${D}" )
> >
> >         if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
> >                 local PYTHON_SCRIPTDIR
> > @@ -488,13 +486,12 @@ distutils-r1_python_install() {
> >
> >         esetup.py install "${flags[@]}" "${@}"
> >
> > -       if [[ -d ${root}$(python_get_sitedir)/tests ]]; then
> > +       if [[ -d ${D}$(python_get_sitedir)/tests ]]; then
> >                 die "Package installs 'tests' package, file collisions likely."
> >         fi
> >
> >         if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
> > -               _distutils-r1_wrap_scripts "${root}"
> > -               multibuild_merge_root "${root}" "${D}"
> > +               _distutils-r1_wrap_scripts "${D}"
> >         fi
> >  }
> >
> > --
> > 1.8.3.2
> >
> 
> I believe this patch causes a race condition which causes
> java-config's ebuild to fail.
> 
> running install_data
> running install_egg_info
> Writing /tmp/portage/dev-java/java-config-2.2.0/image/usr/lib64/python2.7/site-packages/java_config-
> 2.2.0-py2.7.egg-info
> error: /tmp/portage/dev-java/java-config-2.2.0/image//usr/share/java-config-2/config/:
> File exists

I love when people hack build systems and have no idea about writing
build systems...

What are you suggesting? Finding all the broken stuff and fixing it, or
restoring sub-roots?

-- 
Best regards,
Michał Górny

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 966 bytes --]

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

* Re: [gentoo-python] Re: [PATCH 5/8] distutils-r1: disable sub-root merging.
  2013-09-14 22:38     ` Michał Górny
@ 2013-09-14 23:33       ` Mike Gilbert
  2013-09-15  9:04         ` Michał Górny
  0 siblings, 1 reply; 20+ messages in thread
From: Mike Gilbert @ 2013-09-14 23:33 UTC (permalink / raw
  To: Michał Górny; +Cc: gentoo-python, Gentoo Python Project

On Sat, Sep 14, 2013 at 6:38 PM, Michał Górny <mgorny@gentoo.org> wrote:
> Dnia 2013-09-14, o godz. 18:16:33
> Mike Gilbert <floppym@gentoo.org> napisał(a):
>
>> On Fri, Sep 13, 2013 at 2:58 PM, Michał Górny <mgorny@gentoo.org> wrote:
>> > The sub-roots are no longer necessary since we're installing scripts to
>> > per-impl directories initially.
>> > ---
>> >  gx86/eclass/distutils-r1.eclass | 9 +++------
>> >  1 file changed, 3 insertions(+), 6 deletions(-)
>> >
>> > diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
>> > index 7102c58..5fcb55e 100644
>> > --- a/gx86/eclass/distutils-r1.eclass
>> > +++ b/gx86/eclass/distutils-r1.eclass
>> > @@ -476,9 +476,7 @@ distutils-r1_python_install() {
>> >         addpredict "$(python_get_sitedir)"
>> >         addpredict /usr/lib/portage/pym
>> >
>> > -       local root=${D}/_${EPYTHON}
>> > -       [[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D}
>> > -       flags+=( --root="${root}" )
>> > +       flags+=( --root="${D}" )
>> >
>> >         if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
>> >                 local PYTHON_SCRIPTDIR
>> > @@ -488,13 +486,12 @@ distutils-r1_python_install() {
>> >
>> >         esetup.py install "${flags[@]}" "${@}"
>> >
>> > -       if [[ -d ${root}$(python_get_sitedir)/tests ]]; then
>> > +       if [[ -d ${D}$(python_get_sitedir)/tests ]]; then
>> >                 die "Package installs 'tests' package, file collisions likely."
>> >         fi
>> >
>> >         if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
>> > -               _distutils-r1_wrap_scripts "${root}"
>> > -               multibuild_merge_root "${root}" "${D}"
>> > +               _distutils-r1_wrap_scripts "${D}"
>> >         fi
>> >  }
>> >
>> > --
>> > 1.8.3.2
>> >
>>
>> I believe this patch causes a race condition which causes
>> java-config's ebuild to fail.
>>
>> running install_data
>> running install_egg_info
>> Writing /tmp/portage/dev-java/java-config-2.2.0/image/usr/lib64/python2.7/site-packages/java_config-
>> 2.2.0-py2.7.egg-info
>> error: /tmp/portage/dev-java/java-config-2.2.0/image//usr/share/java-config-2/config/:
>> File exists
>
> I love when people hack build systems and have no idea about writing
> build systems...
>
> What are you suggesting? Finding all the broken stuff and fixing it, or
> restoring sub-roots?
>

This is a well-used package which will be broken if we apply this
patch. I'm not sure we can reliably identify this kind of problem, and
fixing individual packages would be a bit of work in any case..
Keeping the sub-roots code in place seems like the safer course of
action here.

Also FYI, I looked into java-config's setup.py, and the code has an
unchecked os.mkdir call followed by an open() call. The former will
fail for multiple python implementations even with a serialized
install, and the latter is racy.


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

* [gentoo-python] Clean up of python eclasses and support for python-exec:2, r2
  2013-09-13 18:58 [gentoo-python] Clean up of python eclasses and support for python-exec:2 Michał Górny
                   ` (7 preceding siblings ...)
  2013-09-13 18:58 ` [gentoo-python] [PATCH 8/8] Support python-exec:2 Michał Górny
@ 2013-09-15  9:03 ` Michał Górny
  2013-09-15  9:03   ` [gentoo-python] [PATCH 1/2] distutils-r1: clean up script install/wrapping Michał Górny
  2013-09-15  9:03   ` [gentoo-python] [PATCH 2/2] Support python-exec:2 Michał Górny
  8 siblings, 2 replies; 20+ messages in thread
From: Michał Górny @ 2013-09-15  9:03 UTC (permalink / raw
  To: gentoo-python; +Cc: python

Replacement for patches from 5-8 as suggested by floppym. Not using
--install-scripts immediately should also reduce risk of breakage.



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

* [gentoo-python] [PATCH 1/2] distutils-r1: clean up script install/wrapping.
  2013-09-15  9:03 ` [gentoo-python] Clean up of python eclasses and support for python-exec:2, r2 Michał Górny
@ 2013-09-15  9:03   ` Michał Górny
  2013-09-15  9:03   ` [gentoo-python] [PATCH 2/2] Support python-exec:2 Michał Górny
  1 sibling, 0 replies; 20+ messages in thread
From: Michał Górny @ 2013-09-15  9:03 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

---
 gx86/eclass/distutils-r1.eclass | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
index c2872b3..985e707 100644
--- a/gx86/eclass/distutils-r1.eclass
+++ b/gx86/eclass/distutils-r1.eclass
@@ -409,39 +409,38 @@ distutils-r1_python_test() {
 	:
 }
 
-# @FUNCTION: _distutils-r1_rename_scripts
+# @FUNCTION: _distutils-r1_wrap_scripts
 # @USAGE: <path>
 # @INTERNAL
 # @DESCRIPTION:
-# Renames installed Python scripts to be implementation-suffixed.
-# ${EPYTHON} needs to be set to the implementation name.
-#
-# All executable scripts having shebang referencing ${EPYTHON}
-# in given path will be renamed.
-_distutils-r1_rename_scripts() {
+# Moves and wraps all Python scripts installed to PYTHON_SCRIPTDIR
+# as necessary.
+_distutils-r1_wrap_scripts() {
 	debug-print-function ${FUNCNAME} "${@}"
 
 	local path=${1}
 	[[ ${path} ]] || die "${FUNCNAME}: no path given"
 
+	mkdir -p "${path}/usr/bin" || die
 	local f
 	while IFS= read -r -d '' f; do
-		debug-print "${FUNCNAME}: found executable at ${f#${D}/}"
+		local basename=${f##*/}
+		debug-print "${FUNCNAME}: found executable at ${f#${path}/}"
 
 		local shebang
 		read -r shebang < "${f}"
-		if [[ ${shebang} == '#!'*${EPYTHON}* ]]
-		then
+		if [[ ${shebang} == '#!'*${EPYTHON}* ]]; then
 			debug-print "${FUNCNAME}: matching shebang: ${shebang}"
 
-			local newf=${f}-${EPYTHON}
-			debug-print "${FUNCNAME}: renaming to ${newf#${D}/}"
+			local newf=${f%/*}/${basename}-${EPYTHON}
+			debug-print "${FUNCNAME}: renaming to ${newf#${path}}"
 			mv "${f}" "${newf}" || die
 
-			debug-print "${FUNCNAME}: installing wrapper at ${f#${D}/}"
-			_python_ln_rel "${path}${EPREFIX}"/usr/bin/python-exec "${f}" || die
+			debug-print "${FUNCNAME}: installing wrapper at /usr/bin/${basename}"
+			_python_ln_rel "${path}${EPREFIX}"/usr/bin/python-exec \
+				"${path}${EPREFIX}/usr/bin/${basename}" || die
 		fi
-	done < <(find "${path}" -type f -executable -print0)
+	done < <(find "${path}/usr/bin" -type f -print0)
 }
 
 # @FUNCTION: distutils-r1_python_install
@@ -474,15 +473,16 @@ distutils-r1_python_install() {
 
 	local root=${D}/_${EPYTHON}
 	[[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D}
+	flags+=( --root="${root}" )
 
-	esetup.py install "${flags[@]}" --root="${root}" "${@}"
+	esetup.py install "${flags[@]}" "${@}"
 
 	if [[ -d ${root}$(python_get_sitedir)/tests ]]; then
 		die "Package installs 'tests' package, file collisions likely."
 	fi
 
 	if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
-		_distutils-r1_rename_scripts "${root}"
+		_distutils-r1_wrap_scripts "${root}"
 		multibuild_merge_root "${root}" "${D}"
 	fi
 }
-- 
1.8.3.2



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

* [gentoo-python] [PATCH 2/2] Support python-exec:2.
  2013-09-15  9:03 ` [gentoo-python] Clean up of python eclasses and support for python-exec:2, r2 Michał Górny
  2013-09-15  9:03   ` [gentoo-python] [PATCH 1/2] distutils-r1: clean up script install/wrapping Michał Górny
@ 2013-09-15  9:03   ` Michał Górny
  2013-09-15  9:29     ` Michał Górny
  1 sibling, 1 reply; 20+ messages in thread
From: Michał Górny @ 2013-09-15  9:03 UTC (permalink / raw
  To: gentoo-python; +Cc: python, Michał Górny

---
 gx86/eclass/distutils-r1.eclass     | 28 +++++++++++++++++----
 gx86/eclass/python-r1.eclass        | 38 +++++++++++++++++++++-------
 gx86/eclass/python-single-r1.eclass |  8 +++++-
 gx86/eclass/python-utils-r1.eclass  | 50 ++++++++++++++++++++++++++++++++++---
 4 files changed, 106 insertions(+), 18 deletions(-)

diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
index 985e707..e03e135 100644
--- a/gx86/eclass/distutils-r1.eclass
+++ b/gx86/eclass/distutils-r1.eclass
@@ -421,6 +421,10 @@ _distutils-r1_wrap_scripts() {
 	local path=${1}
 	[[ ${path} ]] || die "${FUNCNAME}: no path given"
 
+	if ! _python_want_python_exec2; then
+		local PYTHON_SCRIPTDIR=${EPREFIX}/usr/bin
+	fi
+
 	mkdir -p "${path}/usr/bin" || die
 	local f
 	while IFS= read -r -d '' f; do
@@ -432,15 +436,22 @@ _distutils-r1_wrap_scripts() {
 		if [[ ${shebang} == '#!'*${EPYTHON}* ]]; then
 			debug-print "${FUNCNAME}: matching shebang: ${shebang}"
 
-			local newf=${f%/*}/${basename}-${EPYTHON}
-			debug-print "${FUNCNAME}: renaming to ${newf#${path}}"
-			mv "${f}" "${newf}" || die
+			if ! _python_want_python_exec2; then
+				local newf=${f%/*}/${basename}-${EPYTHON}
+				debug-print "${FUNCNAME}: renaming to ${newf#${path}}"
+				mv "${f}" "${newf}" || die
+			fi
 
 			debug-print "${FUNCNAME}: installing wrapper at /usr/bin/${basename}"
-			_python_ln_rel "${path}${EPREFIX}"/usr/bin/python-exec \
+			_python_ln_rel "${path}${EPREFIX}"$(_python_get_wrapper_path) \
 				"${path}${EPREFIX}/usr/bin/${basename}" || die
+		elif _python_want_python_exec2; then
+			debug-print "${FUNCNAME}: non-matching shebang: ${shebang}"
+
+			debug-print "${FUNCNAME}: moving to /usr/bin/${basename}"
+			mv "${f}" "${ED%/}/usr/bin/${basename}" || die
 		fi
-	done < <(find "${path}/usr/bin" -type f -print0)
+	done < <(find "${path}${PYTHON_SCRIPTDIR}" -type f -print0)
 }
 
 # @FUNCTION: distutils-r1_python_install
@@ -475,6 +486,13 @@ distutils-r1_python_install() {
 	[[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D}
 	flags+=( --root="${root}" )
 
+	if [[ ! ${DISTUTILS_SINGLE_IMPL} ]] && _python_want_python_exec2
+	then
+		local PYTHON_SCRIPTDIR
+		python_export PYTHON_SCRIPTDIR
+		flags+=( --install-scripts="${PYTHON_SCRIPTDIR}" )
+	fi
+
 	esetup.py install "${flags[@]}" "${@}"
 
 	if [[ -d ${root}$(python_get_sitedir)/tests ]]; then
diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass
index e006744..d80c7b6 100644
--- a/gx86/eclass/python-r1.eclass
+++ b/gx86/eclass/python-r1.eclass
@@ -122,7 +122,7 @@ fi
 #
 # Example value:
 # @CODE
-# dev-python/python-exec:0
+# dev-python/python-exec:=
 # python_targets_python2_6? ( dev-lang/python:2.6[gdbm] )
 # python_targets_python2_7? ( dev-lang/python:2.7[gdbm] )
 # @CODE
@@ -203,7 +203,13 @@ _python_set_globals() {
 	# but no point in making this overcomplex, BDEP doesn't hurt anyone
 	# 2) python-exec should be built with all targets forced anyway
 	# but if new targets were added, we may need to force a rebuild
-	PYTHON_DEPS+="dev-python/python-exec:0[${PYTHON_USEDEP}]"
+	# 3) use whichever python-exec slot installed in EAPI 5. For EAPI 4,
+	# just fix :0 for now since := deps are not supported.
+	if [[ ${EAPI} != 4 ]]; then
+		PYTHON_DEPS+="dev-python/python-exec:=[${PYTHON_USEDEP}]"
+	else
+		PYTHON_DEPS+="dev-python/python-exec:0[${PYTHON_USEDEP}]"
+	fi
 }
 _python_set_globals
 
@@ -742,12 +748,26 @@ python_replicate_script() {
 	debug-print-function ${FUNCNAME} "${@}"
 
 	_python_replicate_script() {
-		local f
-		for f in "${files[@]}"; do
-			cp -p "${f}" "${f}-${EPYTHON}" || die
-		done
-		_python_rewrite_shebang "${EPYTHON}" \
-			"${files[@]/%/-${EPYTHON}}"
+		if _python_want_python_exec2; then
+			local PYTHON_SCRIPTDIR
+			python_export PYTHON_SCRIPTDIR
+
+			(
+				exeinto "${PYTHON_SCRIPTDIR#${EPREFIX}}"
+				doexe "${files[@]}"
+			)
+
+			_python_rewrite_shebang "${EPYTHON}" \
+				"${files[@]/*\//${D%/}/${PYTHON_SCRIPTDIR}/}"
+		else
+			local f
+			for f in "${files[@]}"; do
+				cp -p "${f}" "${f}-${EPYTHON}" || die
+			done
+
+			_python_rewrite_shebang "${EPYTHON}" \
+				"${files[@]/%/-${EPYTHON}}"
+		fi
 	}
 
 	local files=( "${@}" )
@@ -756,7 +776,7 @@ python_replicate_script() {
 	# install the wrappers
 	local f
 	for f; do
-		_python_ln_rel "${ED%/}"/usr/bin/python-exec "${f}" || die
+		_python_ln_rel "${ED%/}$(_python_get_wrapper_path)" "${f}" || die
 	done
 }
 
diff --git a/gx86/eclass/python-single-r1.eclass b/gx86/eclass/python-single-r1.eclass
index 2b099c3..46786ea 100644
--- a/gx86/eclass/python-single-r1.eclass
+++ b/gx86/eclass/python-single-r1.eclass
@@ -193,7 +193,13 @@ _python_single_set_globals() {
 	# but no point in making this overcomplex, BDEP doesn't hurt anyone
 	# 2) python-exec should be built with all targets forced anyway
 	# but if new targets were added, we may need to force a rebuild
-	PYTHON_DEPS+="dev-python/python-exec:0[${PYTHON_USEDEP}]"
+	# 3) use whichever python-exec slot installed in EAPI 5. For EAPI 4,
+	# just fix :0 for now since := deps are not supported.
+	if [[ ${EAPI} != 4 ]]; then
+		PYTHON_DEPS+="dev-python/python-exec:=[${PYTHON_USEDEP}]"
+	else
+		PYTHON_DEPS+="dev-python/python-exec:0[${PYTHON_USEDEP}]"
+	fi
 }
 _python_single_set_globals
 
diff --git a/gx86/eclass/python-utils-r1.eclass b/gx86/eclass/python-utils-r1.eclass
index 6cf23f0..a15a3f3 100644
--- a/gx86/eclass/python-utils-r1.eclass
+++ b/gx86/eclass/python-utils-r1.eclass
@@ -607,7 +607,7 @@ _python_ln_rel() {
 			rel_path=../${rel_path}${frseg:+${frseg}/}
 		fi
 	done
-	rel_path+=${frpath}${1##*/}
+	rel_path+=${frpath}${from##*/}
 
 	debug-print "${FUNCNAME}: ${from} -> ${to}"
 	debug-print "${FUNCNAME}: rel_path = ${rel_path}"
@@ -756,20 +756,30 @@ python_newscript() {
 	[[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>"
 
 	local d=${python_scriptroot:-${DESTTREE}/bin}
+	local wrapd=${d}
 
 	local f=${1}
 	local barefn=${2}
+	local newfn
 
-	local newfn=${barefn}-${EPYTHON}
+	if _python_want_python_exec2; then
+		local PYTHON_SCRIPTDIR
+		python_export PYTHON_SCRIPTDIR
+		d=${PYTHON_SCRIPTDIR#${EPREFIX}}
+		newfn=${barefn}
+	else
+		newfn=${barefn}-${EPYTHON}
+	fi
 
 	(
+		dodir "${wrapd}"
 		exeinto "${d}"
 		newexe "${f}" "${newfn}" || die
 	)
 	_python_rewrite_shebang "${ED%/}/${d}/${newfn}"
 
 	# install the wrapper
-	_python_ln_rel "${ED%/}"/usr/bin/python-exec \
+	_python_ln_rel "${ED%/}"$(_python_get_wrapper_path) \
 		"${ED%/}/${d}/${barefn}" || die
 }
 
@@ -985,5 +995,39 @@ python_is_python3() {
 	[[ ${impl} == python3* ]]
 }
 
+# @FUNCTION: _python_want_python_exec2
+# @INTERNAL
+# @DESCRIPTION:
+# Check whether we should be using python-exec:2.
+_python_want_python_exec2() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	# EAPI 4 lacks slot operators, so just fix it on python-exec:0.
+	[[ ${EAPI} == 4 ]] && return 1
+
+	# Check if we cached the result, or someone put an override.
+	if [[ ! ${_PYTHON_WANT_PYTHON_EXEC2+1} ]]; then
+		has_version 'dev-python/python-exec:2'
+		_PYTHON_WANT_PYTHON_EXEC2=$(( ! ${?} ))
+	fi
+
+	# Non-zero means 'yes', zero means 'no'.
+	[[ ${_PYTHON_WANT_PYTHON_EXEC2} != 0 ]]
+}
+
+# @FUNCTION: _python_get_wrapper_path
+# @INTERNAL
+# @DESCRIPTION:
+# Output path to proper python-exec slot.
+_python_get_wrapper_path() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	if _python_want_python_exec2; then
+		echo /usr/lib/python-exec/python-exec2
+	else
+		echo /usr/bin/python-exec
+	fi
+}
+
 _PYTHON_UTILS_R1=1
 fi
-- 
1.8.3.2



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

* Re: [gentoo-python] Re: [PATCH 5/8] distutils-r1: disable sub-root merging.
  2013-09-14 23:33       ` Mike Gilbert
@ 2013-09-15  9:04         ` Michał Górny
  0 siblings, 0 replies; 20+ messages in thread
From: Michał Górny @ 2013-09-15  9:04 UTC (permalink / raw
  To: Mike Gilbert; +Cc: gentoo-python, Gentoo Python Project

[-- Attachment #1: Type: text/plain, Size: 3068 bytes --]

Dnia 2013-09-14, o godz. 19:33:04
Mike Gilbert <floppym@gentoo.org> napisał(a):

> On Sat, Sep 14, 2013 at 6:38 PM, Michał Górny <mgorny@gentoo.org> wrote:
> > Dnia 2013-09-14, o godz. 18:16:33
> > Mike Gilbert <floppym@gentoo.org> napisał(a):
> >
> >> On Fri, Sep 13, 2013 at 2:58 PM, Michał Górny <mgorny@gentoo.org> wrote:
> >> > The sub-roots are no longer necessary since we're installing scripts to
> >> > per-impl directories initially.
> >> > ---
> >> >  gx86/eclass/distutils-r1.eclass | 9 +++------
> >> >  1 file changed, 3 insertions(+), 6 deletions(-)
> >> >
> >> > diff --git a/gx86/eclass/distutils-r1.eclass b/gx86/eclass/distutils-r1.eclass
> >> > index 7102c58..5fcb55e 100644
> >> > --- a/gx86/eclass/distutils-r1.eclass
> >> > +++ b/gx86/eclass/distutils-r1.eclass
> >> > @@ -476,9 +476,7 @@ distutils-r1_python_install() {
> >> >         addpredict "$(python_get_sitedir)"
> >> >         addpredict /usr/lib/portage/pym
> >> >
> >> > -       local root=${D}/_${EPYTHON}
> >> > -       [[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D}
> >> > -       flags+=( --root="${root}" )
> >> > +       flags+=( --root="${D}" )
> >> >
> >> >         if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
> >> >                 local PYTHON_SCRIPTDIR
> >> > @@ -488,13 +486,12 @@ distutils-r1_python_install() {
> >> >
> >> >         esetup.py install "${flags[@]}" "${@}"
> >> >
> >> > -       if [[ -d ${root}$(python_get_sitedir)/tests ]]; then
> >> > +       if [[ -d ${D}$(python_get_sitedir)/tests ]]; then
> >> >                 die "Package installs 'tests' package, file collisions likely."
> >> >         fi
> >> >
> >> >         if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
> >> > -               _distutils-r1_wrap_scripts "${root}"
> >> > -               multibuild_merge_root "${root}" "${D}"
> >> > +               _distutils-r1_wrap_scripts "${D}"
> >> >         fi
> >> >  }
> >> >
> >> > --
> >> > 1.8.3.2
> >> >
> >>
> >> I believe this patch causes a race condition which causes
> >> java-config's ebuild to fail.
> >>
> >> running install_data
> >> running install_egg_info
> >> Writing /tmp/portage/dev-java/java-config-2.2.0/image/usr/lib64/python2.7/site-packages/java_config-
> >> 2.2.0-py2.7.egg-info
> >> error: /tmp/portage/dev-java/java-config-2.2.0/image//usr/share/java-config-2/config/:
> >> File exists
> >
> > I love when people hack build systems and have no idea about writing
> > build systems...
> >
> > What are you suggesting? Finding all the broken stuff and fixing it, or
> > restoring sub-roots?
> 
> This is a well-used package which will be broken if we apply this
> patch. I'm not sure we can reliably identify this kind of problem, and
> fixing individual packages would be a bit of work in any case..
> Keeping the sub-roots code in place seems like the safer course of
> action here.

You're right. Replaced 5-8 with two smaller patches and submitted
in a new sub-thread here. You can also find it in -r4 branch.

-- 
Best regards,
Michał Górny

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 966 bytes --]

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

* Re: [gentoo-python] [PATCH 2/2] Support python-exec:2.
  2013-09-15  9:03   ` [gentoo-python] [PATCH 2/2] Support python-exec:2 Michał Górny
@ 2013-09-15  9:29     ` Michał Górny
  0 siblings, 0 replies; 20+ messages in thread
From: Michał Górny @ 2013-09-15  9:29 UTC (permalink / raw
  To: Michał Górny; +Cc: gentoo-python, python

[-- Attachment #1: Type: text/plain, Size: 1047 bytes --]

Minor fix:

Dnia 2013-09-15, o godz. 11:03:26
Michał Górny <mgorny@gentoo.org> napisał(a):

> @@ -756,20 +756,30 @@ python_newscript() {
>  	[[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>"
>  
>  	local d=${python_scriptroot:-${DESTTREE}/bin}
> +	local wrapd=${d}
>  
>  	local f=${1}
>  	local barefn=${2}
> +	local newfn
>  
> -	local newfn=${barefn}-${EPYTHON}
> +	if _python_want_python_exec2; then
> +		local PYTHON_SCRIPTDIR
> +		python_export PYTHON_SCRIPTDIR
> +		d=${PYTHON_SCRIPTDIR#${EPREFIX}}
> +		newfn=${barefn}
> +	else
> +		newfn=${barefn}-${EPYTHON}
> +	fi
>  
>  	(
> +		dodir "${wrapd}"
>  		exeinto "${d}"
>  		newexe "${f}" "${newfn}" || die
>  	)
>  	_python_rewrite_shebang "${ED%/}/${d}/${newfn}"
>  
>  	# install the wrapper
> -	_python_ln_rel "${ED%/}"/usr/bin/python-exec \
> +	_python_ln_rel "${ED%/}"$(_python_get_wrapper_path) \
>  		"${ED%/}/${d}/${barefn}" || die
                         ^^^^ ${wrapd} needs to go here.

-- 
Best regards,
Michał Górny

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 966 bytes --]

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

* [gentoo-python] Re: [PATCH 2/8] Clean up python_replicate_script().
  2013-09-13 18:58 ` [gentoo-python] [PATCH 2/8] Clean up python_replicate_script() Michał Górny
@ 2013-09-15 17:11   ` Mike Gilbert
  2013-09-15 17:36     ` Michał Górny
  0 siblings, 1 reply; 20+ messages in thread
From: Mike Gilbert @ 2013-09-15 17:11 UTC (permalink / raw
  To: Michał Górny; +Cc: gentoo-python, Gentoo Python Project

On Fri, Sep 13, 2013 at 2:58 PM, Michał Górny <mgorny@gentoo.org> wrote:
> ---
>  gx86/eclass/python-r1.eclass | 30 ++++++++++++------------------
>  1 file changed, 12 insertions(+), 18 deletions(-)
>
> diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass
> index 6994952..e006744 100644
> --- a/gx86/eclass/python-r1.eclass
> +++ b/gx86/eclass/python-r1.eclass
> @@ -741,28 +741,22 @@ python_export_best() {
>  python_replicate_script() {
>         debug-print-function ${FUNCNAME} "${@}"
>
> -       local suffixes=()
> -
> -       _add_suffix() {
> -               suffixes+=( "${EPYTHON}" )
> -       }
> -       python_foreach_impl _add_suffix
> -       debug-print "${FUNCNAME}: suffixes = ( ${suffixes[@]} )"
> -
> -       local f suffix
> -       for suffix in "${suffixes[@]}"; do
> -               for f; do
> -                       local newf=${f}-${suffix}
> -
> -                       debug-print "${FUNCNAME}: ${f} -> ${newf}"
> -                       cp "${f}" "${newf}" || die
> +       _python_replicate_script() {
> +               local f
> +               for f in "${files[@]}"; do
> +                       cp -p "${f}" "${f}-${EPYTHON}" || die
>                 done
> +               _python_rewrite_shebang "${EPYTHON}" \
> +                       "${files[@]/%/-${EPYTHON}}"
> +       }
>
> -               _python_rewrite_shebang "${suffix}" "${@/%/-${suffix}}"
> -       done
> +       local files=( "${@}" )
> +       python_foreach_impl _python_replicate_script

Why are we creating a new array variable here? Why not just pass $@ to
_python_replicate script as arguments?

>
> +       # install the wrappers
> +       local f
>         for f; do
> -               _python_ln_rel "${ED}"/usr/bin/python-exec "${f}" || die
> +               _python_ln_rel "${ED%/}"/usr/bin/python-exec "${f}" || die
>         done
>  }
>
> --
> 1.8.3.2
>


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

* [gentoo-python] Re: [PATCH 7/8] Replace _python_ln_rel() with _python_symlink_wrapper().
  2013-09-13 18:58 ` [gentoo-python] [PATCH 7/8] Replace _python_ln_rel() with _python_symlink_wrapper() Michał Górny
@ 2013-09-15 17:27   ` Mike Gilbert
  0 siblings, 0 replies; 20+ messages in thread
From: Mike Gilbert @ 2013-09-15 17:27 UTC (permalink / raw
  To: Michał Górny; +Cc: gentoo-python, Gentoo Python Project

On Fri, Sep 13, 2013 at 2:58 PM, Michał Górny <mgorny@gentoo.org> wrote:
> diff --git a/gx86/eclass/python-utils-r1.eclass b/gx86/eclass/python-utils-r1.eclass
> index 6cf23f0..dd1ce0b 100644
> --- a/gx86/eclass/python-utils-r1.eclass
> +++ b/gx86/eclass/python-utils-r1.eclass
> @@ -575,16 +575,16 @@ _python_rewrite_shebang() {
>         done
>  }
>
> -# @FUNCTION: _python_ln_rel
> -# @USAGE: <from> <to>
> +# @FUNCTION: _python_symlink_wrapper
> +# @USAGE: <to>
>  # @INTERNAL
>  # @DESCRIPTION:
> -# Create a relative symlink.
> -_python_ln_rel() {
> +# Create a relative symlink to the proper version of python-exec.
> +_python_symlink_wrapper() {
>         debug-print-function ${FUNCNAME} "${@}"
>
> -       local from=${1}
> -       local to=${2}
> +       local from=${ED%/}/usr/bin/python-exec
> +       local to=${1}
>
>         local frpath=${from%/*}/
>         local topath=${to%/*}/
> @@ -607,12 +607,12 @@ _python_ln_rel() {
>                         rel_path=../${rel_path}${frseg:+${frseg}/}
>                 fi
>         done
> -       rel_path+=${frpath}${1##*/}
> +       rel_path+=${frpath}${from##*/}
>
>         debug-print "${FUNCNAME}: ${from} -> ${to}"
>         debug-print "${FUNCNAME}: rel_path = ${rel_path}"
>
> -       ln -fs "${rel_path}" "${to}"
> +       ln -fs "${rel_path}" "${to}" || die

It seems like "from" and "to" are backwards here; the link name should
be the "from" and python-exec should be the "to".

Perhaps better variable names would be "linkname" and "target", as are
used in the ln(1) manpage.


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

* Re: [gentoo-python] Re: [PATCH 2/8] Clean up python_replicate_script().
  2013-09-15 17:11   ` [gentoo-python] " Mike Gilbert
@ 2013-09-15 17:36     ` Michał Górny
  0 siblings, 0 replies; 20+ messages in thread
From: Michał Górny @ 2013-09-15 17:36 UTC (permalink / raw
  To: Mike Gilbert; +Cc: gentoo-python, Gentoo Python Project

[-- Attachment #1: Type: text/plain, Size: 2072 bytes --]

Dnia 2013-09-15, o godz. 13:11:21
Mike Gilbert <floppym@gentoo.org> napisał(a):

> On Fri, Sep 13, 2013 at 2:58 PM, Michał Górny <mgorny@gentoo.org> wrote:
> > ---
> >  gx86/eclass/python-r1.eclass | 30 ++++++++++++------------------
> >  1 file changed, 12 insertions(+), 18 deletions(-)
> >
> > diff --git a/gx86/eclass/python-r1.eclass b/gx86/eclass/python-r1.eclass
> > index 6994952..e006744 100644
> > --- a/gx86/eclass/python-r1.eclass
> > +++ b/gx86/eclass/python-r1.eclass
> > @@ -741,28 +741,22 @@ python_export_best() {
> >  python_replicate_script() {
> >         debug-print-function ${FUNCNAME} "${@}"
> >
> > -       local suffixes=()
> > -
> > -       _add_suffix() {
> > -               suffixes+=( "${EPYTHON}" )
> > -       }
> > -       python_foreach_impl _add_suffix
> > -       debug-print "${FUNCNAME}: suffixes = ( ${suffixes[@]} )"
> > -
> > -       local f suffix
> > -       for suffix in "${suffixes[@]}"; do
> > -               for f; do
> > -                       local newf=${f}-${suffix}
> > -
> > -                       debug-print "${FUNCNAME}: ${f} -> ${newf}"
> > -                       cp "${f}" "${newf}" || die
> > +       _python_replicate_script() {
> > +               local f
> > +               for f in "${files[@]}"; do
> > +                       cp -p "${f}" "${f}-${EPYTHON}" || die
> >                 done
> > +               _python_rewrite_shebang "${EPYTHON}" \
> > +                       "${files[@]/%/-${EPYTHON}}"
> > +       }
> >
> > -               _python_rewrite_shebang "${suffix}" "${@/%/-${suffix}}"
> > -       done
> > +       local files=( "${@}" )
> > +       python_foreach_impl _python_replicate_script
> 
> Why are we creating a new array variable here? Why not just pass $@ to
> _python_replicate script as arguments?

It's because python_foreach_impl likes to verbose and prints "${@}"
starting with first non-underline arg. Passing files out-of-argv
is the simplest way of avoiding verbose output.


-- 
Best regards,
Michał Górny

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 966 bytes --]

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

end of thread, other threads:[~2013-09-15 17:37 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-13 18:58 [gentoo-python] Clean up of python eclasses and support for python-exec:2 Michał Górny
2013-09-13 18:58 ` [gentoo-python] [PATCH 1/8] Add PYTHON_SCRIPTDIR for script installation path Michał Górny
2013-09-13 18:58 ` [gentoo-python] [PATCH 2/8] Clean up python_replicate_script() Michał Górny
2013-09-15 17:11   ` [gentoo-python] " Mike Gilbert
2013-09-15 17:36     ` Michał Górny
2013-09-13 18:58 ` [gentoo-python] [PATCH 3/8] Clean up python_newscript() Michał Górny
2013-09-13 18:58 ` [gentoo-python] [PATCH 4/8] distutils-r1: rework script install/wrapping Michał Górny
2013-09-13 18:58 ` [gentoo-python] [PATCH 5/8] distutils-r1: disable sub-root merging Michał Górny
2013-09-14 22:16   ` [gentoo-python] " Mike Gilbert
2013-09-14 22:38     ` Michał Górny
2013-09-14 23:33       ` Mike Gilbert
2013-09-15  9:04         ` Michał Górny
2013-09-13 18:58 ` [gentoo-python] [PATCH 6/8] _distutils-r1_wrap_scripts(): do not pass root path explicitly Michał Górny
2013-09-13 18:58 ` [gentoo-python] [PATCH 7/8] Replace _python_ln_rel() with _python_symlink_wrapper() Michał Górny
2013-09-15 17:27   ` [gentoo-python] " Mike Gilbert
2013-09-13 18:58 ` [gentoo-python] [PATCH 8/8] Support python-exec:2 Michał Górny
2013-09-15  9:03 ` [gentoo-python] Clean up of python eclasses and support for python-exec:2, r2 Michał Górny
2013-09-15  9:03   ` [gentoo-python] [PATCH 1/2] distutils-r1: clean up script install/wrapping Michał Górny
2013-09-15  9:03   ` [gentoo-python] [PATCH 2/2] Support python-exec:2 Michał Górny
2013-09-15  9:29     ` Michał Górny

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