public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCHES] python-r1.eclass: any-of dep API support
@ 2017-05-20 13:30 Michał Górny
  2017-05-20 13:30 ` [gentoo-dev] [PATCH 1/7] distutils-r1.eclass: Reuse python_setup for common phases Michał Górny
                   ` (9 more replies)
  0 siblings, 10 replies; 12+ messages in thread
From: Michał Górny @ 2017-05-20 13:30 UTC (permalink / raw)
  To: gentoo-dev; +Cc: python

Hi, everyone.

Here's a set of patches inspired by the recent Sphinx dependency
discussion. They make python-r1 (and therefore distutils-r1) capable
of any-of dependency logic similar to the one used in python-any-r1.

The basic goal is relatively simple -- to improve handling of pure
build-time dependencies in the eclass. It solves two common problems:

a. dependencies on packages that support only a subset of PYTHON_COMPAT,

b. dependencies that need to be implementation-bound between themselves
   (e.g. Sphinx plugins).

The new API improves both of those cases significantly. For the former,
we no longer force user to select additional targets via REQUIRED_USE --
instead, we just any-of dependencies + python_check_deps() to select
implementation independently of whether it is enabled or not.

For the latter, we no longer have to force all targets of the package
on all the involved dependencies. Again, using any-of dep
and appropriate python_check_deps() we can enforce a single (any)
target throughout all the packages and use it.

The first three patches do some code refactoring that makes the change
easier and possibly improves maintainability of the code. The next two
patches add support for python_check_deps() and python_gen_any_dep()
respectively. The last two patches provide examples for both use cases
mentioned.

Please review.

--
Best regards,
Michał Górny



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

* [gentoo-dev] [PATCH 1/7] distutils-r1.eclass: Reuse python_setup for common phases
  2017-05-20 13:30 [gentoo-dev] [PATCHES] python-r1.eclass: any-of dep API support Michał Górny
@ 2017-05-20 13:30 ` Michał Górny
  2017-05-20 13:30 ` [gentoo-dev] [PATCH 2/7] python-r1.eclass: Move PYTHON_COMPAT_OVERRIDE warning into flag check Michał Górny
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Michał Górny @ 2017-05-20 13:30 UTC (permalink / raw)
  To: gentoo-dev; +Cc: python, Michał Górny

Rewrite the python_*_all() phase running code to reuse python_setup
instead of hacking on top of python_foreach_impl. The resulting code
is a bit simpler but most importantly, it avoids duplication of code
from python-r1 and ensures that distutils-r1 common phases are directly
altered by changes in python_setup.

