* [gentoo-dev] [PATCHES] python-r1 suite: minor fixes
@ 2017-05-20 8:56 Michał Górny
2017-05-20 8:56 ` [gentoo-dev] [PATCH 1/4] python-any-r1.eclass: python_gen_any_dep, add missing 'local i' Michał Górny
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Michał Górny @ 2017-05-20 8:56 UTC (permalink / raw
To: gentoo-dev; +Cc: python
Hi,
Here's a quick set of minor patches to python-r1 suite. It mostly
includes some fixes to issues I've noticed while working on something
bigger ;-).
The first patch merely fixes missing 'local' for a variable. The second
adds REQUIRED_USE to the python_setup() use example in python-r1.
The third converts distutils-r1 common impl support to use the new
pattern matching function (which is an omission from the original set
of patches).
The fourth patch is most interesting of all -- it makes the pattern
matching work well with mismatched PYTHON_COMPAT/EPYTHON-style impls.
This makes the API more lax, and avoids requiring users to be aware
of technically implied impl style restrictions, i.e. having to write:
REQUIRED_USE="doc? ( || ( $(python_gen_useflags 'python2_*') ) )"
src_compile() {
use doc && python_setup 'python2.*'
}
Note that flags used PYTHON_COMPAT form (with '_') while setup functions
used EPYTHON form (with '.'). Now both are equally happy with both
forms.
--
Best regards,
Michał Górny
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gentoo-dev] [PATCH 1/4] python-any-r1.eclass: python_gen_any_dep, add missing 'local i'
2017-05-20 8:56 [gentoo-dev] [PATCHES] python-r1 suite: minor fixes Michał Górny
@ 2017-05-20 8:56 ` Michał Górny
2017-05-20 8:56 ` [gentoo-dev] [PATCH 2/4] python-r1.eclass: python_setup, add REQUIRED_USE to the example Michał Górny
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Michał Górny @ 2017-05-20 8:56 UTC (permalink / raw
To: gentoo-dev; +Cc: python, Michał Górny
---
eclass/python-any-r1.eclass | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass
index 69f7bb736d22..e4d2d46bc706 100644
--- a/eclass/python-any-r1.eclass
+++ b/eclass/python-any-r1.eclass
@@ -224,7 +224,7 @@ python_gen_any_dep() {
local depstr=${1}
[[ ${depstr} ]] || die "No dependency string provided"
- local PYTHON_PKG_DEP out=
+ local i PYTHON_PKG_DEP out=
for i in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
local PYTHON_USEDEP="python_targets_${i}(-),python_single_target_${i}(+)"
python_export "${i}" PYTHON_PKG_DEP
--
2.13.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-dev] [PATCH 2/4] python-r1.eclass: python_setup, add REQUIRED_USE to the example
2017-05-20 8:56 [gentoo-dev] [PATCHES] python-r1 suite: minor fixes Michał Górny
2017-05-20 8:56 ` [gentoo-dev] [PATCH 1/4] python-any-r1.eclass: python_gen_any_dep, add missing 'local i' Michał Górny
@ 2017-05-20 8:56 ` Michał Górny
2017-05-20 8:56 ` [gentoo-dev] [PATCH 3/4] distutils-r1.eclass: Use _python_impl_matches() Michał Górny
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Michał Górny @ 2017-05-20 8:56 UTC (permalink / raw
To: gentoo-dev; +Cc: python, Michał Górny
---
eclass/python-r1.eclass | 1 +
1 file changed, 1 insertion(+)
diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index 8de0a851856c..809dc5f2b8e5 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -614,6 +614,7 @@ python_parallel_foreach_impl() {
# Example:
# @CODE
# DEPEND="doc? ( dev-python/epydoc[$(python_gen_usedep 'python2*')] )"
+# REQUIRED_USE="doc? ( $(python_gen_useflags 'python2*') )"
#
# src_compile() {
# #...
--
2.13.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-dev] [PATCH 3/4] distutils-r1.eclass: Use _python_impl_matches()
2017-05-20 8:56 [gentoo-dev] [PATCHES] python-r1 suite: minor fixes Michał Górny
2017-05-20 8:56 ` [gentoo-dev] [PATCH 1/4] python-any-r1.eclass: python_gen_any_dep, add missing 'local i' Michał Górny
2017-05-20 8:56 ` [gentoo-dev] [PATCH 2/4] python-r1.eclass: python_setup, add REQUIRED_USE to the example Michał Górny
@ 2017-05-20 8:56 ` Michał Górny
2017-05-20 8:56 ` [gentoo-dev] [PATCH 4/4] python-utils-r1.eclass: _python_impl_matches, handle both forms of impl Michał Górny
2017-06-06 6:59 ` [gentoo-dev] [PATCHES] python-r1 suite: minor fixes Michał Górny
4 siblings, 0 replies; 6+ messages in thread
From: Michał Górny @ 2017-05-20 8:56 UTC (permalink / raw
To: gentoo-dev; +Cc: python, Michał Górny
Update the missed occurence of pattern matching with the new framework.
---
eclass/distutils-r1.eclass | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 1376326c9579..6078fb6d52b7 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2016 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: distutils-r1.eclass
@@ -191,6 +191,12 @@ fi
# (allowing any implementation). If multiple values are specified,
# implementations matching any of the patterns will be accepted.
#
+# 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.
+#
# If the restriction needs to apply conditionally to a USE flag,
# the variable should be set conditionally as well (e.g. in an early
# phase function or other convenient location).
@@ -669,12 +675,9 @@ _distutils-r1_run_common_phase() {
if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then
local best_impl patterns=( "${DISTUTILS_ALL_SUBPHASE_IMPLS[@]-*}" )
_distutils_try_impl() {
- local pattern
- for pattern in "${patterns[@]}"; do
- if [[ ${EPYTHON} == ${pattern} ]]; then
- best_impl=${MULTIBUILD_VARIANT}
- fi
- done
+ if _python_impl_matches "${EPYTHON}" "${patterns[@]}"; then
+ best_impl=${MULTIBUILD_VARIANT}
+ fi
}
python_foreach_impl _distutils_try_impl
unset -f _distutils_try_impl
--
2.13.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-dev] [PATCH 4/4] python-utils-r1.eclass: _python_impl_matches, handle both forms of impl
2017-05-20 8:56 [gentoo-dev] [PATCHES] python-r1 suite: minor fixes Michał Górny
` (2 preceding siblings ...)
2017-05-20 8:56 ` [gentoo-dev] [PATCH 3/4] distutils-r1.eclass: Use _python_impl_matches() Michał Górny
@ 2017-05-20 8:56 ` Michał Górny
2017-06-06 6:59 ` [gentoo-dev] [PATCHES] python-r1 suite: minor fixes Michał Górny
4 siblings, 0 replies; 6+ messages in thread
From: Michał Górny @ 2017-05-20 8:56 UTC (permalink / raw
To: gentoo-dev; +Cc: python, Michał Górny
Make the pattern matching code in _python_impl_matches() more lax,
allowing (accidental) mixing of PYTHON_COMPAT-style values with
EPYTHON-style values. This is trivial to do, and solves the problem
introduced by complexity-by-limitation of other eclasses -- where
patterns for dependency strings are using PYTHON_COMPAT syntax,
and patterns for python_setup are using EPYTHON syntax.
---
eclass/python-utils-r1.eclass | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 0bf7e7ec1a3e..68fb9ba2578d 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -169,7 +169,8 @@ _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 can be either:
+# <impl> can be in PYTHON_COMPAT or EPYTHON 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)
@@ -186,7 +187,8 @@ _python_impl_matches() {
elif [[ ${pattern} == -3 ]]; then
python_is_python3 "${impl}"
return
- elif [[ ${impl} == ${pattern} ]]; then
+ # unify value style to allow lax matching
+ elif [[ ${impl/./_} == ${pattern/./_} ]]; then
return 0
fi
done
--
2.13.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [gentoo-dev] [PATCHES] python-r1 suite: minor fixes
2017-05-20 8:56 [gentoo-dev] [PATCHES] python-r1 suite: minor fixes Michał Górny
` (3 preceding siblings ...)
2017-05-20 8:56 ` [gentoo-dev] [PATCH 4/4] python-utils-r1.eclass: _python_impl_matches, handle both forms of impl Michał Górny
@ 2017-06-06 6:59 ` Michał Górny
4 siblings, 0 replies; 6+ 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: 1206 bytes --]
On sob, 2017-05-20 at 10:56 +0200, Michał Górny wrote:
> Hi,
>
> Here's a quick set of minor patches to python-r1 suite. It mostly
> includes some fixes to issues I've noticed while working on something
> bigger ;-).
>
> The first patch merely fixes missing 'local' for a variable. The second
> adds REQUIRED_USE to the python_setup() use example in python-r1.
> The third converts distutils-r1 common impl support to use the new
> pattern matching function (which is an omission from the original set
> of patches).
>
> The fourth patch is most interesting of all -- it makes the pattern
> matching work well with mismatched PYTHON_COMPAT/EPYTHON-style impls.
> This makes the API more lax, and avoids requiring users to be aware
> of technically implied impl style restrictions, i.e. having to write:
>
> REQUIRED_USE="doc? ( || ( $(python_gen_useflags 'python2_*') ) )"
>
> src_compile() {
> use doc && python_setup 'python2.*'
> }
>
> Note that flags used PYTHON_COMPAT form (with '_') while setup functions
> used EPYTHON form (with '.'). Now both are equally happy with both
> forms.
>
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] 6+ messages in thread
end of thread, other threads:[~2017-06-06 6:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-20 8:56 [gentoo-dev] [PATCHES] python-r1 suite: minor fixes Michał Górny
2017-05-20 8:56 ` [gentoo-dev] [PATCH 1/4] python-any-r1.eclass: python_gen_any_dep, add missing 'local i' Michał Górny
2017-05-20 8:56 ` [gentoo-dev] [PATCH 2/4] python-r1.eclass: python_setup, add REQUIRED_USE to the example Michał Górny
2017-05-20 8:56 ` [gentoo-dev] [PATCH 3/4] distutils-r1.eclass: Use _python_impl_matches() Michał Górny
2017-05-20 8:56 ` [gentoo-dev] [PATCH 4/4] python-utils-r1.eclass: _python_impl_matches, handle both forms of impl Michał Górny
2017-06-06 6:59 ` [gentoo-dev] [PATCHES] python-r1 suite: minor fixes 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