public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 1/3] python-utils-r1.eclass: Allow -2/-3 as impl-patterns for py2/py3
@ 2017-05-10 18:53 Michał Górny
  2017-05-10 18:53 ` [gentoo-dev] [PATCH 2/3] virtual/python-futures: Use -2 operator to python_gen_usedep (example) Michał Górny
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Michał Górny @ 2017-05-10 18:53 UTC (permalink / raw
  To: gentoo-dev; +Cc: python, Michał Górny

Allow two special values in the implementation patterns for
_python_impl_matches(): -2 to indicate all Python 2-compatible
implementations, and -3 to indicate all Python 3-compatible
implementations. Both of those values are implemented using
the python_is_python3 function.

This is mostly meant to make it easier and more fool-proof to write
dependencies on backports to Python 2 which in most cases apply to PyPy2
as well.
---
 eclass/python-utils-r1.eclass | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 7efec083e35e..703246933acc 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -156,8 +156,10 @@ _python_set_impls() {
 # Check whether the specified <impl> matches at least one
 # of the patterns following it. Return 0 if it does, 1 otherwise.
 #
-# <impl> should be in PYTHON_COMPAT form. The patterns are fnmatch-style
-# patterns.
+# <impl> should be in PYTHON_COMPAT form. The patterns can be either:
+# a) fnmatch-style patterns, e.g. 'python2*', 'pypy'...
+# b) '-2' to indicate all Python 2 variants (= !python_is_python3)
+# c) '-3' to indicate all Python 3 variants (= python_is_python3)
 _python_impl_matches() {
 	[[ ${#} -ge 2 ]] || die "${FUNCNAME}: takes at least 2 parameters"
 
@@ -165,7 +167,13 @@ _python_impl_matches() {
 	shift
 
 	for pattern; do
-		if [[ ${impl} == ${pattern} ]]; then
+		if [[ ${pattern} == -2 ]]; then
+			! python_is_python3 "${impl}"
+			return
+		elif [[ ${pattern} == -3 ]]; then
+			python_is_python3 "${impl}"
+			return
+		elif [[ ${impl} == ${pattern} ]]; then
 			return 0
 		fi
 	done
-- 
2.13.0



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

* [gentoo-dev] [PATCH 2/3] virtual/python-futures: Use -2 operator to python_gen_usedep (example)
  2017-05-10 18:53 [gentoo-dev] [PATCH 1/3] python-utils-r1.eclass: Allow -2/-3 as impl-patterns for py2/py3 Michał Górny
@ 2017-05-10 18:53 ` Michał Górny
  2017-05-10 18:53 ` [gentoo-dev] [PATCH 3/3] virtual/python-dnspython: Use -2/-3 operators " Michał Górny
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Michał Górny @ 2017-05-10 18:53 UTC (permalink / raw
  To: gentoo-dev; +Cc: python, Michał Górny

---
 virtual/python-futures/python-futures-0.ebuild | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/virtual/python-futures/python-futures-0.ebuild b/virtual/python-futures/python-futures-0.ebuild
index 094a0c6dbdd8..d810a9cc3261 100644
--- a/virtual/python-futures/python-futures-0.ebuild
+++ b/virtual/python-futures/python-futures-0.ebuild
@@ -13,4 +13,4 @@ KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ppc ppc64 ~s390 ~sh sparc x86"
 REQUIRED_USE="${PYTHON_REQUIRED_USE}"
 
 RDEPEND="${PYTHON_DEPS}
-	$(python_gen_cond_dep 'dev-python/futures[${PYTHON_USEDEP}]' python2_7 pypy)"
+	$(python_gen_cond_dep 'dev-python/futures[${PYTHON_USEDEP}]' -2)"
-- 
2.13.0



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

* [gentoo-dev] [PATCH 3/3] virtual/python-dnspython: Use -2/-3 operators to python_gen_usedep (example)
  2017-05-10 18:53 [gentoo-dev] [PATCH 1/3] python-utils-r1.eclass: Allow -2/-3 as impl-patterns for py2/py3 Michał Górny
  2017-05-10 18:53 ` [gentoo-dev] [PATCH 2/3] virtual/python-futures: Use -2 operator to python_gen_usedep (example) Michał Górny