The code still needs to reimplement some of the internals. However, it
is mostly limited to code specific to distutils-r1, and should be more
maintainable.
---
 eclass/distutils-r1.eclass | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index e79f86bab12d..167af95eaed6 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -672,20 +672,20 @@ distutils-r1_run_phase() {
 _distutils-r1_run_common_phase() {
 	local DISTUTILS_ORIG_BUILD_DIR=${BUILD_DIR}
 
-	if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
-		local best_impl patterns=( "${DISTUTILS_ALL_SUBPHASE_IMPLS[@]-*}" )
-		_distutils_try_impl() {
-			if _python_impl_matches "${EPYTHON}" "${patterns[@]}"; then
-				best_impl=${MULTIBUILD_VARIANT}
-			fi
-		}
-		python_foreach_impl _distutils_try_impl
-		unset -f _distutils_try_impl
-
-		local PYTHON_COMPAT=( "${best_impl}" )
+	if [[ ${DISTUTILS_SINGLE_IMPL} ]]; then
+		# reuse the dedicated code branch
+		_distutils-r1_run_foreach_impl "${@}"
+	else
+		local -x EPYTHON PYTHON
+		local -x PATH=${PATH} PKG_CONFIG_PATH=${PKG_CONFIG_PATH}
+		python_setup "${DISTUTILS_ALL_SUBPHASE_IMPLS[@]}"
+
+		local MULTIBUILD_VARIANTS=( "${EPYTHON/./_}" )
+		# store for restoring after distutils-r1_run_phase.
+		local _DISTUTILS_INITIAL_CWD=${PWD}
+		multibuild_foreach_variant \
+			distutils-r1_run_phase "${@}"
 	fi
-
-	_distutils-r1_run_foreach_impl "${@}"
 }
 
 # @FUNCTION: _distutils-r1_run_foreach_impl
-- 
2.13.0



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

* [gentoo-dev] [PATCH 2/7] python-r1.eclass: Move PYTHON_COMPAT_OVERRIDE warning into flag check
  2017-05-20 13:30 [gentoo-dev] [PATCHES] python-r1.eclass: any-of dep API support Michał Górny
  2017-05-20 13:30 ` [gentoo-dev] [PATCH 1/7] distutils-r1.eclass: Reuse python_setup for common phases Michał Górny
@ 2017-05-20 13:30 ` Michał Górny
  2017-05-20 13:30 ` [gentoo-dev] [PATCH 3/7] python-r1.eclass: Inline implementation loop logic into python_setup Michał Górny
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Michał Górny @ 2017-05-20 13:30 UTC (permalink / raw)
  To: gentoo-dev; +Cc: python, Michał Górny

Move the PYTHON_COMPAT_OVERRIDE warning from _python_obtain_impls()
to _python_validate_useflags(). Since the latter function is the only
point where the former is called, this is a purely cosmetic change at
the moment. However, it makes it possible to reuse the warning in
additional places without the necessity of setting MULTIBUILD_VARIANTS.
---
 eclass/python-r1.eclass | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index 5eaa802e06b9..ae9e3806e729 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -242,10 +242,25 @@ if [[ ! ${_PYTHON_R1} ]]; then
 # @FUNCTION: _python_validate_useflags
 # @INTERNAL
 # @DESCRIPTION:
-# Enforce the proper setting of PYTHON_TARGETS.
+# Enforce the proper setting of PYTHON_TARGETS, if PYTHON_COMPAT_OVERRIDE
+# is not in effect. If it is, just warn that the flags will be ignored.
 _python_validate_useflags() {
 	debug-print-function ${FUNCNAME} "${@}"
 
+	if [[ ${PYTHON_COMPAT_OVERRIDE} ]]; then
+		if [[ ! ${_PYTHON_COMPAT_OVERRIDE_WARNED} ]]; then
+			ewarn "WARNING: PYTHON_COMPAT_OVERRIDE in effect. The following Python"
+			ewarn "implementations will be enabled:"
+			ewarn
+			ewarn "	${PYTHON_COMPAT_OVERRIDE}"
+			ewarn
+			ewarn "Dependencies won't be satisfied, and PYTHON_TARGETS will be ignored."
+			_PYTHON_COMPAT_OVERRIDE_WARNED=1
+		fi
+		# we do not use flags with PCO
+		return
+	fi
+
 	local i
 
 	for i in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
@@ -490,23 +505,13 @@ python_copy_sources() {
 # @DESCRIPTION:
 # Set up the enabled implementation list.
 _python_obtain_impls() {
-	if [[ ${PYTHON_COMPAT_OVERRIDE} ]]; then
-		if [[ ! ${_PYTHON_COMPAT_OVERRIDE_WARNED} ]]; then
-			ewarn "WARNING: PYTHON_COMPAT_OVERRIDE in effect. The following Python"
-			ewarn "implementations will be enabled:"
-			ewarn
-			ewarn "	${PYTHON_COMPAT_OVERRIDE}"
-			ewarn
-			ewarn "Dependencies won't be satisfied, and PYTHON_TARGETS will be ignored."
-			_PYTHON_COMPAT_OVERRIDE_WARNED=1
-		fi
+	_python_validate_useflags
 
+	if [[ ${PYTHON_COMPAT_OVERRIDE} ]]; then
 		MULTIBUILD_VARIANTS=( ${PYTHON_COMPAT_OVERRIDE} )
 		return
 	fi
 
-	_python_validate_useflags
-
 	MULTIBUILD_VARIANTS=()
 
 	local impl
-- 
2.13.0



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

* [gentoo-dev] [PATCH 3/7] python-r1.eclass: Inline implementation loop logic into python_setup
  2017-05-20 13:30 [gentoo-dev] [PATCHES] python-r1.eclass: any-of dep API support Michał Górny
  2017-05-20 13:30 ` [gentoo-dev] [PATCH 1/7] distutils-r1.eclass: Reuse python_setup for common phases Michał Górny
  2017-05-20 13:30 ` [gentoo-dev] [PATCH 2/7] python-r1.eclass: Move PYTHON_COMPAT_OVERRIDE warning into flag check Michał Górny
@ 2017-05-20 13:30 ` Michał Górny
  2017-05-20 13:30 ` [gentoo-dev] [PATCH 4/7] python-r1.eclass: Support python_check_deps() in python_setup Michał Górny
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Michał Górny @ 2017-05-20 13:30 UTC (permalink / raw)
  To: gentoo-dev; +Cc: python, Michał Górny

Inline the logic needed to iterate over implementations directly into
python_setup instead of using python_foreach_impl. This is mostly NFC,
except that we iterate in reverse order now -- that is, we start at
the newest implementation and stop at the first one that works for us.
Previously we (implicitly) started at the oldest implementation, checked
all implementation and used the last one (i.e. the newest) that worked.

More importantly, the new code makes it possible to alter the logic more
easily and avoid relying on implementation of python_foreach_impl().
---
 eclass/python-r1.eclass | 35 ++++++++++++++++++++++++++---------
 1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index ae9e3806e729..9c37a20f7c2e 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -597,16 +597,34 @@ python_foreach_impl() {
 python_setup() {
 	debug-print-function ${FUNCNAME} "${@}"
 
-	local best_impl patterns=( "${@-*}" )
-	_python_try_impl() {
-		if _python_impl_matches "${EPYTHON}" "${patterns[@]}"; then
-			best_impl=${EPYTHON}
+	_python_validate_useflags
+	local pycompat=( "${PYTHON_COMPAT[@]}" )
+	if [[ ${PYTHON_COMPAT_OVERRIDE} ]]; then
+		pycompat=( ${PYTHON_COMPAT_OVERRIDE} )
+	fi
+
+	# (reverse iteration -- newest impl first)
+	local found
+	for (( i = ${#_PYTHON_SUPPORTED_IMPLS[@]} - 1; i >= 0; i-- )); do
+		local impl=${_PYTHON_SUPPORTED_IMPLS[i]}
+
+		# check PYTHON_COMPAT[_OVERRIDE]
+		has "${impl}" "${pycompat[@]}" || continue
+
+		# match USE flags only if override is not in effect
+		if [[ ! ${PYTHON_COMPAT_OVERRIDE} ]]; then
+			use "python_targets_${impl}" || continue
 		fi
-	}
-	python_foreach_impl _python_try_impl
-	unset -f _python_try_impl
 
-	if [[ ! ${best_impl} ]]; then
+		# check patterns
+		_python_impl_matches "${impl}" "${@-*}" || continue
+
+		python_export "${impl}" EPYTHON PYTHON
+		found=1
+		break
+	done
+
+	if [[ ! ${found} ]]; then
 		eerror "${FUNCNAME}: none of the enabled implementation matched the patterns."
 		eerror "  patterns: ${@-'(*)'}"
 		eerror "Likely a REQUIRED_USE constraint (possibly USE-conditional) is missing."
@@ -615,7 +633,6 @@ python_setup() {
 		die "${FUNCNAME}: no enabled implementation satisfy requirements"
 	fi
 
-	python_export "${best_impl}" EPYTHON PYTHON
 	python_wrapper_setup
 }
 
-- 
2.13.0



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

* [gentoo-dev] [PATCH 4/7] python-r1.eclass: Support python_check_deps() in python_setup
  2017-05-20 13:30 [gentoo-dev] [PATCHES] python-r1.eclass: any-of dep API support Michał Górny
                   ` (2 preceding siblings ...)
  2017-05-20 13:30 ` [gentoo-dev] [PATCH 3/7] python-r1.eclass: Inline implementation loop logic into python_setup Michał Górny
@ 2017-05-20 13:30 ` Michał Górny
  2017-05-20 13:30 ` [gentoo-dev] [PATCH 5/7] python-r1.eclass: Add python_gen_any_dep, to create any-of deps Michał Górny
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Michał Górny @ 2017-05-20 13:30 UTC (permalink / raw)
  To: gentoo-dev; +Cc: python, Michał Górny

Provide an alternate mode for python_setup() that behaves similarly to
python-any-r1 eclass. If python_check_deps() function is declared
by the ebuild, the python_setup logic switches to accepting any
implementation that is in PYTHON_COMPAT, installed and satisfies
python_check_deps() independently of USE flags.

This new logic makes it possible to replace some of the existing
REQUIRED_USE constraints for build-time dependencies with more friendly
any-of dependencies. For example, if a package supports both Python 2 &
Python 3 but has a purely Python 2 build-time dependency (e.g. for
building documentation) we had to force Python 2 being enabled via
REQUIRED_USE. Using python_check_deps() with appropriate any-of
dependency, we can use Python 2 for this task without actually forcing
the user to change USE flags or install the package for Python 2.
---
 eclass/python-r1.eclass | 48 ++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 38 insertions(+), 10 deletions(-)

diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index 9c37a20f7c2e..2992f603cf8a 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -231,7 +231,7 @@ _python_set_globals() {
 		PYTHON_DEPS=${deps}
 		PYTHON_REQUIRED_USE=${requse}
 		PYTHON_USEDEP=${usedep}
-		readonly PYTHON_DEPS PYTHON_REQUIRED_USE PYTHON_USEDEP
+		readonly PYTHON_DEPS PYTHON_REQUIRED_USE
 	fi
 }
 _python_set_globals
@@ -563,9 +563,27 @@ python_foreach_impl() {
 # @FUNCTION: python_setup
 # @USAGE: [<impl-pattern>...]
 # @DESCRIPTION:
-# Find the best (most preferred) Python implementation that is enabled
-# and matches at least one of the patterns passed (or '*' if no patterns
-# passed). Set the Python build environment up for that implementation.
+# Find the best (most preferred) Python implementation that is suitable
+# for running common Python code. Set the Python build environment up
+# for that implementation. This function has two modes of operation:
+# pure and any-of dep.
+#
+# The pure mode is used if python_check_deps() function is not declared.
+# In this case, an implementation is considered suitable if it is
+# supported (in PYTHON_COMPAT), enabled (via USE flags) and matches
+# at least one of the patterns passed (or '*' if no patterns passed).
+#
+# Implementation restrictions in the pure mode need to be accompanied
+# by appropriate REQUIRED_USE constraints. Otherwise, the eclass may
+# fail at build time due to unsatisfied dependencies.
+#
+# The any-of dep mode is used if python_check_deps() is declared.
+# In this mode, an implementation is considered suitable if it is
+# supported, matches at least one of the patterns and python_check_deps()
+# has successful return code. USE flags are not considered.
+#
+# The python_check_deps() function in the any-of mode needs to be
+# accompanied by appropriate any-of dependencies.
 #
 # The patterns can be either fnmatch-style patterns (matched via bash
 # == operator against PYTHON_COMPAT values) or '-2' / '-3' to indicate
@@ -577,11 +595,7 @@ python_foreach_impl() {
 # of python_foreach_impl calls (e.g. for shared processes like doc
 # building). python_foreach_impl sets up the build environment itself.
 #
-# If the specific commands support only a subset of Python
-# implementations, patterns need to be passed to restrict the allowed
-# implementations.
-#
-# Example:
+# Pure mode example:
 # @CODE
 # DEPEND="doc? ( dev-python/epydoc[$(python_gen_usedep 'python2*')] )"
 # REQUIRED_USE="doc? ( $(python_gen_useflags 'python2*') )"
@@ -603,6 +617,9 @@ python_setup() {
 		pycompat=( ${PYTHON_COMPAT_OVERRIDE} )
 	fi
 
+	local has_check_deps
+	declare -f python_check_deps >/dev/null && has_check_deps=1
+
 	# (reverse iteration -- newest impl first)
 	local found
 	for (( i = ${#_PYTHON_SUPPORTED_IMPLS[@]} - 1; i >= 0; i-- )); do
@@ -612,7 +629,8 @@ python_setup() {
 		has "${impl}" "${pycompat[@]}" || continue
 
 		# match USE flags only if override is not in effect
-		if [[ ! ${PYTHON_COMPAT_OVERRIDE} ]]; then
+		# and python_check_deps() is not defined
+		if [[ ! ${PYTHON_COMPAT_OVERRIDE} && ! ${has_check_deps} ]]; then
 			use "python_targets_${impl}" || continue
 		fi
 
@@ -620,6 +638,16 @@ python_setup() {
 		_python_impl_matches "${impl}" "${@-*}" || continue
 
 		python_export "${impl}" EPYTHON PYTHON
+
+		# if python_check_deps() is declared, switch into any-of mode
+		if [[ ${has_check_deps} ]]; then
+			# first check if the interpreter is installed
+			python_is_installed "${impl}" || continue
+			# then run python_check_deps
+			local PYTHON_USEDEP="python_targets_${impl}(-),python_single_target_${impl}(+)"
+			python_check_deps || continue
+		fi
+
 		found=1
 		break
 	done
-- 
2.13.0



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

* [gentoo-dev] [PATCH 5/7] python-r1.eclass: Add python_gen_any_dep, to create any-of deps
  2017-05-20 13:30 [gentoo-dev] [PATCHES] python-r1.eclass: any-of dep API support Michał Górny
                   ` (3 preceding siblings ...)
  2017-05-20 13:30 ` [gentoo-dev] [PATCH 4/7] python-r1.eclass: Support python_check_deps() in python_setup Michał Górny
@ 2017-05-20 13:30 ` Michał Górny
  2017-05-20 13:30 ` [gentoo-dev] [PATCH 6/7] app-portage/gentoopm: Use any-of deps (example) Michał Górny
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Michał Górny @ 2017-05-20 13:30 UTC (permalink / raw)
  To: gentoo-dev; +Cc: python, Michał Górny

Add a python_gen_any_dep() function similar to the one in python-any-r1
to facilitate creating any-of dependencies for the new python_setup
syntax.
---
 eclass/python-r1.eclass | 98 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 98 insertions(+)

diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index 2992f603cf8a..5ec23d23d8cc 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -468,6 +468,86 @@ python_gen_impl_dep() {
 	echo "${matches[@]}"
 }
 
+# @FUNCTION: python_gen_any_dep
+# @USAGE: <dependency-block> [<impl-pattern>...]
+# @DESCRIPTION:
+# Generate an any-of dependency that enforces a version match between
+# the Python interpreter and Python packages. <dependency-block> needs
+# to list one or more dependencies with verbatim '${PYTHON_USEDEP}'
+# references (quoted!) that will get expanded inside the function.
+# Optionally, patterns may be specified to restrict the dependency
+# to a subset of Python implementations supported by the ebuild.
+#
+# The patterns can be either fnmatch-style patterns (matched via bash
+# == operator against PYTHON_COMPAT values) or '-2' / '-3' to indicate
+# appropriately all enabled Python 2/3 implementations (alike
+# python_is_python3). Remember to escape or quote the fnmatch patterns
+# to prevent accidental shell filename expansion.
+#
+# This should be used along with an appropriate python_check_deps()
+# that checks which of the any-of blocks were matched, and python_setup
+# call that enables use of the matched implementation.
+#
+# Example use:
+# @CODE
+# DEPEND="$(python_gen_any_dep '
+#	dev-python/foo[${PYTHON_USEDEP}]
+#	|| ( dev-python/bar[${PYTHON_USEDEP}]
+#		dev-python/baz[${PYTHON_USEDEP}] )' -2)"
+#
+# python_check_deps() {
+#	has_version "dev-python/foo[${PYTHON_USEDEP}]" \
+#		&& { has_version "dev-python/bar[${PYTHON_USEDEP}]" \
+#			|| has_version "dev-python/baz[${PYTHON_USEDEP}]"; }
+# }
+#
+# src_compile() {
+#	python_foreach_impl usual_code
+#
+#	# some common post-build task that requires Python 2
+#	python_setup -2
+#	emake frobnicate
+# }
+# @CODE
+#
+# Example value:
+# @CODE
+# || (
+#	(
+#		dev-lang/python:2.7
+#		dev-python/foo[python_targets_python2_7(-)?,python_single_target_python2_7(+)?]
+#		|| ( dev-python/bar[python_targets_python2_7(-)?,python_single_target_python2_7(+)?]
+#			dev-python/baz[python_targets_python2_7(-)?,python_single_target_python2_7(+)?] )
+#	)
+#	(
+#		dev-lang/python:3.3
+#		dev-python/foo[python_targets_python3_3(-)?,python_single_target_python3_3(+)?]
+#		|| ( dev-python/bar[python_targets_python3_3(-)?,python_single_target_python3_3(+)?]
+#			dev-python/baz[python_targets_python3_3(-)?,python_single_target_python3_3(+)?] )
+#	)
+# )
+# @CODE
+python_gen_any_dep() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	local depstr=${1}
+	[[ ${depstr} ]] || die "No dependency string provided"
+	shift
+
+	local i PYTHON_PKG_DEP out=
+	for i in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
+		if _python_impl_matches "${i}" "${@-*}"; then
+			local PYTHON_USEDEP="python_targets_${i}(-),python_single_target_${i}(+)"
+			python_export "${i}" PYTHON_PKG_DEP
+
+			local i_depstr=${depstr//\$\{PYTHON_USEDEP\}/${PYTHON_USEDEP}}
+			# note: need to strip '=' slot operator for || deps
+			out="( ${PYTHON_PKG_DEP%=} ${i_depstr} ) ${out}"
+		fi
+	done
+	echo "|| ( ${out})"
+}
+
 # @ECLASS-VARIABLE: BUILD_DIR
 # @DESCRIPTION:
 # The current build directory. In global scope, it is supposed to
@@ -608,6 +688,24 @@ python_foreach_impl() {
 #   fi
 # }
 # @CODE
+#
+# Any-of mode example:
+# @CODE
+# DEPEND="doc? (
+#	$(python_gen_any_dep 'dev-python/epydoc[${PYTHON_USEDEP}]' 'python2*') )"
+#
+# python_check_deps() {
+#	has_version "dev-python/epydoc[${PYTHON_USEDEP}]"
+# }
+#
+# src_compile() {
+#   #...
+#   if use doc; then
+#     python_setup 'python2*'
+#     make doc
+#   fi
+# }
+# @CODE
 python_setup() {
 	debug-print-function ${FUNCNAME} "${@}"
 
-- 
2.13.0



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

* [gentoo-dev] [PATCH 6/7] app-portage/gentoopm: Use any-of deps (example)
  2017-05-20 13:30 [gentoo-dev] [PATCHES] python-r1.eclass: any-of dep API support Michał Górny
                   ` (4 preceding siblings ...)
  2017-05-20 13:30 ` [gentoo-dev] [PATCH 5/7] python-r1.eclass: Add python_gen_any_dep, to create any-of deps Michał Górny
@ 2017-05-20 13:30 ` Michał Górny
  2017-05-20 13:30 ` [gentoo-dev] [PATCH 7/7] dev-python/backports-unittest-mock: Use any-of API for Sphinx (example) Michał Górny
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Michał Górny @ 2017-05-20 13:30 UTC (permalink / raw)
  To: gentoo-dev; +Cc: python, Michał Górny

---
 app-portage/gentoopm/gentoopm-9999.ebuild | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/app-portage/gentoopm/gentoopm-9999.ebuild b/app-portage/gentoopm/gentoopm-9999.ebuild
index a4529c98bc9b..220247442d2d 100644
--- a/app-portage/gentoopm/gentoopm-9999.ebuild
+++ b/app-portage/gentoopm/gentoopm-9999.ebuild
@@ -21,10 +21,12 @@ RDEPEND="
 		>=sys-apps/pkgcore-0.9.4[${PYTHON_USEDEP}]
 		>=sys-apps/portage-2.1.10.3[${PYTHON_USEDEP}]
 		>=sys-apps/paludis-3.0.0_pre20170219[python,${PYTHON_USEDEP}] )"
-DEPEND="doc? ( dev-python/epydoc[$(python_gen_usedep python2_7)] )"
+DEPEND="doc? ( $(python_gen_any_dep 'dev-python/epydoc[${PYTHON_USEDEP}]' python2_7) )"
 PDEPEND="app-eselect/eselect-package-manager"
 
-REQUIRED_USE="doc? ( $(python_gen_useflags python2_7) )"
+python_check_deps() {
+	has_version "dev-python/epydoc[${PYTHON_USEDEP}]"
+}
 
 src_configure() {
 	use doc && DISTUTILS_ALL_SUBPHASE_IMPLS=( python2.7 )
-- 
2.13.0



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

* [gentoo-dev] [PATCH 7/7] dev-python/backports-unittest-mock: Use any-of API for Sphinx (example)
  2017-05-20 13:30 [gentoo-dev] [PATCHES] python-r1.eclass: any-of dep API support Michał Górny
                   ` (5 preceding siblings ...)
  2017-05-20 13:30 ` [gentoo-dev] [PATCH 6/7] app-portage/gentoopm: Use any-of deps (example) Michał Górny
@ 2017-05-20 13:30 ` Michał Górny
  2017-05-21  2:44 ` [gentoo-dev] [PATCHES] python-r1.eclass: any-of dep API support Alex Turbov
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Michał Górny @ 2017-05-20 13:30 UTC (permalink / raw)
  To: gentoo-dev; +Cc: python, Michał Górny

---
 .../backports-unittest-mock/backports-unittest-mock-1.2.1.ebuild | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/dev-python/backports-unittest-mock/backports-unittest-mock-1.2.1.ebuild b/dev-python/backports-unittest-mock/backports-unittest-mock-1.2.1.ebuild
index c3c3de101526..5d053726f18b 100644
--- a/dev-python/backports-unittest-mock/backports-unittest-mock-1.2.1.ebuild
+++ b/dev-python/backports-unittest-mock/backports-unittest-mock-1.2.1.ebuild
@@ -23,10 +23,10 @@ IUSE="doc test"
 RDEPEND="dev-python/mock[${PYTHON_USEDEP}]"
 DEPEND="dev-python/setuptools[${PYTHON_USEDEP}]
 	>=dev-python/setuptools_scm-1.15.0[${PYTHON_USEDEP}]
-	doc? (
+	doc? ( $(python_gen_any_dep '
 		dev-python/sphinx[${PYTHON_USEDEP}]
 		dev-python/rst-linker[${PYTHON_USEDEP}]
-	)
+	') )
 	test? (
 		${RDEPEND}
 		>=dev-python/pytest-2.8[${PYTHON_USEDEP}]
@@ -36,6 +36,11 @@ DEPEND="dev-python/setuptools[${PYTHON_USEDEP}]
 
 S="${WORKDIR}/${MY_PN}-${PV}"
 
+python_check_deps() {
+	has_version "dev-python/sphinx[${PYTHON_USEDEP}]" &&
+		has_version "dev-python/rst-linker[${PYTHON_USEDEP}]"
+}
+
 python_compile_all() {
 	if use doc; then
 		cd docs || die
-- 
2.13.0



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

* Re: [gentoo-dev] [PATCHES] python-r1.eclass: any-of dep API support
  2017-05-20 13:30 [gentoo-dev] [PATCHES] python-r1.eclass: any-of dep API support Michał Górny
                   ` (6 preceding siblings ...)
  2017-05-20 13:30 ` [gentoo-dev] [PATCH 7/7] dev-python/backports-unittest-mock: Use any-of API for Sphinx (example) Michał Górny
@ 2017-05-21  2:44 ` Alex Turbov
  2017-05-21  7:30   ` Michał Górny
  2017-05-28  3:59 ` Daniel Campbell
  2017-06-06  6:59 ` Michał Górny
  9 siblings, 1 reply; 12+ messages in thread
From: Alex Turbov @ 2017-05-21  2:44 UTC (permalink / raw)
  To: gentoo-dev; +Cc: python

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

When it'll be possible to start to use it?

On Sat, May 20, 2017 at 8:30 PM, Michał Górny <mgorny@gentoo.org> wrote:

> Hi, everyone.
>
> Here's a set of patches inspired by the recent Sphinx dependency
> discussion. They make python-r1 (and therefore distutils-r1) capable
> of any-of dependency logic similar to the one used in python-any-r1.
>
> The basic goal is relatively simple -- to improve handling of pure
> build-time dependencies in the eclass. It solves two common problems:
>
> a. dependencies on packages that support only a subset of PYTHON_COMPAT,
>
> b. dependencies that need to be implementation-bound between themselves
>    (e.g. Sphinx plugins).
>
> The new API improves both of those cases significantly. For the former,
> we no longer force user to select additional targets via REQUIRED_USE --
> instead, we just any-of dependencies + python_check_deps() to select
> implementation independently of whether it is enabled or not.
>
> For the latter, we no longer have to force all targets of the package
> on all the involved dependencies. Again, using any-of dep
> and appropriate python_check_deps() we can enforce a single (any)
> target throughout all the packages and use it.
>
> The first three patches do some code refactoring that makes the change
> easier and possibly improves maintainability of the code. The next two
> patches add support for python_check_deps() and python_gen_any_dep()
> respectively. The last two patches provide examples for both use cases
> mentioned.
>
> Please review.
>
> --
> Best regards,
> Michał Górny
>
>
>

[-- Attachment #2: Type: text/html, Size: 2004 bytes --]

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

* Re: [gentoo-dev] [PATCHES] python-r1.eclass: any-of dep API support
  2017-05-21  2:44 ` [gentoo-dev] [PATCHES] python-r1.eclass: any-of dep API support Alex Turbov
@ 2017-05-21  7:30   ` Michał Górny
  0 siblings, 0 replies; 12+ messages in thread
From: Michał Górny @ 2017-05-21  7:30 UTC (permalink / raw)
  To: gentoo-dev; +Cc: python

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

On nie, 2017-05-21 at 09:44 +0700, Alex Turbov wrote:
> When it'll be possible to start to use it?
> 

I'll send a reply to the patch when it's committed. Usually takes
a week, unless somebody opposes.

-- 
Best regards,
Michał Górny

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

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

* Re: [gentoo-dev] [PATCHES] python-r1.eclass: any-of dep API support
  2017-05-20 13:30 [gentoo-dev] [PATCHES] python-r1.eclass: any-of dep API support Michał Górny
                   ` (7 preceding siblings ...)
  2017-05-21  2:44 ` [gentoo-dev] [PATCHES] python-r1.eclass: any-of dep API support Alex Turbov
@ 2017-05-28  3:59 ` Daniel Campbell
  2017-06-06  6:59 ` Michał Górny
  9 siblings, 0 replies; 12+ messages in thread
From: Daniel Campbell @ 2017-05-28  3:59 UTC (permalink / raw)
  To: gentoo-dev


[-- Attachment #1.1: Type: text/plain, Size: 663 bytes --]

On 05/20/2017 06:30 AM, Michał Górny wrote:
> 
> 
> Please review.
> 
> --
> Best regards,
> Michał Górny
> 
> 

It looks much as you mentioned it'd be: moving code around and cutting
down duplication. Looks good to me. I really appreciate the example in
patch 7, which makes it a little more clear how to use it. Thanks for
putting all of this together.

I'm not sure how to express this because I don't know which question to
ask. Is there anything I can help with once this gets committed?
-- 
Daniel Campbell - Gentoo Developer
OpenPGP Key: 0x1EA055D6 @ hkp://keys.gnupg.net
fpr: AE03 9064 AE00 053C 270C  1DE4 6F7A 9091 1EA0 55D6


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [gentoo-dev] [PATCHES] python-r1.eclass: any-of dep API support
  2017-05-20 13:30 [gentoo-dev] [PATCHES] python-r1.eclass: any-of dep API support Michał Górny
                   ` (8 preceding siblings ...)
  2017-05-28  3:59 ` Daniel Campbell
@ 2017-06-06  6:59 ` Michał Górny
  9 siblings, 0 replies; 12+ messages in thread
From: Michał Górny @ 2017-06-06  6:59 UTC (permalink / raw)
  To: gentoo-dev; +Cc: python

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

On sob, 2017-05-20 at 15:30 +0200, Michał Górny wrote:
> Hi, everyone.
> 
> Here's a set of patches inspired by the recent Sphinx dependency
> discussion. They make python-r1 (and therefore distutils-r1) capable
> of any-of dependency logic similar to the one used in python-any-r1.
> 
> The basic goal is relatively simple -- to improve handling of pure
> build-time dependencies in the eclass. It solves two common problems:
> 
> a. dependencies on packages that support only a subset of PYTHON_COMPAT,
> 
> b. dependencies that need to be implementation-bound between themselves
>    (e.g. Sphinx plugins).
> 
> The new API improves both of those cases significantly. For the former,
> we no longer force user to select additional targets via REQUIRED_USE --
> instead, we just any-of dependencies + python_check_deps() to select
> implementation independently of whether it is enabled or not.
> 
> For the latter, we no longer have to force all targets of the package
> on all the involved dependencies. Again, using any-of dep
> and appropriate python_check_deps() we can enforce a single (any)
> target throughout all the packages and use it.
> 
> The first three patches do some code refactoring that makes the change
> easier and possibly improves maintainability of the code. The next two
> patches add support for python_check_deps() and python_gen_any_dep()
> respectively. The last two patches provide examples for both use cases
> mentioned.
> 

Merged them a while back.

-- 
Best regards,
Michał Górny

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

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

end of thread, other threads:[~2017-06-06  7:01 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-20 13:30 [gentoo-dev] [PATCHES] python-r1.eclass: any-of dep API support Michał Górny
2017-05-20 13:30 ` [gentoo-dev] [PATCH 1/7] distutils-r1.eclass: Reuse python_setup for common phases Michał Górny
2017-05-20 13:30 ` [gentoo-dev] [PATCH 2/7] python-r1.eclass: Move PYTHON_COMPAT_OVERRIDE warning into flag check Michał Górny
2017-05-20 13:30 ` [gentoo-dev] [PATCH 3/7] python-r1.eclass: Inline implementation loop logic into python_setup Michał Górny
2017-05-20 13:30 ` [gentoo-dev] [PATCH 4/7] python-r1.eclass: Support python_check_deps() in python_setup Michał Górny
2017-05-20 13:30 ` [gentoo-dev] [PATCH 5/7] python-r1.eclass: Add python_gen_any_dep, to create any-of deps Michał Górny
2017-05-20 13:30 ` [gentoo-dev] [PATCH 6/7] app-portage/gentoopm: Use any-of deps (example) Michał Górny
2017-05-20 13:30 ` [gentoo-dev] [PATCH 7/7] dev-python/backports-unittest-mock: Use any-of API for Sphinx (example) Michał Górny
2017-05-21  2:44 ` [gentoo-dev] [PATCHES] python-r1.eclass: any-of dep API support Alex Turbov
2017-05-21  7:30   ` Michał Górny
2017-05-28  3:59 ` Daniel Campbell
2017-06-06  6:59 ` 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