public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] Patch for python.eclass
@ 2010-09-20  1:18 Arfrever Frehtes Taifersar Arahesis
  2010-09-20  1:45 ` [gentoo-dev] " Mike Frysinger
  2010-09-24 17:39 ` [gentoo-dev] " Arfrever Frehtes Taifersar Arahesis
  0 siblings, 2 replies; 11+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2010-09-20  1:18 UTC (permalink / raw
  To: Gentoo Development; +Cc: qa


[-- Attachment #1.1: Type: Text/Plain, Size: 1630 bytes --]

This patch for python.eclass has been divided into 3 subpatches to simplify review.

Subpatch #1 fixes preservation of whitespace.

Subpatch #2 renames 2 local arrays in python_mod_optimize() function:
  site_packages_absolute_dirs  -> dirs
  site_packages_absolute_files -> files

Subpatch #3 adds --allow-evaluated-non-sitedir-paths option to python_mod_optimize() and
python_mod_cleanup() functions.
In rare cases, packages supporting installation for multiple Python ABIs install .py files
outside of site-packages directories. python_mod_optimize() and python_mod_cleanup()
functions currently don't support such paths. It's better to not allow such paths by
default, so this subpatch adds new --allow-evaluated-non-sitedir-paths option to these
functions. This option is disallowed in packages not supporting installation for multiple
Python ABIs. Such paths are internally evaluated inside these functions. Such paths work
correctly only if they contain '${PYTHON_ABI}' or '$(python_get_version)' (probably with
'$(python_get_implementation)') or '$(custom_function)' (where custom_function() uses
"${PYTHON_ABI}" or "$(python_get_version)" and prints appropriate output), so there are
sanity checks, which ensure that such paths contain '$'.

Example usage:

pkg_postinst() {
    python_mod_optimize --allow-evaluated-non-sitedir-paths '/usr/share/package_name/${PYTHON_ABI}'
}

pkg_postrm() {
    python_mod_cleanup --allow-evaluated-non-sitedir-paths '/usr/share/package_name/${PYTHON_ABI}'
}

This functionality is needed by Zope 2.12 / 2.13.

-- 
Arfrever Frehtes Taifersar Arahesis

[-- Attachment #1.2: python.eclass.patch --]
[-- Type: text/x-patch, Size: 10021 bytes --]

--- python.eclass
+++ python.eclass
@@ -925,7 +925,7 @@
 
 		if [[ "${quiet}" == "0" ]]; then
 			if [[ -n "${action_message_template}" ]]; then
-				action_message="$(eval echo -n "${action_message_template}")"
+				eval "action_message=\"${action_message_template}\""
 			else
 				action_message="${action} of ${CATEGORY}/${PF} with $(python_get_implementation) $(python_get_version)..."
 			fi
@@ -959,7 +959,7 @@
 
 		if [[ "${return_code}" -ne 0 ]]; then
 			if [[ -n "${failure_message_template}" ]]; then
-				failure_message="$(eval echo -n "${failure_message_template}")"
+				eval "failure_message=\"${failure_message_template}\""
 			else
 				failure_message="${action} failed with $(python_get_implementation) $(python_get_version) in ${function}() function"
 			fi
@@ -1925,7 +1925,7 @@
 	python_test_function() {
 		local evaluated_PYTHONPATH
 
-		evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
+		eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\""
 
 		_python_test_hook pre
 
@@ -1989,7 +1989,7 @@
 	python_test_function() {
 		local evaluated_PYTHONPATH
 
-		evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
+		eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\""
 
 		_python_test_hook pre
 
@@ -2053,7 +2053,7 @@
 	python_test_function() {
 		local evaluated_PYTHONPATH
 
-		evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
+		eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\""
 
 		_python_test_hook pre
 
@@ -2223,7 +2223,7 @@
 
 	if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
 		# PYTHON_ABI variable cannot be local in packages not supporting installation for multiple Python ABIs.
-		local dir file iterated_PYTHON_ABIS options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=()
+		local allow_evaluated_non_sitedir_paths="0" dir dirs=() evaluated_dirs=() evaluated_files=() file files=() iterated_PYTHON_ABIS options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_dirs=() site_packages_files=()
 
 		if _python_package_supporting_installation_for_multiple_python_abis; then
 			if has "${EAPI:-0}" 0 1 2 3 && [[ -z "${PYTHON_ABIS}" ]]; then
@@ -2243,6 +2243,9 @@
 
 		while (($#)); do
 			case "$1" in
+				--allow-evaluated-non-sitedir-paths)
+					allow_evaluated_non_sitedir_paths="1"
+					;;
 				-l|-f|-q)
 					options+=("$1")
 					;;
@@ -2264,6 +2267,10 @@
 			shift
 		done
 
+		if [[ "${allow_evaluated_non_sitedir_paths}" == "1" ]] && ! _python_package_supporting_installation_for_multiple_python_abis; then
+			die "${FUNCNAME}(): '--allow-evaluated-non-sitedir-paths' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+		fi
+
 		if [[ "$#" -eq 0 ]]; then
 			ewarn
 			ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be"
@@ -2279,16 +2286,27 @@
 				die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories"
 			elif [[ "$1" =~ ^/ ]]; then
 				if _python_package_supporting_installation_for_multiple_python_abis; then
-					die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
-				fi
-				if [[ -d "${root}$1" ]]; then
-					other_dirs+=("${root}$1")
-				elif [[ -f "${root}$1" ]]; then
-					other_files+=("${root}$1")
-				elif [[ -e "${root}$1" ]]; then
-					eerror "${FUNCNAME}(): '${root}$1' is not a regular file or a directory"
+					if [[ "${allow_evaluated_non_sitedir_paths}" != "1" ]]; then
+						die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
+					fi
+					if [[ "$1" != *\$* ]]; then
+						die "${FUNCNAME}(): '$1' has invalid syntax"
+					fi
+					if [[ "$1" == *.py ]]; then
+						evaluated_files+=("$1")
+					else
+						evaluated_dirs+=("$1")
+					fi
 				else
-					eerror "${FUNCNAME}(): '${root}$1' does not exist"
+					if [[ -d "${root}$1" ]]; then
+						other_dirs+=("${root}$1")
+					elif [[ -f "${root}$1" ]]; then
+						other_files+=("${root}$1")
+					elif [[ -e "${root}$1" ]]; then
+						eerror "${FUNCNAME}(): '${root}$1' is not a regular file or a directory"
+					else
+						eerror "${FUNCNAME}(): '${root}$1' does not exist"
+					fi
 				fi
 			else
 				for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
@@ -2312,32 +2330,38 @@
 		options+=("-q")
 
 		for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
-			if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})); then
+			if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})) || ((${#evaluated_dirs[@]})) || ((${#evaluated_files[@]})); then
 				return_code="0"
 				ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)"
-				if ((${#site_packages_dirs[@]})); then
+				if ((${#site_packages_dirs[@]})) || ((${#evaluated_dirs[@]})); then
 					for dir in "${site_packages_dirs[@]}"; do
-						site_packages_absolute_dirs+=("${root}$(python_get_sitedir)/${dir}")
+						dirs+=("${root}$(python_get_sitedir)/${dir}")
 					done
-					"$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" || return_code="1"
+					for dir in "${evaluated_dirs[@]}"; do
+						eval "dirs+=(\"\${root}${dir}\")"
+					done
+					"$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${dirs[@]}" || return_code="1"
 					if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
-						"$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" &> /dev/null || return_code="1"
+						"$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${dirs[@]}" &> /dev/null || return_code="1"
 					fi
-					_python_clean_compiled_modules "${site_packages_absolute_dirs[@]}"
+					_python_clean_compiled_modules "${dirs[@]}"
 				fi
-				if ((${#site_packages_files[@]})); then
+				if ((${#site_packages_files[@]})) || ((${#evaluated_files[@]})); then
 					for file in "${site_packages_files[@]}"; do
-						site_packages_absolute_files+=("${root}$(python_get_sitedir)/${file}")
+						files+=("${root}$(python_get_sitedir)/${file}")
+					done
+					for file in "${evaluated_files[@]}"; do
+						eval "files+=(\"\${root}${file}\")"
 					done
-					"$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" || return_code="1"
+					"$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${files[@]}" || return_code="1"
 					if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
-						"$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" &> /dev/null || return_code="1"
+						"$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${files[@]}" &> /dev/null || return_code="1"
 					fi
-					_python_clean_compiled_modules "${site_packages_absolute_files[@]}"
+					_python_clean_compiled_modules "${files[@]}"
 				fi
 				eend "${return_code}"
 			fi
-			unset site_packages_absolute_dirs site_packages_absolute_files
+			unset dirs files
 		done
 
 		if _python_package_supporting_installation_for_multiple_python_abis; then
@@ -2459,7 +2483,7 @@
 	_python_check_python_pkg_setup_execution
 	_python_initialize_prefix_variables
 
-	local dir iterated_PYTHON_ABIS PYTHON_ABI="${PYTHON_ABI}" root search_paths=() sitedir
+	local allow_evaluated_non_sitedir_paths="0" dir iterated_PYTHON_ABIS PYTHON_ABI="${PYTHON_ABI}" root search_paths=() sitedir
 
 	# Check if phase is pkg_postrm().
 	[[ "${EBUILD_PHASE}" != "postrm" ]] && die "${FUNCNAME}() can be used only in pkg_postrm() phase"
@@ -2480,6 +2504,29 @@
 	# Strip trailing slash from EROOT.
 	root="${EROOT%/}"
 
+	while (($#)); do
+		case "$1" in
+			--allow-evaluated-non-sitedir-paths)
+				allow_evaluated_non_sitedir_paths="1"
+				;;
+			--)
+				shift
+				break
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				break
+				;;
+		esac
+		shift
+	done
+
+	if [[ "${allow_evaluated_non_sitedir_paths}" == "1" ]] && ! _python_package_supporting_installation_for_multiple_python_abis; then
+		die "${FUNCNAME}(): '--allow-evaluated-non-sitedir-paths' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+	fi
+
 	if [[ "$#" -gt 0 ]]; then
 		if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
 			while (($#)); do
@@ -2489,9 +2536,18 @@
 					die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories"
 				elif [[ "$1" =~ ^/ ]]; then
 					if _python_package_supporting_installation_for_multiple_python_abis; then
-						die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
+						if [[ "${allow_evaluated_non_sitedir_paths}" != "1" ]]; then
+							die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
+						fi
+						if [[ "$1" != *\$* ]]; then
+							die "${FUNCNAME}(): '$1' has invalid syntax"
+						fi
+						for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
+							eval "search_paths+=(\"\${root}$1\")"
+						done
+					else
+						search_paths+=("${root}$1")
 					fi
-					search_paths+=("${root}$1")
 				else
 					for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
 						search_paths+=("${root}$(python_get_sitedir)/$1")

[-- Attachment #1.3: python.eclass.patch.1 --]
[-- Type: text/x-patch, Size: 1532 bytes --]

--- python.eclass
+++ python.eclass
@@ -925,7 +925,7 @@
 
 		if [[ "${quiet}" == "0" ]]; then
 			if [[ -n "${action_message_template}" ]]; then
-				action_message="$(eval echo -n "${action_message_template}")"
+				eval "action_message=\"${action_message_template}\""
 			else
 				action_message="${action} of ${CATEGORY}/${PF} with $(python_get_implementation) $(python_get_version)..."
 			fi
@@ -959,7 +959,7 @@
 
 		if [[ "${return_code}" -ne 0 ]]; then
 			if [[ -n "${failure_message_template}" ]]; then
-				failure_message="$(eval echo -n "${failure_message_template}")"
+				eval "failure_message=\"${failure_message_template}\""
 			else
 				failure_message="${action} failed with $(python_get_implementation) $(python_get_version) in ${function}() function"
 			fi
@@ -1925,7 +1925,7 @@
 	python_test_function() {
 		local evaluated_PYTHONPATH
 
-		evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
+		eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\""
 
 		_python_test_hook pre
 
@@ -1989,7 +1989,7 @@
 	python_test_function() {
 		local evaluated_PYTHONPATH
 
-		evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
+		eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\""
 
 		_python_test_hook pre
 
@@ -2053,7 +2053,7 @@
 	python_test_function() {
 		local evaluated_PYTHONPATH
 
-		evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
+		eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\""
 
 		_python_test_hook pre
 

[-- Attachment #1.4: python.eclass.patch.2 --]
[-- Type: text/x-patch, Size: 3143 bytes --]

--- python.eclass
+++ python.eclass
@@ -2223,7 +2223,7 @@
 
 	if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
 		# PYTHON_ABI variable cannot be local in packages not supporting installation for multiple Python ABIs.
-		local dir file iterated_PYTHON_ABIS options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_absolute_dirs=() site_packages_dirs=() site_packages_absolute_files=() site_packages_files=()
+		local dir dirs=() file files=() iterated_PYTHON_ABIS options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_dirs=() site_packages_files=()
 
 		if _python_package_supporting_installation_for_multiple_python_abis; then
 			if has "${EAPI:-0}" 0 1 2 3 && [[ -z "${PYTHON_ABIS}" ]]; then
@@ -2317,27 +2317,27 @@
 				ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)"
 				if ((${#site_packages_dirs[@]})); then
 					for dir in "${site_packages_dirs[@]}"; do
-						site_packages_absolute_dirs+=("${root}$(python_get_sitedir)/${dir}")
+						dirs+=("${root}$(python_get_sitedir)/${dir}")
 					done
-					"$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" || return_code="1"
+					"$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${dirs[@]}" || return_code="1"
 					if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
-						"$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${site_packages_absolute_dirs[@]}" &> /dev/null || return_code="1"
+						"$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${dirs[@]}" &> /dev/null || return_code="1"
 					fi
-					_python_clean_compiled_modules "${site_packages_absolute_dirs[@]}"
+					_python_clean_compiled_modules "${dirs[@]}"
 				fi
 				if ((${#site_packages_files[@]})); then
 					for file in "${site_packages_files[@]}"; do
-						site_packages_absolute_files+=("${root}$(python_get_sitedir)/${file}")
+						files+=("${root}$(python_get_sitedir)/${file}")
 					done
-					"$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" || return_code="1"
+					"$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${files[@]}" || return_code="1"
 					if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
-						"$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${site_packages_absolute_files[@]}" &> /dev/null || return_code="1"
+						"$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${files[@]}" &> /dev/null || return_code="1"
 					fi
-					_python_clean_compiled_modules "${site_packages_absolute_files[@]}"
+					_python_clean_compiled_modules "${files[@]}"
 				fi
 				eend "${return_code}"
 			fi
-			unset site_packages_absolute_dirs site_packages_absolute_files
+			unset dirs files
 		done
 
 		if _python_package_supporting_installation_for_multiple_python_abis; then

[-- Attachment #1.5: python.eclass.patch.3 --]
[-- Type: text/x-patch, Size: 7349 bytes --]

--- python.eclass
+++ python.eclass
@@ -2223,7 +2223,7 @@
 
 	if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
 		# PYTHON_ABI variable cannot be local in packages not supporting installation for multiple Python ABIs.
-		local dir dirs=() file files=() iterated_PYTHON_ABIS options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_dirs=() site_packages_files=()
+		local allow_evaluated_non_sitedir_paths="0" dir dirs=() evaluated_dirs=() evaluated_files=() file files=() iterated_PYTHON_ABIS options=() other_dirs=() other_files=() previous_PYTHON_ABI="${PYTHON_ABI}" return_code root site_packages_dirs=() site_packages_files=()
 
 		if _python_package_supporting_installation_for_multiple_python_abis; then
 			if has "${EAPI:-0}" 0 1 2 3 && [[ -z "${PYTHON_ABIS}" ]]; then
@@ -2243,6 +2243,9 @@
 
 		while (($#)); do
 			case "$1" in
+				--allow-evaluated-non-sitedir-paths)
+					allow_evaluated_non_sitedir_paths="1"
+					;;
 				-l|-f|-q)
 					options+=("$1")
 					;;
@@ -2264,6 +2267,10 @@
 			shift
 		done
 
+		if [[ "${allow_evaluated_non_sitedir_paths}" == "1" ]] && ! _python_package_supporting_installation_for_multiple_python_abis; then
+			die "${FUNCNAME}(): '--allow-evaluated-non-sitedir-paths' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+		fi
+
 		if [[ "$#" -eq 0 ]]; then
 			ewarn
 			ewarn "Deprecation Warning: Not passing of paths to ${FUNCNAME}() is deprecated and will be"
@@ -2279,16 +2286,27 @@
 				die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories"
 			elif [[ "$1" =~ ^/ ]]; then
 				if _python_package_supporting_installation_for_multiple_python_abis; then
-					die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
-				fi
-				if [[ -d "${root}$1" ]]; then
-					other_dirs+=("${root}$1")
-				elif [[ -f "${root}$1" ]]; then
-					other_files+=("${root}$1")
-				elif [[ -e "${root}$1" ]]; then
-					eerror "${FUNCNAME}(): '${root}$1' is not a regular file or a directory"
+					if [[ "${allow_evaluated_non_sitedir_paths}" != "1" ]]; then
+						die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
+					fi
+					if [[ "$1" != *\$* ]]; then
+						die "${FUNCNAME}(): '$1' has invalid syntax"
+					fi
+					if [[ "$1" == *.py ]]; then
+						evaluated_files+=("$1")
+					else
+						evaluated_dirs+=("$1")
+					fi
 				else
-					eerror "${FUNCNAME}(): '${root}$1' does not exist"
+					if [[ -d "${root}$1" ]]; then
+						other_dirs+=("${root}$1")
+					elif [[ -f "${root}$1" ]]; then
+						other_files+=("${root}$1")
+					elif [[ -e "${root}$1" ]]; then
+						eerror "${FUNCNAME}(): '${root}$1' is not a regular file or a directory"
+					else
+						eerror "${FUNCNAME}(): '${root}$1' does not exist"
+					fi
 				fi
 			else
 				for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
@@ -2312,23 +2330,29 @@
 		options+=("-q")
 
 		for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
-			if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})); then
+			if ((${#site_packages_dirs[@]})) || ((${#site_packages_files[@]})) || ((${#evaluated_dirs[@]})) || ((${#evaluated_files[@]})); then
 				return_code="0"
 				ebegin "Compilation and optimization of Python modules for $(python_get_implementation) $(python_get_version)"
-				if ((${#site_packages_dirs[@]})); then
+				if ((${#site_packages_dirs[@]})) || ((${#evaluated_dirs[@]})); then
 					for dir in "${site_packages_dirs[@]}"; do
 						dirs+=("${root}$(python_get_sitedir)/${dir}")
 					done
+					for dir in "${evaluated_dirs[@]}"; do
+						eval "dirs+=(\"\${root}${dir}\")"
+					done
 					"$(PYTHON)" "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${dirs[@]}" || return_code="1"
 					if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
 						"$(PYTHON)" -O "${root}$(python_get_libdir)/compileall.py" "${options[@]}" "${dirs[@]}" &> /dev/null || return_code="1"
 					fi
 					_python_clean_compiled_modules "${dirs[@]}"
 				fi
-				if ((${#site_packages_files[@]})); then
+				if ((${#site_packages_files[@]})) || ((${#evaluated_files[@]})); then
 					for file in "${site_packages_files[@]}"; do
 						files+=("${root}$(python_get_sitedir)/${file}")
 					done
+					for file in "${evaluated_files[@]}"; do
+						eval "files+=(\"\${root}${file}\")"
+					done
 					"$(PYTHON)" "${root}$(python_get_libdir)/py_compile.py" "${files[@]}" || return_code="1"
 					if [[ "$(_python_get_implementation "${PYTHON_ABI}")" != "Jython" ]]; then
 						"$(PYTHON)" -O "${root}$(python_get_libdir)/py_compile.py" "${files[@]}" &> /dev/null || return_code="1"
@@ -2459,7 +2483,7 @@
 	_python_check_python_pkg_setup_execution
 	_python_initialize_prefix_variables
 
-	local dir iterated_PYTHON_ABIS PYTHON_ABI="${PYTHON_ABI}" root search_paths=() sitedir
+	local allow_evaluated_non_sitedir_paths="0" dir iterated_PYTHON_ABIS PYTHON_ABI="${PYTHON_ABI}" root search_paths=() sitedir
 
 	# Check if phase is pkg_postrm().
 	[[ "${EBUILD_PHASE}" != "postrm" ]] && die "${FUNCNAME}() can be used only in pkg_postrm() phase"
@@ -2480,6 +2504,29 @@
 	# Strip trailing slash from EROOT.
 	root="${EROOT%/}"
 
+	while (($#)); do
+		case "$1" in
+			--allow-evaluated-non-sitedir-paths)
+				allow_evaluated_non_sitedir_paths="1"
+				;;
+			--)
+				shift
+				break
+				;;
+			-*)
+				die "${FUNCNAME}(): Unrecognized option '$1'"
+				;;
+			*)
+				break
+				;;
+		esac
+		shift
+	done
+
+	if [[ "${allow_evaluated_non_sitedir_paths}" == "1" ]] && ! _python_package_supporting_installation_for_multiple_python_abis; then
+		die "${FUNCNAME}(): '--allow-evaluated-non-sitedir-paths' option cannot be used in ebuilds of packages not supporting installation for multiple Python ABIs"
+	fi
+
 	if [[ "$#" -gt 0 ]]; then
 		if ! has "${EAPI:-0}" 0 1 2 || _python_package_supporting_installation_for_multiple_python_abis; then
 			while (($#)); do
@@ -2489,9 +2536,18 @@
 					die "${FUNCNAME}(): Paths of directories / files in site-packages directories must be relative to site-packages directories"
 				elif [[ "$1" =~ ^/ ]]; then
 					if _python_package_supporting_installation_for_multiple_python_abis; then
-						die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
+						if [[ "${allow_evaluated_non_sitedir_paths}" != "1" ]]; then
+							die "${FUNCNAME}(): Absolute paths cannot be used in ebuilds of packages supporting installation for multiple Python ABIs"
+						fi
+						if [[ "$1" != *\$* ]]; then
+							die "${FUNCNAME}(): '$1' has invalid syntax"
+						fi
+						for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
+							eval "search_paths+=(\"\${root}$1\")"
+						done
+					else
+						search_paths+=("${root}$1")
 					fi
-					search_paths+=("${root}$1")
 				else
 					for PYTHON_ABI in ${iterated_PYTHON_ABIS}; do
 						search_paths+=("${root}$(python_get_sitedir)/$1")

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* [gentoo-dev] Re: Patch for python.eclass
  2010-09-20  1:18 [gentoo-dev] Patch for python.eclass Arfrever Frehtes Taifersar Arahesis
@ 2010-09-20  1:45 ` Mike Frysinger
  2010-09-20  2:53   ` Arfrever Frehtes Taifersar Arahesis
  2010-09-24 17:39 ` [gentoo-dev] " Arfrever Frehtes Taifersar Arahesis
  1 sibling, 1 reply; 11+ messages in thread
From: Mike Frysinger @ 2010-09-20  1:45 UTC (permalink / raw
  To: Gentoo Development; +Cc: qa

[-- Attachment #1: Type: Text/Plain, Size: 856 bytes --]

On Sunday, September 19, 2010 21:18:51 Arfrever Frehtes Taifersar Arahesis 
wrote:
> -evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
> +eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\""

the quotes in the 2nd one are useless.  this should work the same:
	eval evaluated_PYTHONPATH=\"${PYTHONPATH_template}\"

while you're in the process of cleaning things up, i know we dont have a rule 
anywhere in terms of line length, but python.eclass has always struck me as a 
file with incredibly excessive line length.  comparing to other eclasses, it 
has multiple lines in it longer than any single line in any other eclass.

i normally develop in a terminal with 170 cols (which i think is larger than 
average), so i'm pretty lenient, but even python.eclass exceeds that multiple 
times if not running close to it.
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [gentoo-dev] Re: Patch for python.eclass
  2010-09-20  1:45 ` [gentoo-dev] " Mike Frysinger
@ 2010-09-20  2:53   ` Arfrever Frehtes Taifersar Arahesis
  2010-09-20  3:00     ` Mike Frysinger
  2010-09-20  6:10     ` Peter Volkov
  0 siblings, 2 replies; 11+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2010-09-20  2:53 UTC (permalink / raw
  To: Gentoo Development; +Cc: qa

[-- Attachment #1: Type: Text/Plain, Size: 1312 bytes --]

2010-09-20 03:45:14 Mike Frysinger napisał(a):
> On Sunday, September 19, 2010 21:18:51 Arfrever Frehtes Taifersar Arahesis 
> wrote:
> > -evaluated_PYTHONPATH="$(eval echo -n "${PYTHONPATH_template}")"
> > +eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\""
> 
> the quotes in the 2nd one are useless.  this should work the same:
> 	eval evaluated_PYTHONPATH=\"${PYTHONPATH_template}\"

The quotes are required:

$ PYTHONPATH_template="/usr/share/a   b"
$ eval "evaluated_PYTHONPATH=\"${PYTHONPATH_template}\""
$ echo "${evaluated_PYTHONPATH}"
/usr/share/a   b
$ eval evaluated_PYTHONPATH=\"${PYTHONPATH_template}\"
$ echo "${evaluated_PYTHONPATH}"
/usr/share/a b

> while you're in the process of cleaning things up, i know we dont have a rule 
> anywhere in terms of line length, but python.eclass has always struck me as a 
> file with incredibly excessive line length.  comparing to other eclasses, it 
> has multiple lines in it longer than any single line in any other eclass.
> 
> i normally develop in a terminal with 170 cols (which i think is larger than 
> average), so i'm pretty lenient, but even python.eclass exceeds that multiple 
> times if not running close to it.

python.eclass has many nested checks, loops etc.

-- 
Arfrever Frehtes Taifersar Arahesis

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [gentoo-dev] Re: Patch for python.eclass
  2010-09-20  2:53   ` Arfrever Frehtes Taifersar Arahesis
@ 2010-09-20  3:00     ` Mike Frysinger
  2010-09-20  6:10     ` Peter Volkov
  1 sibling, 0 replies; 11+ messages in thread
From: Mike Frysinger @ 2010-09-20  3:00 UTC (permalink / raw
  To: Gentoo Development; +Cc: qa

[-- Attachment #1: Type: Text/Plain, Size: 1338 bytes --]

On Sunday, September 19, 2010 22:53:31 Arfrever Frehtes Taifersar Arahesis 
wrote:
> 2010-09-20 03:45:14 Mike Frysinger napisał(a):
> > while you're in the process of cleaning things up, i know we dont have a
> > rule anywhere in terms of line length, but python.eclass has always
> > struck me as a file with incredibly excessive line length.  comparing to
> > other eclasses, it has multiple lines in it longer than any single line
> > in any other eclass.
> > 
> > i normally develop in a terminal with 170 cols (which i think is larger
> > than average), so i'm pretty lenient, but even python.eclass exceeds
> > that multiple times if not running close to it.
> 
> python.eclass has many nested checks, loops etc.

so what ?  actually look at the long lines.  none of them need to be so long:

lines 33 & 802 & 2226 - a large number of local variables that could easily be 
line wrapped otherwise we get 344+ cols.  good luck figuring out what vars are 
at the tail end of that.

lines 274 & 290 - a lot of checks in a single if statement that too could 
easily be line wrapped

line 2354 - a really long ebegin message that is shown to users

line 489 - a single sed statement that can easily be line wrapped

lines 1158 & 1184 - a single inline python command that can easily be line 
wrapped
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [gentoo-dev] Re: Patch for python.eclass
  2010-09-20  2:53   ` Arfrever Frehtes Taifersar Arahesis
  2010-09-20  3:00     ` Mike Frysinger
@ 2010-09-20  6:10     ` Peter Volkov
  1 sibling, 0 replies; 11+ messages in thread
From: Peter Volkov @ 2010-09-20  6:10 UTC (permalink / raw
  To: gentoo-dev

В Пнд, 20/09/2010 в 04:53 +0200, Arfrever Frehtes Taifersar Arahesis
пишет:
> > while you're in the process of cleaning things up, i know we dont have a rule 
> > anywhere in terms of line length, but python.eclass has always struck me as a 
> > file with incredibly excessive line length.  comparing to other eclasses, it 
> > has multiple lines in it longer than any single line in any other eclass.
> > 
> > i normally develop in a terminal with 170 cols (which i think is larger than 
> > average), so i'm pretty lenient, but even python.eclass exceeds that multiple 
> > times if not running close to it.
> 
> python.eclass has many nested checks, loops etc.

Although we don't write ebuilds in C there are useful bits in
/usr/src/linux/Documentation/CodingStyle:

1. Coding style is all about readability and maintainability using
commonly available tools.

2. Now, some people will claim that having 8-character indentations
makes the code move too far to the right, and makes it hard to read on a
80-character terminal screen. The answer to that is that if you need
more than 3 levels of indentation, you're screwed anyway, and should fix
your program.


In other words having many nested checks means that eclass needs
reorganization to avoid them.

-- 
Peter.




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

* Re: [gentoo-dev] Patch for python.eclass
  2010-09-20  1:18 [gentoo-dev] Patch for python.eclass Arfrever Frehtes Taifersar Arahesis
  2010-09-20  1:45 ` [gentoo-dev] " Mike Frysinger
@ 2010-09-24 17:39 ` Arfrever Frehtes Taifersar Arahesis
  1 sibling, 0 replies; 11+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2010-09-24 17:39 UTC (permalink / raw
  To: Gentoo Development; +Cc: qa

[-- Attachment #1: Type: Text/Plain, Size: 133 bytes --]

I will commit this patch in 3 days, if there are no other suggestions about this patch.

-- 
Arfrever Frehtes Taifersar Arahesis

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* [gentoo-dev] Re: Patch for python.eclass
  2010-10-18  1:33 Arfrever Frehtes Taifersar Arahesis
@ 2010-10-18  7:06 ` Mike Frysinger
  2010-10-18 15:10   ` Arfrever Frehtes Taifersar Arahesis
  0 siblings, 1 reply; 11+ messages in thread
From: Mike Frysinger @ 2010-10-18  7:06 UTC (permalink / raw
  To: Arfrever Frehtes Taifersar Arahesis; +Cc: Gentoo Development, qa

[-- Attachment #1: Type: Text/Plain, Size: 840 bytes --]

On October 17, 2010 21:33:20 Arfrever Frehtes Taifersar Arahesis wrote:
> Example usage:
>   RDEPEND="net-libs/gnutls
>       $(python_add_abi_dependencies ">=dev-python/PyQt4-4.7.7[svg]")
>       $(python_add_abi_dependencies -e "2.7 3.[2-9]" dev-python/argparse)"
>   DEPEND="${RDEPEND}
>       $(python_add_abi_dependencies dev-python/setuptools)
>       $(python_add_abi_dependencies -i "3.*" net-zope/zope-fixers)
>       test? ( $(python_add_abi_dependencies dev-python/py) )"

"dependencies" is overly verbose imo.  why not just use "depend" ?  plus, 
"add" usually means the func is the one doing the addition when this is not 
the case -- the user is the one doing the addition.  "python_abi_depend" 
should be sufficient.

> Subpatch #5 improves some code used in older EAPIs.

does this fix Bug 340395 ?
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* [gentoo-dev] Re: Patch for python.eclass
  2010-10-18  7:06 ` [gentoo-dev] " Mike Frysinger
@ 2010-10-18 15:10   ` Arfrever Frehtes Taifersar Arahesis
  2010-10-18 15:15     ` Diego Elio Pettenò
  0 siblings, 1 reply; 11+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2010-10-18 15:10 UTC (permalink / raw
  To: Gentoo Development; +Cc: qa

[-- Attachment #1: Type: Text/Plain, Size: 296 bytes --]

2010-10-18 09:06:06 Mike Frysinger napisał(a):
> On October 17, 2010 21:33:20 Arfrever Frehtes Taifersar Arahesis wrote:
> > Subpatch #5 improves some code used in older EAPIs.
> 
> does this fix Bug 340395 ?

No. It's not related to that bug.

-- 
Arfrever Frehtes Taifersar Arahesis

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* [gentoo-dev] Re: Patch for python.eclass
  2010-10-18 15:10   ` Arfrever Frehtes Taifersar Arahesis
@ 2010-10-18 15:15     ` Diego Elio Pettenò
  2010-10-22  7:56       ` Mike Frysinger
  0 siblings, 1 reply; 11+ messages in thread
From: Diego Elio Pettenò @ 2010-10-18 15:15 UTC (permalink / raw
  To: Arfrever Frehtes Taifersar Arahesis; +Cc: Gentoo Development, qa

Il giorno lun, 18/10/2010 alle 17.10 +0200, Arfrever Frehtes Taifersar
Arahesis ha scritto:
> 
> No. It's not related to that bug.

So I guess Mike's next reply is going to be "and what are you waiting
for, before fixing it?". Seriously.

-- 
Diego Elio Pettenò — Flameeyes
http://blog.flameeyes.eu/





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

* [gentoo-dev] Re: Patch for python.eclass
  2010-10-18 15:15     ` Diego Elio Pettenò
@ 2010-10-22  7:56       ` Mike Frysinger
  2010-10-23 19:21         ` Arfrever Frehtes Taifersar Arahesis
  0 siblings, 1 reply; 11+ messages in thread
From: Mike Frysinger @ 2010-10-22  7:56 UTC (permalink / raw
  To: Diego Elio Pettenò
  Cc: Arfrever Frehtes Taifersar Arahesis, Gentoo Development, qa

[-- Attachment #1: Type: Text/Plain, Size: 377 bytes --]

On Monday, October 18, 2010 11:15:45 Diego Elio Pettenò wrote:
> Il giorno lun, 18/10/2010 alle 17.10 +0200, Arfrever ha scritto:
> > No. It's not related to that bug.
> 
> So I guess Mike's next reply is going to be "and what are you waiting
> for, before fixing it?". Seriously.

i guess the answer is that you need someone on the QA team to fix it for you ?
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* [gentoo-dev] Re: Patch for python.eclass
  2010-10-22  7:56       ` Mike Frysinger
@ 2010-10-23 19:21         ` Arfrever Frehtes Taifersar Arahesis
  0 siblings, 0 replies; 11+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2010-10-23 19:21 UTC (permalink / raw
  To: Gentoo Development; +Cc: qa

[-- Attachment #1: Type: Text/Plain, Size: 569 bytes --]

2010-10-22 09:56:56 Mike Frysinger napisał(a):
> On Monday, October 18, 2010 11:15:45 Diego Elio Pettenò wrote:
> > Il giorno lun, 18/10/2010 alle 17.10 +0200, Arfrever ha scritto:
> > > No. It's not related to that bug.
> > 
> > So I guess Mike's next reply is going to be "and what are you waiting
> > for, before fixing it?". Seriously.
> 
> i guess the answer is that you need someone on the QA team to fix it for you ?

You shouldn't assume, that I can write answers when I'm away.
I will work on a patch.

-- 
Arfrever Frehtes Taifersar Arahesis

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2010-10-23 19:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-20  1:18 [gentoo-dev] Patch for python.eclass Arfrever Frehtes Taifersar Arahesis
2010-09-20  1:45 ` [gentoo-dev] " Mike Frysinger
2010-09-20  2:53   ` Arfrever Frehtes Taifersar Arahesis
2010-09-20  3:00     ` Mike Frysinger
2010-09-20  6:10     ` Peter Volkov
2010-09-24 17:39 ` [gentoo-dev] " Arfrever Frehtes Taifersar Arahesis
  -- strict thread matches above, loose matches on Subject: below --
2010-10-18  1:33 Arfrever Frehtes Taifersar Arahesis
2010-10-18  7:06 ` [gentoo-dev] " Mike Frysinger
2010-10-18 15:10   ` Arfrever Frehtes Taifersar Arahesis
2010-10-18 15:15     ` Diego Elio Pettenò
2010-10-22  7:56       ` Mike Frysinger
2010-10-23 19:21         ` Arfrever Frehtes Taifersar Arahesis

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