-# 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
# (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).
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