@ 2017-05-10 18:53 ` Michał Górny
  2017-05-10 20:32 ` [gentoo-dev] Re: [PATCH 1/3] python-utils-r1.eclass: Allow -2/-3 as impl-patterns for py2/py3 Mike Gilbert
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Michał Górny @ 2017-05-10 18:53 UTC (permalink / raw
  To: gentoo-dev; +Cc: python, Michał Górny

---
 virtual/python-dnspython/python-dnspython-1.ebuild | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/virtual/python-dnspython/python-dnspython-1.ebuild b/virtual/python-dnspython/python-dnspython-1.ebuild
index 063bbe7ce66f..885153f90caf 100644
--- a/virtual/python-dnspython/python-dnspython-1.ebuild
+++ b/virtual/python-dnspython/python-dnspython-1.ebuild
@@ -14,6 +14,6 @@ REQUIRED_USE="${PYTHON_REQUIRED_USE}"
 
 RDEPEND="${PYTHON_DEPS}
 	!dev-python/dnspython:0
-	$(python_gen_cond_dep 'dev-python/dnspython:py2[${PYTHON_USEDEP}]' python2*)
-	$(python_gen_cond_dep 'dev-python/dnspython:py3[${PYTHON_USEDEP}]' python3*)"
+	$(python_gen_cond_dep 'dev-python/dnspython:py2[${PYTHON_USEDEP}]' -2)
+	$(python_gen_cond_dep 'dev-python/dnspython:py3[${PYTHON_USEDEP}]' -3)"
 DEPEND="!dev-python/dnspython:0"
-- 
2.13.0



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

* [gentoo-dev] Re: [PATCH 1/3] python-utils-r1.eclass: Allow -2/-3 as impl-patterns for py2/py3
  2017-05-10 18:53 [gentoo-dev] [PATCH 1/3] python-utils-r1.eclass: Allow -2/-3 as impl-patterns for py2/py3 Michał Górny
  2017-05-10 18:53 ` [gentoo-dev] [PATCH 2/3] virtual/python-futures: Use -2 operator to python_gen_usedep (example) Michał Górny
  2017-05-10 18:53 ` [gentoo-dev] [PATCH 3/3] virtual/python-dnspython: Use -2/-3 operators " Michał Górny
@ 2017-05-10 20:32 ` Mike Gilbert
  2017-05-10 21:15 ` [gentoo-dev] " Patrick McLean
  2017-05-16 17:20 ` Michał Górny
  4 siblings, 0 replies; 7+ messages in thread
From: Mike Gilbert @ 2017-05-10 20:32 UTC (permalink / raw
  To: Michał Górny; +Cc: Gentoo Dev, Gentoo Python Project

On Wed, May 10, 2017 at 2:53 PM, Michał Górny <mgorny@gentoo.org> wrote:
> Allow two special values in the implementation patterns for
> _python_impl_matches(): -2 to indicate all Python 2-compatible
> implementations, and -3 to indicate all Python 3-compatible
> implementations. Both of those values are implemented using
> the python_is_python3 function.
>
> This is mostly meant to make it easier and more fool-proof to write
> dependencies on backports to Python 2 which in most cases apply to PyPy2
> as well.

Seems reasonable to me.


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

* Re: [gentoo-dev] [PATCH 1/3] python-utils-r1.eclass: Allow -2/-3 as impl-patterns for py2/py3
  2017-05-10 18:53 [gentoo-dev] [PATCH 1/3] python-utils-r1.eclass: Allow -2/-3 as impl-patterns for py2/py3 Michał Górny
                   ` (2 preceding siblings ...)
  2017-05-10 20:32 ` [gentoo-dev] Re: [PATCH 1/3] python-utils-r1.eclass: Allow -2/-3 as impl-patterns for py2/py3 Mike Gilbert
@ 2017-05-10 21:15 ` Patrick McLean
  2017-05-10 21:36   ` Michał Górny
  2017-05-16 17:20 ` Michał Górny
  4 siblings, 1 reply; 7+ messages in thread
From: Patrick McLean @ 2017-05-10 21:15 UTC (permalink / raw
  To: Michał Górny; +Cc: gentoo-dev, python

On Wed, 10 May 2017 20:53:31 +0200
Michał Górny <mgorny@gentoo.org> wrote:

> Allow two special values in the implementation patterns for
> _python_impl_matches(): -2 to indicate all Python 2-compatible
> implementations, and -3 to indicate all Python 3-compatible
> implementations. Both of those values are implemented using
> the python_is_python3 function.

Seems mostly reasonable, though the syntax is somewhat confusing at
first glance. There are many places where we use "-value" to negate, so
this looks like it means "not python 2" rather than "all python 2".
Perhaps something like '+2' would make it easier to read.

> This is mostly meant to make it easier and more fool-proof to write
> dependencies on backports to Python 2 which in most cases apply to
> PyPy2 as well.


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

* Re: [gentoo-dev] [PATCH 1/3] python-utils-r1.eclass: Allow -2/-3 as impl-patterns for py2/py3
  2017-05-10 21:15 ` [gentoo-dev] " Patrick McLean
@ 2017-05-10 21:36   ` Michał Górny
  0 siblings, 0 replies; 7+ messages in thread
From: Michał Górny @ 2017-05-10 21:36 UTC (permalink / raw
  To: gentoo-dev; +Cc: python

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

On śro, 2017-05-10 at 14:15 -0700, Patrick McLean wrote:
> On Wed, 10 May 2017 20:53:31 +0200
> Michał Górny <mgorny@gentoo.org> wrote:
> 
> > Allow two special values in the implementation patterns for
> > _python_impl_matches(): -2 to indicate all Python 2-compatible
> > implementations, and -3 to indicate all Python 3-compatible
> > implementations. Both of those values are implemented using
> > the python_is_python3 function.
> 
> Seems mostly reasonable, though the syntax is somewhat confusing at
> first glance. There are many places where we use "-value" to negate, so
> this looks like it means "not python 2" rather than "all python 2".
> Perhaps something like '+2' would make it easier to read.

Well, it was supposed to correspond to option parameters, so that it
doesn't collide with regular template matching. But '+' works for me
too, same as anything. Or '@2'. Or '${py2}' ;-P.

> 
> > This is mostly meant to make it easier and more fool-proof to write
> > dependencies on backports to Python 2 which in most cases apply to
> > PyPy2 as well.
> 
> 

-- 
Best regards,
Michał Górny

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

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

* Re: [gentoo-dev] [PATCH 1/3] python-utils-r1.eclass: Allow -2/-3 as impl-patterns for py2/py3
  2017-05-10 18:53 [gentoo-dev] [PATCH 1/3] python-utils-r1.eclass: Allow -2/-3 as impl-patterns for py2/py3 Michał Górny
                   ` (3 preceding siblings ...)
  2017-05-10 21:15 ` [gentoo-dev] " Patrick McLean
@ 2017-05-16 17:20 ` Michał Górny
  4 siblings, 0 replies; 7+ messages in thread
From: Michał Górny @ 2017-05-16 17:20 UTC (permalink / raw
  To: gentoo-dev; +Cc: python

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

On śro, 2017-05-10 at 20:53 +0200, Michał Górny wrote:
> Allow two special values in the implementation patterns for
> _python_impl_matches(): -2 to indicate all Python 2-compatible
> implementations, and -3 to indicate all Python 3-compatible
> implementations. Both of those values are implemented using
> the python_is_python3 function.
> 
> This is mostly meant to make it easier and more fool-proof to write
> dependencies on backports to Python 2 which in most cases apply to PyPy2
> as well.
> ---
>  eclass/python-utils-r1.eclass | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
> index 7efec083e35e..703246933acc 100644
> --- a/eclass/python-utils-r1.eclass
> +++ b/eclass/python-utils-r1.eclass
> @@ -156,8 +156,10 @@ _python_set_impls() {
>  # Check whether the specified <impl> matches at least one
>  # of the patterns following it. Return 0 if it does, 1 otherwise.
>  #
> -# <impl> should be in PYTHON_COMPAT form. The patterns are fnmatch-style
> -# patterns.
> +# <impl> should be in PYTHON_COMPAT form. The patterns can be either:
> +# a) fnmatch-style patterns, e.g. 'python2*', 'pypy'...
> +# b) '-2' to indicate all Python 2 variants (= !python_is_python3)
> +# c) '-3' to indicate all Python 3 variants (= python_is_python3)
>  _python_impl_matches() {
>  	[[ ${#} -ge 2 ]] || die "${FUNCNAME}: takes at least 2 parameters"
>  
> @@ -165,7 +167,13 @@ _python_impl_matches() {
>  	shift
>  
>  	for pattern; do
> -		if [[ ${impl} == ${pattern} ]]; then
> +		if [[ ${pattern} == -2 ]]; then
> +			! python_is_python3 "${impl}"
> +			return
> +		elif [[ ${pattern} == -3 ]]; then
> +			python_is_python3 "${impl}"
> +			return
> +		elif [[ ${impl} == ${pattern} ]]; then
>  			return 0
>  		fi
>  	done

Committed.

-- 
Best regards,
Michał Górny

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

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

end of thread, other threads:[~2017-05-16 17:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-10 18:53 [gentoo-dev] [PATCH 1/3] python-utils-r1.eclass: Allow -2/-3 as impl-patterns for py2/py3 Michał Górny
2017-05-10 18:53 ` [gentoo-dev] [PATCH 2/3] virtual/python-futures: Use -2 operator to python_gen_usedep (example) Michał Górny
2017-05-10 18:53 ` [gentoo-dev] [PATCH 3/3] virtual/python-dnspython: Use -2/-3 operators " Michał Górny
2017-05-10 20:32 ` [gentoo-dev] Re: [PATCH 1/3] python-utils-r1.eclass: Allow -2/-3 as impl-patterns for py2/py3 Mike Gilbert
2017-05-10 21:15 ` [gentoo-dev] " Patrick McLean
2017-05-10 21:36   ` Michał Górny
2017-05-16 17:20 ` 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