[gentoo-dev] [PATCH 07/30] python-utils-r1.eclass: Add function to run python_check_deps()

2022-02-06 Thread Michał Górny
Add a function encompassing the common logic to run python_check_deps()
from python-any-r1 and python-r1.

Signed-off-by: Michał Górny 
---
 eclass/python-any-r1.eclass   | 32 
 eclass/python-r1.eclass   |  7 +--
 eclass/python-utils-r1.eclass | 20 
 3 files changed, 25 insertions(+), 34 deletions(-)

diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass
index 4c832384ed7a..8d3af399b4be 100644
--- a/eclass/python-any-r1.eclass
+++ b/eclass/python-any-r1.eclass
@@ -271,31 +271,6 @@ python_gen_any_dep() {
echo "|| ( ${out})"
 }
 
-# @FUNCTION: _python_EPYTHON_supported
-# @USAGE: 
-# @INTERNAL
-# @DESCRIPTION:
-# Check whether the specified implementation is supported by package
-# (specified in PYTHON_COMPAT). Calls python_check_deps() if declared.
-_python_EPYTHON_supported() {
-   debug-print-function ${FUNCNAME} "${@}"
-
-   local EPYTHON=${1}
-   local i=${EPYTHON/./_}
-
-   if python_is_installed "${i}"; then
-   if declare -f python_check_deps >/dev/null; then
-   local PYTHON_USEDEP="python_targets_${i}(-)"
-   local 
PYTHON_SINGLE_USEDEP="python_single_target_${i}(-)"
-   python_check_deps
-   return ${?}
-   fi
-
-   return 0
-   fi
-   return 1
-}
-
 # @FUNCTION: python_setup
 # @DESCRIPTION:
 # Determine what the best installed (and supported) Python
@@ -330,7 +305,7 @@ python_setup() {
einfo "EPYTHON (${EPYTHON}) not supported by the 
package"
elif ! has "${impl}" "${_PYTHON_ALL_IMPLS[@]}"; then
ewarn "Invalid EPYTHON: ${EPYTHON}"
-   elif _python_EPYTHON_supported "${EPYTHON}"; then
+   elif _python_run_check_deps "${impl}"; then
_python_export EPYTHON PYTHON
_python_wrapper_setup
einfo "Using ${EPYTHON} to build"
@@ -341,8 +316,9 @@ python_setup() {
# fallback to best installed impl.
# (reverse iteration over _PYTHON_SUPPORTED_IMPLS)
for (( i = ${#_PYTHON_SUPPORTED_IMPLS[@]} - 1; i >= 0; i-- )); do
-   _python_export "${_PYTHON_SUPPORTED_IMPLS[i]}" EPYTHON PYTHON
-   if _python_EPYTHON_supported "${EPYTHON}"; then
+   local impl=${_PYTHON_SUPPORTED_IMPLS[i]}
+   _python_export "${impl}" EPYTHON PYTHON
+   if _python_run_check_deps "${impl}"; then
_python_wrapper_setup
einfo "Using ${EPYTHON} to build"
return
diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index f9a9e9465b40..469c3014abfb 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -740,12 +740,7 @@ python_setup() {
 
# 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}(-)"
-   local 
PYTHON_SINGLE_USEDEP="python_single_target_${impl}(-)"
-   python_check_deps || continue
+   _python_run_check_deps "${impl}" || continue
fi
 
found=1
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index c8367f8065f4..f8c0c00ce919 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1368,5 +1368,25 @@ eunittest() {
return ${?}
 }
 
+# @FUNCTION: _python_run_check_deps
+# @INTERNAL
+# @USAGE: 
+# @DESCRIPTION:
+# Verify whether  is an acceptable choice to run any-r1 style
+# code.  Checks whether the interpreter is installed, runs
+# python_check_deps() if declared.
+_python_run_check_deps() {
+   debug-print-function ${FUNCNAME} "${@}"
+
+   local impl=${1}
+
+   python_is_installed "${impl}" || return 1
+   declare -f python_check_deps >/dev/null || return 0
+
+   local PYTHON_USEDEP="python_targets_${impl}(-)"
+   local PYTHON_SINGLE_USEDEP="python_single_target_${impl}(-)"
+   python_check_deps
+}
+
 _PYTHON_UTILS_R1=1
 fi
-- 
2.35.1




[gentoo-dev] [PATCH 08/30] python-any-r1.eclass: Explain the reason for interpreter choice

2022-02-06 Thread Michał Górny
Signed-off-by: Michał Górny 
---
 eclass/python-any-r1.eclass | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass
index 8d3af399b4be..5c01e9eb6888 100644
--- a/eclass/python-any-r1.eclass
+++ b/eclass/python-any-r1.eclass
@@ -294,7 +294,7 @@ python_setup() {
 
_python_export "${impls[0]}" EPYTHON PYTHON
_python_wrapper_setup
-   einfo "Using ${EPYTHON} to build"
+   einfo "Using ${EPYTHON} to build (via PYTHON_COMPAT_OVERRIDE)"
return
fi
 
@@ -308,7 +308,7 @@ python_setup() {
elif _python_run_check_deps "${impl}"; then
_python_export EPYTHON PYTHON
_python_wrapper_setup
-   einfo "Using ${EPYTHON} to build"
+   einfo "Using ${EPYTHON} to build (via EPYTHON)"
return
fi
fi
@@ -320,7 +320,7 @@ python_setup() {
_python_export "${impl}" EPYTHON PYTHON
if _python_run_check_deps "${impl}"; then
_python_wrapper_setup
-   einfo "Using ${EPYTHON} to build"
+   einfo "Using ${EPYTHON} to build (via PYTHON_COMPAT 
iteration)"
return
fi
done
-- 
2.35.1




[gentoo-dev] [PATCH 09/30] python-utils-r1.eclass: Report _python_run_check_deps verbosely

2022-02-06 Thread Michał Górny
Report dep checking progress verbosely, to help users understand why
a particular implementations was rejected or selected.

Signed-off-by: Michał Górny 
---
 eclass/python-utils-r1.eclass | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index f8c0c00ce919..2a83ef463ffd 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1380,12 +1380,20 @@ _python_run_check_deps() {
 
local impl=${1}
 
-   python_is_installed "${impl}" || return 1
+   einfo "Checking whether ${impl} is suitable ..."
+
+   local PYTHON_PKG_DEP
+   _python_export "${impl}" PYTHON_PKG_DEP
+   ebegin "  ${PYTHON_PKG_DEP}"
+   python_is_installed "${impl}"
+   eend ${?} || return 1
declare -f python_check_deps >/dev/null || return 0
 
local PYTHON_USEDEP="python_targets_${impl}(-)"
local PYTHON_SINGLE_USEDEP="python_single_target_${impl}(-)"
+   ebegin "  python_check_deps"
python_check_deps
+   eend ${?}
 }
 
 _PYTHON_UTILS_R1=1
-- 
2.35.1




[gentoo-dev] [PATCH 10/30] python-utils-r1.eclass: Inline python_is_installed

2022-02-06 Thread Michał Górny
Inline the python_is_installed function that is used exactly once
(in _python_run_check_deps).  This helps us avoid having to grab
PYTHON_PKG_DEP twice.

Signed-off-by: Michał Górny 
---
 eclass/python-utils-r1.eclass | 22 +++---
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 2a83ef463ffd..3d938f5ee74f 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -995,24 +995,6 @@ python_is_python3() {
[[ ${impl} == python3* || ${impl} == pypy3 ]]
 }
 
-# @FUNCTION: python_is_installed
-# @USAGE: []
-# @DESCRIPTION:
-# Check whether the interpreter for  (or ${EPYTHON}) is installed.
-# Uses has_version with a proper dependency string.
-#
-# Returns 0 (true) if it is, 1 (false) otherwise.
-python_is_installed() {
-   local impl=${1:-${EPYTHON}}
-   [[ ${impl} ]] || die "${FUNCNAME}: no impl nor EPYTHON"
-   local hasv_args=( -b )
-   [[ ${EAPI} == 6 ]] && hasv_args=( --host-root )
-
-   local PYTHON_PKG_DEP
-   _python_export "${impl}" PYTHON_PKG_DEP
-   has_version "${hasv_args[@]}" "${PYTHON_PKG_DEP}"
-}
-
 # @FUNCTION: python_fix_shebang
 # @USAGE: [-f|--force] [-q|--quiet] ...
 # @DESCRIPTION:
@@ -1379,13 +1361,15 @@ _python_run_check_deps() {
debug-print-function ${FUNCNAME} "${@}"
 
local impl=${1}
+   local hasv_args=( -b )
+   [[ ${EAPI} == 6 ]] && hasv_args=( --host-root )
 
einfo "Checking whether ${impl} is suitable ..."
 
local PYTHON_PKG_DEP
_python_export "${impl}" PYTHON_PKG_DEP
ebegin "  ${PYTHON_PKG_DEP}"
-   python_is_installed "${impl}"
+   has_version "${hasv_args[@]}" "${PYTHON_PKG_DEP}"
eend ${?} || return 1
declare -f python_check_deps >/dev/null || return 0
 
-- 
2.35.1




[gentoo-dev] [PATCH 11/30] distutils-r1.eclass: Fix has_version for distutils_enable_sphinx

2022-02-06 Thread Michał Górny
Fix the has_version calls for distutils_enable_sphinx to use -b option
(--host-root in earlier EAPIs).

Signed-off-by: Michał Górny 
---
 eclass/distutils-r1.eclass | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 814ee85a2b1f..c0b04cf7d997 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -426,9 +426,13 @@ distutils_enable_sphinx() {
 
python_check_deps() {
use doc || return 0
+
+   local hasv_args=( -b )
+   [[ ${EAPI} == 6 ]] && hasv_args=( --host-root )
local p
for p in dev-python/sphinx 
"${_DISTUTILS_SPHINX_PLUGINS[@]}"; do
-   has_version "${p}[${PYTHON_USEDEP}]" || return 1
+   has_version "${hasv_args[@]}" 
"${p}[${PYTHON_USEDEP}]" ||
+   return 1
done
}
else
-- 
2.35.1




[gentoo-dev] [PATCH 12/30] python-utils-r1.eclass: Add a verbose python_has_version() wrapper

2022-02-06 Thread Michał Górny
Add a python_has_version() wrapper that runs has_version in a verbose
way that makes python_check_deps() failures easier to understand.

Signed-off-by: Michał Górny 
---
 eclass/python-utils-r1.eclass | 16 
 1 file changed, 16 insertions(+)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 3d938f5ee74f..c3726437cb68 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1380,5 +1380,21 @@ _python_run_check_deps() {
eend ${?}
 }
 
+# @FUNCTION: python_has_version
+# @USAGE: [-b|-d|-r] 
+# @DESCRIPTION:
+# A wrapper for has_version() with verbose output suitable for
+# python_check_deps.
+python_has_version() {
+   debug-print-function ${FUNCNAME} "${@}"
+
+   local pkg=${1}
+   [[ ${pkg} == -* ]] && pkg=${2}
+
+   ebegin "${pkg}"
+   has_version "${@}"
+   eend ${?}
+}
+
 _PYTHON_UTILS_R1=1
 fi
-- 
2.35.1




[gentoo-dev] [PATCH 13/30] distutils-r1.eclass: Use python_has_version in ...enable_sphinx

2022-02-06 Thread Michał Górny
Signed-off-by: Michał Górny 
---
 eclass/distutils-r1.eclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index c0b04cf7d997..295263b62420 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -431,7 +431,7 @@ distutils_enable_sphinx() {
[[ ${EAPI} == 6 ]] && hasv_args=( --host-root )
local p
for p in dev-python/sphinx 
"${_DISTUTILS_SPHINX_PLUGINS[@]}"; do
-   has_version "${hasv_args[@]}" 
"${p}[${PYTHON_USEDEP}]" ||
+   python_has_version "${hasv_args[@]}" 
"${p}[${PYTHON_USEDEP}]" ||
return 1
done
}
-- 
2.35.1




[gentoo-dev] [PATCH 14/30] python-utils-r1.eclass: Fix sphinx_build for non-autodoc case

2022-02-06 Thread Michał Górny
Fix the regression in calling sphinx-build for the non-autodoc case
that causes the build to fail if dev-python/sphinx isn't built
for the newest Python interpreter available.  To account for this,
we need to call sphinx-build as an executable (i.e. via python-exec).

Ideally, build_sphinx would be aware of which case it is used for,
and use appropriate invocation.  Unfortunately, we cannot do that
without breaking backwards compatibility.  However, we can simply check
if Sphinx is available via ${EPYTHON}, and fall back to calling
python-exec directly.  This is effectively equivalent to choosing
the specific invocation directly, as python-exec would have respected
the implementation specified by EPYTHON anyway if sphinx-build
executable was available for it.

Fixes: f6a17acb8b7c (...: Run sphinx-build via EPYTHON)
Signed-off-by: Michał Górny 
---
 eclass/python-utils-r1.eclass | 22 ++
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index c3726437cb68..362e55aed06f 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -1231,10 +1231,24 @@ build_sphinx() {
 
sed -i -e 's:^intersphinx_mapping:disabled_&:' \
"${dir}"/conf.py || die
-   # not all packages include the Makefile in pypi tarball
-   "${EPYTHON}" -m sphinx.cmd.build \
-   -b html -d "${dir}"/_build/doctrees "${dir}" \
-   "${dir}"/_build/html || die
+   # 1. not all packages include the Makefile in pypi tarball,
+   # so we call sphinx-build directly
+   # 2. if autodoc is used, we need to call sphinx via EPYTHON,
+   # to ensure that PEP 517 venv is respected
+   # 3. if autodoc is not used, then sphinx might not be installed
+   # for the current impl, so we need a fallback to sphinx-build
+   local command=( "${EPYTHON}" -m sphinx.cmd.build )
+   if ! "${EPYTHON}" -c "import sphinx.cmd.build" 2>/dev/null; then
+   command=( sphinx-build )
+   fi
+   command+=(
+   -b html
+   -d "${dir}"/_build/doctrees
+   "${dir}"
+   "${dir}"/_build/html
+   )
+   echo "${command[@]}" >&2
+   "${command[@]}" || die
 
HTML_DOCS+=( "${dir}/_build/html/." )
 }
-- 
2.35.1




[gentoo-dev] [PATCH 15/30] python-utils-r1.eclass: Remove deprecated python_export

2022-02-06 Thread Michał Górny
Remove python_export, as it is no longer used by any ebuilds
in ::gentoo.

Signed-off-by: Michał Górny 
---
 eclass/python-utils-r1.eclass | 17 -
 1 file changed, 17 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 362e55aed06f..99662c0a2e16 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -266,23 +266,6 @@ _python_impl_matches() {
 # python2.7
 # @CODE
 
-# @FUNCTION: python_export
-# @USAGE: [] ...
-# @INTERNAL
-# @DESCRIPTION:
-# Backwards compatibility function.  The relevant API is now considered
-# private, please use python_get* instead.
-python_export() {
-   debug-print-function ${FUNCNAME} "${@}"
-
-   eqawarn "python_export() is part of private eclass API."
-   eqawarn "Please call python_get*() instead."
-
-   [[ ${EAPI} == [67] ]] || die "${FUNCNAME} banned in EAPI ${EAPI}"
-
-   _python_export "${@}"
-}
-
 # @FUNCTION: _python_export
 # @USAGE: [] ...
 # @INTERNAL
-- 
2.35.1




[gentoo-dev] [PATCH 16/30] python-utils-r1.eclass: Remove python_wrapper_setup

2022-02-06 Thread Michał Górny
Signed-off-by: Michał Górny 
---
 eclass/python-utils-r1.eclass | 16 
 1 file changed, 16 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 99662c0a2e16..a2de1c2b506e 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -838,22 +838,6 @@ python_doheader() {
)
 }
 
-# @FUNCTION: python_wrapper_setup
-# @USAGE: [ []]
-# @DESCRIPTION:
-# Backwards compatibility function.  The relevant API is now considered
-# private, please use python_setup instead.
-python_wrapper_setup() {
-   debug-print-function ${FUNCNAME} "${@}"
-
-   eqawarn "python_wrapper_setup() is part of private eclass API."
-   eqawarn "Please call python_setup() instead."
-
-   [[ ${EAPI} == [67] ]] || die "${FUNCNAME} banned in EAPI ${EAPI}"
-
-   _python_wrapper_setup "${@}"
-}
-
 # @FUNCTION: _python_wrapper_setup
 # @USAGE: [ []]
 # @INTERNAL
-- 
2.35.1




[gentoo-dev] [PATCH 17/30] python-single-r1.eclass: Inline & simplify USE-deps in gen_cond_dep

2022-02-06 Thread Michał Górny
Generate simpler USE-deps inline in python_gen_cond_dep() and remove
_python_gen_usedep().  The original code always repeated USE deps
on all targets to aid Portage in giving better suggestions.  However,
since there always will be exactly one implementation selected, this
is unnecessary and we can just have every cond-dep match exactly that
one target.

Signed-off-by: Michał Górny 
---
 eclass/python-single-r1.eclass | 45 +++---
 1 file changed, 3 insertions(+), 42 deletions(-)

diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass
index 574ee9cfc04e..73afcdc3ed6c 100644
--- a/eclass/python-single-r1.eclass
+++ b/eclass/python-single-r1.eclass
@@ -259,40 +259,6 @@ unset -f _python_single_set_globals
 
 if [[ ! ${_PYTHON_SINGLE_R1} ]]; then
 
-# @FUNCTION: _python_gen_usedep
-# @USAGE: [...]
-# @INTERNAL
-# @DESCRIPTION:
-# Output a USE dependency string for Python implementations which
-# are both in PYTHON_COMPAT and match any of the patterns passed
-# as parameters to the function.
-#
-# The patterns are fnmatch-style patterns (matched via bash
-# == operator against PYTHON_COMPAT values).  Remember to escape
-# or quote the fnmatch patterns to prevent accidental shell filename
-# expansion.
-#
-# This is an internal function used to implement python_gen_cond_dep.
-_python_gen_usedep() {
-   debug-print-function ${FUNCNAME} "${@}"
-
-   local impl matches=()
-
-   _python_verify_patterns "${@}"
-   for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
-   if _python_impl_matches "${impl}" "${@}"; then
-   matches+=(
-   "python_single_target_${impl}(-)?"
-   )
-   fi
-   done
-
-   [[ ${matches[@]} ]] || die "No supported implementations match 
python_gen_usedep patterns: ${@}"
-
-   local out=${matches[@]}
-   echo "${out// /,}"
-}
-
 # @FUNCTION: python_gen_useflags
 # @USAGE: [...]
 # @DESCRIPTION:
@@ -372,13 +338,7 @@ python_gen_cond_dep() {
_python_verify_patterns "${@}"
for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
if _python_impl_matches "${impl}" "${@}"; then
-   # substitute ${PYTHON_SINGLE_USEDEP} if used
-   # (since python_gen_usedep() will not return
-   #  ${PYTHON_SINGLE_USEDEP}, the code is run at most 
once)
-   if [[ ${dep} == *'${PYTHON_SINGLE_USEDEP}'* ]]; then
-   local usedep=$(_python_gen_usedep "${@}")
-   dep=${dep//\$\{PYTHON_SINGLE_USEDEP\}/${usedep}}
-   fi
+   local single_usedep="python_single_target_${impl}(-)"
local multi_usedep="python_targets_${impl}(-)"
 
if [[ ${EAPI} != [67] ]]; then
@@ -387,7 +347,8 @@ python_gen_cond_dep() {
fi
fi
 
-   local 
subdep=${dep//\$\{PYTHON_MULTI_USEDEP\}/${multi_usedep}}
+   local 
subdep=${dep//\$\{PYTHON_SINGLE_USEDEP\}/${single_usedep}}
+   
subdep=${subdep//\$\{PYTHON_MULTI_USEDEP\}/${multi_usedep}}
matches+=( "python_single_target_${impl}? (
${subdep//\$\{PYTHON_USEDEP\}/${multi_usedep}} 
)" )
fi
-- 
2.35.1




[gentoo-dev] [PATCH 18/30] python-r1.eclass: Improve comment for USE-dep generation

2022-02-06 Thread Michał Górny
Signed-off-by: Michał Górny 
---
 eclass/python-r1.eclass | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index 469c3014abfb..bb851e167617 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -393,9 +393,15 @@ python_gen_cond_dep() {
_python_verify_patterns "${@}"
for impl in "${_PYTHON_SUPPORTED_IMPLS[@]}"; do
if _python_impl_matches "${impl}" "${@}"; then
-   # substitute ${PYTHON_USEDEP} if used
-   # (since python_gen_usedep() will not return 
${PYTHON_USEDEP}
-   #  the code is run at most once)
+   # substitute ${PYTHON_USEDEP} with USE-dep on *all* 
matching
+   # targets, if it is used.  this ensures that Portage 
will
+   # report all missing USE flags simultaneously rather 
than
+   # requesting the user to enable them one by one.
+   #
+   # NB: the first call with replace all instances
+   # of ${PYTHON_USEDEP}, so the condition will be false
+   # on subsequent loop iterations and _python_gen_usedep()
+   # will run at most once.
if [[ ${dep} == *'${PYTHON_USEDEP}'* ]]; then
local usedep=$(_python_gen_usedep "${@}")
dep=${dep//\$\{PYTHON_USEDEP\}/${usedep}}
-- 
2.35.1




[gentoo-dev] [PATCH 19/30] python-utils-r1.eclass: Remove python_is_python3

2022-02-06 Thread Michał Górny
Signed-off-by: Michał Górny 
---
 eclass/distutils-r1.eclass  |  8 +++-
 eclass/python-utils-r1.eclass   | 17 -
 eclass/tests/python-utils-r1.sh |  5 -
 3 files changed, 3 insertions(+), 27 deletions(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 295263b62420..7f9cf242c421 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -333,11 +333,9 @@ unset -f _distutils_set_globals
 # (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.
+# The patterns are fnmatch-style patterns (matched via bash == operator
+# against PYTHON_COMPAT values). 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
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index a2de1c2b506e..a42ae66d9c89 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -945,23 +945,6 @@ _python_wrapper_setup() {
export PATH PKG_CONFIG_PATH
 }
 
-# @FUNCTION: python_is_python3
-# @USAGE: []
-# @DESCRIPTION:
-# Check whether  (or ${EPYTHON}) is a Python3k variant
-# (i.e. uses syntax and stdlib of Python 3.*).
-#
-# Returns 0 (true) if it is, 1 (false) otherwise.
-python_is_python3() {
-   eqawarn "${FUNCNAME} is deprecated, as Python 2 is not supported 
anymore"
-   [[ ${EAPI} == [67] ]] || die "${FUNCNAME} banned in EAPI ${EAPI}"
-
-   local impl=${1:-${EPYTHON}}
-   [[ ${impl} ]] || die "python_is_python3: no impl nor EPYTHON"
-
-   [[ ${impl} == python3* || ${impl} == pypy3 ]]
-}
-
 # @FUNCTION: python_fix_shebang
 # @USAGE: [-f|--force] [-q|--quiet] ...
 # @DESCRIPTION:
diff --git a/eclass/tests/python-utils-r1.sh b/eclass/tests/python-utils-r1.sh
index 7ba4a864ff10..0244ce26ad0f 100755
--- a/eclass/tests/python-utils-r1.sh
+++ b/eclass/tests/python-utils-r1.sh
@@ -156,11 +156,6 @@ fi
 test_var PYTHON_PKG_DEP pypy3 '*dev-python/pypy3*:0='
 test_var PYTHON_SCRIPTDIR pypy3 /usr/lib/python-exec/pypy3
 
-test_is "python_is_python3 python2.7" 1
-test_is "python_is_python3 python3.2" 0
-test_is "python_is_python3 pypy" 1
-test_is "python_is_python3 pypy3" 0
-
 # generic shebangs
 test_fix_shebang '#!/usr/bin/python' python3.6 '#!/usr/bin/python3.6'
 test_fix_shebang '#!/usr/bin/python' pypy3 '#!/usr/bin/pypy3'
-- 
2.35.1




[gentoo-dev] [PATCH 20/30] python-single-r1.eclass: Remove PYTHON_MULTI_USEDEP

2022-02-06 Thread Michał Górny
Signed-off-by: Michał Górny 
---
 eclass/python-single-r1.eclass | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass
index 73afcdc3ed6c..0e9a16a47d0e 100644
--- a/eclass/python-single-r1.eclass
+++ b/eclass/python-single-r1.eclass
@@ -341,14 +341,7 @@ python_gen_cond_dep() {
local single_usedep="python_single_target_${impl}(-)"
local multi_usedep="python_targets_${impl}(-)"
 
-   if [[ ${EAPI} != [67] ]]; then
-   if [[ ${dep} == *\$\{PYTHON_MULTI_USEDEP\}* ]]; 
then
-   die "Replace PYTHON_MULTI_USEDEP with 
PYTHON_USEDEP in EAPI ${EAPI}"
-   fi
-   fi
-
local 
subdep=${dep//\$\{PYTHON_SINGLE_USEDEP\}/${single_usedep}}
-   
subdep=${subdep//\$\{PYTHON_MULTI_USEDEP\}/${multi_usedep}}
matches+=( "python_single_target_${impl}? (
${subdep//\$\{PYTHON_USEDEP\}/${multi_usedep}} 
)" )
fi
-- 
2.35.1




[gentoo-dev] [PATCH 21/30] distutils-r1.eclass: Use heredoc instead of "python -c"

2022-02-06 Thread Michał Górny
Use heredocs instead of inlining longish scripts in "python -c",
for greater readability.  Thanks to arthurzam for the suggestion.

Signed-off-by: Michał Górny 
---
 eclass/distutils-r1.eclass | 31 +--
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 7f9cf242c421..ea8fc7e5d165 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -936,9 +936,13 @@ _distutils-r1_get_backend() {
if [[ -f pyproject.toml ]]; then
# if pyproject.toml exists, try getting the backend from it
# NB: this could fail if pyproject.toml doesn't list one
-   build_backend=$("${EPYTHON}" -c 'import tomli; \
-   print(tomli.load(open("pyproject.toml", "rb")) \
-   ["build-system"]["build-backend"])' 2>/dev/null)
+   build_backend=$(
+   "${EPYTHON}" - <<-EOF 2>/dev/null
+   import tomli
+   print(tomli.load(open("pyproject.toml", "rb"))
+   ["build-system"]["build-backend"])
+   EOF
+   )
fi
if [[ -z ${build_backend} && ${DISTUTILS_USE_PEP517} == setuptools &&
-f setup.py ]]
@@ -1004,10 +1008,13 @@ distutils_pep517_install() {
 
local build_backend=$(_distutils-r1_get_backend)
einfo "  Building the wheel for ${PWD#${WORKDIR}/} via ${build_backend}"
-   local wheel=$("${EPYTHON}" -c "import ${build_backend%:*}; \
-   import os; \
-   
print(${build_backend/:/.}.build_wheel(os.environ['WHEEL_BUILD_DIR']))" ||
-   die "Wheel build failed")
+   local wheel=$(
+   "${EPYTHON}" - <<-EOF || die "Wheel build failed"
+   import ${build_backend%:*}
+   import os
+   
print(${build_backend/:/.}.build_wheel(os.environ['WHEEL_BUILD_DIR']))
+   EOF
+   )
[[ -n ${wheel} ]] || die "No wheel name returned"
 
einfo "  Installing the wheel to ${root}"
@@ -1017,9 +1024,13 @@ distutils_pep517_install() {
# NB: we override sys.prefix & sys.exec_prefix because otherwise
# installer would use virtualenv's prefix
local -x PYTHON_PREFIX=${EPREFIX}/usr
-   "${EPYTHON}" -c 'import os, sys; sys.prefix = sys.exec_prefix = 
os.environ["PYTHON_PREFIX"]; from installer.__main__ import main; 
main(sys.argv[1:])' \
-   -d "${root}" "${WHEEL_BUILD_DIR}/${wheel}" 
--no-compile-bytecode ||
-   die "installer failed"
+   "${EPYTHON}" - -d "${root}" "${WHEEL_BUILD_DIR}/${wheel}" 
--no-compile-bytecode \
+   <<-EOF || die "installer failed"
+   import os, sys
+   sys.prefix = sys.exec_prefix = os.environ["PYTHON_PREFIX"]
+   from installer.__main__ import main
+   main(sys.argv[1:])
+   EOF
 
# remove installed licenses
find "${root}$(python_get_sitedir)" \
-- 
2.35.1




[gentoo-dev] [PATCH 22/30] python-utils-r1.eclass: Use heredoc instead of "python -c"

2022-02-06 Thread Michał Górny
Signed-off-by: Michał Górny 
---
 eclass/python-utils-r1.eclass | 41 ++-
 1 file changed, 36 insertions(+), 5 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index a42ae66d9c89..d423a28cccb5 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -316,13 +316,23 @@ _python_export() {
;;
PYTHON_SITEDIR)
[[ -n ${PYTHON} ]] || die "PYTHON needs to be 
set for ${var} to be exported, or requested before it"
-   PYTHON_SITEDIR=$("${PYTHON}" -c 'import 
sysconfig; print(sysconfig.get_path("purelib"))') || die
+   PYTHON_SITEDIR=$(
+   "${PYTHON}" - <<-EOF || die
+   import sysconfig
+   
print(sysconfig.get_path("purelib"))
+   EOF
+   )
export PYTHON_SITEDIR
debug-print "${FUNCNAME}: PYTHON_SITEDIR = 
${PYTHON_SITEDIR}"
;;
PYTHON_INCLUDEDIR)
[[ -n ${PYTHON} ]] || die "PYTHON needs to be 
set for ${var} to be exported, or requested before it"
-   PYTHON_INCLUDEDIR=$("${PYTHON}" -c 'import 
sysconfig; print(sysconfig.get_path("platinclude"))') || die
+   PYTHON_INCLUDEDIR=$(
+   "${PYTHON}" - <<-EOF || die
+   import sysconfig
+   
print(sysconfig.get_path("platinclude"))
+   EOF
+   )
export PYTHON_INCLUDEDIR
debug-print "${FUNCNAME}: PYTHON_INCLUDEDIR = 
${PYTHON_INCLUDEDIR}"
 
@@ -333,7 +343,17 @@ _python_export() {
;;
PYTHON_LIBPATH)
[[ -n ${PYTHON} ]] || die "PYTHON needs to be 
set for ${var} to be exported, or requested before it"
-   PYTHON_LIBPATH=$("${PYTHON}" -c 'import 
os.path, sysconfig; print(os.path.join(sysconfig.get_config_var("LIBDIR"), 
sysconfig.get_config_var("LDLIBRARY")) if sysconfig.get_config_var("LDLIBRARY") 
else "")') || die
+   PYTHON_LIBPATH=$(
+   "${PYTHON}" - <<-EOF || die
+   import os.path, sysconfig
+   print(
+   os.path.join(
+   
sysconfig.get_config_var("LIBDIR"),
+   
sysconfig.get_config_var("LDLIBRARY"))
+   if 
sysconfig.get_config_var("LDLIBRARY")
+   else "")
+   EOF
+   )
export PYTHON_LIBPATH
debug-print "${FUNCNAME}: PYTHON_LIBPATH = 
${PYTHON_LIBPATH}"
 
@@ -383,7 +403,13 @@ _python_export() {
case "${impl}" in
python*)
[[ -n ${PYTHON} ]] || die 
"PYTHON needs to be set for ${var} to be exported, or requested before it"
-   flags=$("${PYTHON}" -c 'import 
sysconfig; print(sysconfig.get_config_var("ABIFLAGS") or "")') || die
+   flags=$(
+   "${PYTHON}" - <<-EOF || 
die
+   import sysconfig
+   
print(sysconfig.get_config_var("ABIFLAGS")
+   or "")
+   EOF
+   )
val=${PYTHON}${flags}-config
;;
*)
@@ -574,7 +600,12 @@ python_optimize() {
if [[ ${f} == /* && -d ${D%/}${f} ]]; then
set -- "${D%/}${f}" "${@}"
fi
-   done < <("${PYTHON}" -c 'import sys; print("".join(x + "\0" for 
x in sys.path))' || die)
+   done < <(
+   "${PYTHON}" - <<-EOF || di

[gentoo-dev] [PATCH 23/30] python-utils-r1.eclass: Remove old phase check from python_optimize

2022-02-06 Thread Michał Górny
Signed-off-by: Michał Górny 
---
 eclass/python-utils-r1.eclass | 9 -
 1 file changed, 9 deletions(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index d423a28cccb5..7d6c81e14dc8 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -573,15 +573,6 @@ python_get_scriptdir() {
 python_optimize() {
debug-print-function ${FUNCNAME} "${@}"
 
-   if [[ ${EBUILD_PHASE} == pre* || ${EBUILD_PHASE} == post* ]]; then
-   eerror "The new Python eclasses expect the compiled Python 
files to"
-   eerror "be controlled by the Package Manager. For this reason,"
-   eerror "the python_optimize function can be used only during 
src_* phases"
-   eerror "(src_install most commonly) and not during pkg_* 
phases."
-   echo
-   die "python_optimize is not to be used in pre/post* phases"
-   fi
-
[[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is 
null).'
 
local PYTHON=${PYTHON}
-- 
2.35.1




[gentoo-dev] [PATCH 24/30] python-utils-r1.eclass: Add status messages to python_optimize

2022-02-06 Thread Michał Górny
Signed-off-by: Michał Górny 
---
 eclass/python-utils-r1.eclass | 1 +
 1 file changed, 1 insertion(+)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 7d6c81e14dc8..1c6409add35c 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -610,6 +610,7 @@ python_optimize() {
local instpath=${d#${D%/}}
instpath=/${instpath##/}
 
+   einfo "Optimize Python modules for ${instpath}"
case "${EPYTHON}" in
python2.7|python3.[34])
"${PYTHON}" -m compileall -q -f -d 
"${instpath}" "${d}"
-- 
2.35.1




[gentoo-dev] [PATCH 25/30] python-utils-r1.eclass: Support matching impls by stdlib version

2022-02-06 Thread Michał Górny
Update _python_impl_matches() (used to implement python_gen*,
python_setup) to support specifying stdlib versions ("3.8", "3.9")
in addition to exact implementation names.  This makes handling PyPy3
version changes much easier when dealing with backports.

For example, if you specify "3.8", then the spec will match python3_8
and pypy3, for as long as we supply PyPy3.8.  Once we upgrade to PyPy3.9
completely, it will stop matching pypy3 and we won't have to manually
keep updating these deps.

Signed-off-by: Michał Górny 
---
 eclass/distutils-r1.eclass |  5 ++---
 eclass/python-r1.eclass| 35 ++
 eclass/python-single-r1.eclass | 18 ++---
 eclass/python-utils-r1.eclass  | 22 +
 4 files changed, 36 insertions(+), 44 deletions(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index ea8fc7e5d165..4feb9d7177ae 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -333,9 +333,8 @@ unset -f _distutils_set_globals
 # (allowing any implementation). If multiple values are specified,
 # implementations matching any of the patterns will be accepted.
 #
-# The patterns are fnmatch-style patterns (matched via bash == operator
-# against PYTHON_COMPAT values). Remember to escape or quote the fnmatch
-# patterns to prevent accidental shell filename expansion.
+# For the pattern syntax, please see _python_impl_matches
+# in python-utils-r1.eclass.
 #
 # If the restriction needs to apply conditionally to a USE flag,
 # the variable should be set conditionally as well (e.g. in an early
diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index bb851e167617..bf2fd62fdcba 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -289,11 +289,6 @@ _python_validate_useflags() {
 # are both in PYTHON_COMPAT and match any of the patterns passed
 # as parameters to the function.
 #
-# The patterns are fnmatch-style patterns (matched via bash
-# == operator against PYTHON_COMPAT values).  Remember to escape
-# or quote the fnmatch patterns to prevent accidental shell filename
-# expansion.
-#
 # This is an internal function used to implement python_gen_cond_dep.
 _python_gen_usedep() {
debug-print-function ${FUNCNAME} "${@}"
@@ -322,10 +317,8 @@ _python_gen_usedep() {
 # are both in PYTHON_COMPAT and match any of the patterns passed
 # as parameters to the function.
 #
-# The patterns are fnmatch-style patterns (matched via bash
-# == operator against PYTHON_COMPAT values).  Remember to escape
-# or quote the fnmatch patterns to prevent accidental shell filename
-# expansion.
+# For the pattern syntax, please see _python_impl_matches
+# in python-utils-r1.eclass.
 #
 # Example:
 # @CODE
@@ -359,10 +352,8 @@ python_gen_useflags() {
 # of Python implementations which are both in PYTHON_COMPAT and match
 # any of the patterns passed as the remaining parameters.
 #
-# The patterns are fnmatch-style patterns (matched via bash
-# == operator against PYTHON_COMPAT values).  Remember to escape
-# or quote the fnmatch patterns to prevent accidental shell filename
-# expansion.
+# For the pattern syntax, please see _python_impl_matches
+# in python-utils-r1.eclass.
 #
 # In order to enforce USE constraints on the packages, verbatim
 # '${PYTHON_USEDEP}' (quoted!) may be placed in the dependency
@@ -423,10 +414,8 @@ python_gen_cond_dep() {
 # patterns are passed, the output dependencies will be generated only
 # for the implementations matching them.
 #
-# The patterns are fnmatch-style patterns (matched via bash
-# == operator against PYTHON_COMPAT values).  Remember to escape
-# or quote the fnmatch patterns to prevent accidental shell filename
-# expansion.
+# For the pattern syntax, please see _python_impl_matches
+# in python-utils-r1.eclass.
 #
 # Use this function when you need to request different USE flags
 # on the Python interpreter depending on package's USE flags. If you
@@ -479,10 +468,8 @@ python_gen_impl_dep() {
 #
 # Optionally, patterns may be specified to restrict the dependency to
 # a subset of Python implementations supported by the ebuild.
-# The patterns are fnmatch-style patterns (matched via bash
-# == operator against PYTHON_COMPAT values).  Remember to escape
-# or quote the fnmatch patterns to prevent accidental shell filename
-# expansion.
+# For the pattern syntax, please see _python_impl_matches
+# in python-utils-r1.eclass.
 #
 # This should be used along with an appropriate python_check_deps()
 # that checks which of the any-of blocks were matched, and python_setup
@@ -669,10 +656,8 @@ python_foreach_impl() {
 # The python_check_deps() function in the any-of mode needs to be
 # accompanied by appropriate any-of dependencies.
 #
-# The patterns are fnmatch-style patterns (matched via bash
-# == operator against PYTHON_COMPAT values).  Remember to escape
-# or quote the fnmatch patterns to prevent accidental shell filename
-# expansion.
+# For the pattern syntax, pl

[gentoo-dev] [PATCH 26/30] dev-python/jaraco-text: Use python_gen_cond_dep w/ stdlib ver

2022-02-06 Thread Michał Górny
Signed-off-by: Michał Górny 
---
 dev-python/jaraco-text/jaraco-text-3.7.0-r1.ebuild | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dev-python/jaraco-text/jaraco-text-3.7.0-r1.ebuild 
b/dev-python/jaraco-text/jaraco-text-3.7.0-r1.ebuild
index 66eb9f8d0462..0b6a909952eb 100644
--- a/dev-python/jaraco-text/jaraco-text-3.7.0-r1.ebuild
+++ b/dev-python/jaraco-text/jaraco-text-3.7.0-r1.ebuild
@@ -23,7 +23,7 @@ RDEPEND="
>=dev-python/jaraco-functools-3.5.0-r1[${PYTHON_USEDEP}]
$(python_gen_cond_dep '
>=dev-python/importlib_resources-5.4.0-r3[${PYTHON_USEDEP}]
-   ' python3_8 pypy3)
+   ' 3.8)
 "
 
 distutils_enable_sphinx docs \
-- 
2.35.1




[gentoo-dev] [PATCH 27/30] python-any-r1.eclass: Do not test EPYTHON twice

2022-02-06 Thread Michał Górny
Avoid checking the implementation from EPYTHON via fallback iteration.
While there's no technical harm in doing that, now that we output
verbosely the users will notice ;-).

Signed-off-by: Michał Górny 
---
 eclass/python-any-r1.eclass | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass
index 5c01e9eb6888..4e954f57cd2d 100644
--- a/eclass/python-any-r1.eclass
+++ b/eclass/python-any-r1.eclass
@@ -299,13 +299,13 @@ python_setup() {
fi
 
# first, try ${EPYTHON}... maybe it's good enough for us.
-   if [[ ${EPYTHON} ]]; then
-   local impl=${EPYTHON/./_}
-   if ! has "${impl}" "${_PYTHON_SUPPORTED_IMPLS[@]}"; then
+   local epython_impl=${EPYTHON/./_}
+   if [[ ${epython_impl} ]]; then
+   if ! has "${epython_impl}" "${_PYTHON_SUPPORTED_IMPLS[@]}"; then
einfo "EPYTHON (${EPYTHON}) not supported by the 
package"
-   elif ! has "${impl}" "${_PYTHON_ALL_IMPLS[@]}"; then
+   elif ! has "${epython_impl}" "${_PYTHON_ALL_IMPLS[@]}"; then
ewarn "Invalid EPYTHON: ${EPYTHON}"
-   elif _python_run_check_deps "${impl}"; then
+   elif _python_run_check_deps "${epython_impl}"; then
_python_export EPYTHON PYTHON
_python_wrapper_setup
einfo "Using ${EPYTHON} to build (via EPYTHON)"
@@ -313,10 +313,12 @@ python_setup() {
fi
fi
 
-   # fallback to best installed impl.
+   # fallback to the best installed impl.
# (reverse iteration over _PYTHON_SUPPORTED_IMPLS)
for (( i = ${#_PYTHON_SUPPORTED_IMPLS[@]} - 1; i >= 0; i-- )); do
local impl=${_PYTHON_SUPPORTED_IMPLS[i]}
+   # avoid checking EPYTHON twice
+   [[ ${impl} == ${epython_impl} ]] && continue
_python_export "${impl}" EPYTHON PYTHON
if _python_run_check_deps "${impl}"; then
_python_wrapper_setup
-- 
2.35.1




[gentoo-dev] [PATCH 28/30] python-utils-r1.eclass: Add QA check for obsolete PYTHON_COMPAT

2022-02-06 Thread Michał Górny
Add a QA check that reports obsolete implementation in PYTHON_COMPAT
if ebuild has been modified in 2022 (based on copyright year).
Requested by sam.

Signed-off-by: Michał Górny 
---
 eclass/python-utils-r1.eclass | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 291d7ce9b771..83ac0a68da45 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -123,6 +123,8 @@ _python_set_impls() {
if [[ $(declare -p PYTHON_COMPAT) != "declare -a"* ]]; then
die 'PYTHON_COMPAT must be an array.'
fi
+
+   local obsolete=()
if [[ ! ${PYTHON_COMPAT_NO_STRICT} ]]; then
for i in "${PYTHON_COMPAT[@]}"; do
# check for incorrect implementations
@@ -130,7 +132,10 @@ _python_set_impls() {
# please keep them in sync with _PYTHON_ALL_IMPLS
# and _PYTHON_HISTORICAL_IMPLS
case ${i} in
-   
jython2_7|pypy|pypy1_[89]|pypy2_0|pypy3|python2_[5-7]|python3_[1-9]|python3_10)
+   pypy3|python2_7|python3_[89]|python3_10)
+   ;;
+   
jython2_7|pypy|pypy1_[89]|pypy2_0|python2_[5-6]|python3_[1-7])
+   obsolete+=( "${i}" )
;;
*)
if has "${i}" "${_PYTHON_ALL_IMPLS[@]}" 
\
@@ -144,6 +149,17 @@ _python_set_impls() {
done
fi
 
+   if [[ -n ${obsolete[@]} && ${EBUILD_PHASE} == setup ]]; then
+   # complain if people don't clean up old impls while touching
+   # the ebuilds recently.  use the copyright year to infer last
+   # modification
+   # NB: this check doesn't have to work reliably
+   if [[ $(head -n 1 "${EBUILD}" 2>/dev/null) == *2022* ]]; then
+   eqawarn "Please clean PYTHON_COMPAT of obsolete 
implementations:"
+   eqawarn "  ${obsolete[*]}"
+   fi
+   fi
+
local supp=() unsupp=()
 
for i in "${_PYTHON_ALL_IMPLS[@]}"; do
-- 
2.35.1




[gentoo-dev] [PATCH 29/30] dev-libs/libwacom: Use python_has_version for verbose output

2022-02-06 Thread Michał Górny
Signed-off-by: Michał Górny 
---
 dev-libs/libwacom/libwacom-1.11.ebuild | 6 +++---
 dev-libs/libwacom/libwacom-1.12.ebuild | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/dev-libs/libwacom/libwacom-1.11.ebuild 
b/dev-libs/libwacom/libwacom-1.11.ebuild
index acfda32d8405..3e406d573b91 100644
--- a/dev-libs/libwacom/libwacom-1.11.ebuild
+++ b/dev-libs/libwacom/libwacom-1.11.ebuild
@@ -35,9 +35,9 @@ BDEPEND="
 "
 
 python_check_deps() {
-   has_version -b "dev-python/python-libevdev[${PYTHON_USEDEP}]" &&
-   has_version -b "dev-python/pyudev[${PYTHON_USEDEP}]" &&
-   has_version -b "dev-python/pytest[${PYTHON_USEDEP}]"
+   python_has_version -b "dev-python/python-libevdev[${PYTHON_USEDEP}]" &&
+   python_has_version -b "dev-python/pyudev[${PYTHON_USEDEP}]" &&
+   python_has_version -b "dev-python/pytest[${PYTHON_USEDEP}]"
 }
 
 pkg_setup() {
diff --git a/dev-libs/libwacom/libwacom-1.12.ebuild 
b/dev-libs/libwacom/libwacom-1.12.ebuild
index acfda32d8405..3e406d573b91 100644
--- a/dev-libs/libwacom/libwacom-1.12.ebuild
+++ b/dev-libs/libwacom/libwacom-1.12.ebuild
@@ -35,9 +35,9 @@ BDEPEND="
 "
 
 python_check_deps() {
-   has_version -b "dev-python/python-libevdev[${PYTHON_USEDEP}]" &&
-   has_version -b "dev-python/pyudev[${PYTHON_USEDEP}]" &&
-   has_version -b "dev-python/pytest[${PYTHON_USEDEP}]"
+   python_has_version -b "dev-python/python-libevdev[${PYTHON_USEDEP}]" &&
+   python_has_version -b "dev-python/pyudev[${PYTHON_USEDEP}]" &&
+   python_has_version -b "dev-python/pytest[${PYTHON_USEDEP}]"
 }
 
 pkg_setup() {
-- 
2.35.1




[gentoo-dev] [PATCH 30/30] distutils-r1.eclass: Add min version to tomli dep

2022-02-06 Thread Michał Górny
Closes: https://bugs.gentoo.org/832782
Signed-off-by: Michał Górny 
---
 eclass/distutils-r1.eclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 4feb9d7177ae..aa8496092cee 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -176,7 +176,7 @@ _distutils_set_globals() {
# tomli is used to read build-backend from pyproject.toml
bdep='
>=dev-python/installer-0.4.0_p20220124[${PYTHON_USEDEP}]
-   dev-python/tomli[${PYTHON_USEDEP}]'
+   >=dev-python/tomli-1.2.3[${PYTHON_USEDEP}]'
case ${DISTUTILS_USE_PEP517} in
flit)
bdep+='
-- 
2.35.1




[gentoo-dev] Packages up for grabs: x11-misc/autocutsel

2022-02-06 Thread Jonas Stein

Dear all

the following packages are up for grabs after dropping
desktop-misc

x11-misc/autocutsel
https://packages.gentoo.org/packages/x11-misc/autocutsel

No open bugs, I did a version bump and an eapi bump before removing 
desktop-misc


--
Best,
Jonas



[gentoo-dev] Last rites: app-misc/emelfm2

2022-02-06 Thread Jonas Stein

# Jonas Stein  (2022-02-06)
# Dead upstream, unmaintained, open bugs.
# Removal after 2022-04-01.  Bug #832808.
app-misc/emelfm2

https://bugs.gentoo.org/832808

--
Best,
Jonas



[gentoo-dev] Package up for grabs: app-dicts/verbiste

2022-02-06 Thread Joonas Niilola
Hey,

app-dicts/verbiste is available due to retirement of its maintainer. Has
currently 3 bugs open.

-- juippis


OpenPGP_signature
Description: OpenPGP digital signature


[gentoo-dev] Packages up for grabs: media-libs/libgroove, media-gfx/img2pdf and more

2022-02-06 Thread Jonas Stein

Dear all

the following packages are up for grabs after retirement of the proxied 
maintainer https://bugs.gentoo.org/633102:



media-libs/libgroove
media-libs/libsoundio
x11-misc/xss-lock
media-gfx/img2pdf
games-rpg/baldurs-gate-ee
media-sound/pnmixer
dev-python/configshell-fb
dev-python/pyacoustid
sys-block/targetcli-fb


Links to pgo for your comfort:

https://packages.gentoo.org/packages/media-libs/libgroove
https://packages.gentoo.org/packages/media-libs/libsoundio
https://packages.gentoo.org/packages/x11-misc/xss-lock
https://packages.gentoo.org/packages/media-gfx/img2pdf
https://packages.gentoo.org/packages/games-rpg/baldurs-gate-ee
https://packages.gentoo.org/packages/media-sound/pnmixer
https://packages.gentoo.org/packages/dev-python/configshell-fb
https://packages.gentoo.org/packages/dev-python/pyacoustid
https://packages.gentoo.org/packages/sys-block/targetcli-fb

--
Best,
Jonas



[gentoo-dev] [PATCH 00/30] One batch of Python eclass updates to rule them all

2022-02-06 Thread Michał Górny
Hi,

Here's the largest batch of eclass updates in quite some time.  They
combine some new features needed for PEP 517 packages, other new
features, refactoring, cleanup and cosmetic changes -- hopefully
to stop the cache updates for some time.

The changes can be also reviewed on GitHub, particularly if you want
to see the big diff rather than the 30 individual changes:
https://github.com/gentoo/gentoo/pull/24065

The highlights are:

1. A new distutils_pep517_install function is introduced that carries
   the "core" PEP 517 functionality (previously inline
   in distutils-r1_python_compile).  This is mostly an internal change,
   except that it can be used to install additional packages required
   for tests (right now isort & pip need it).  New isort revision
   is included.

2. Some deprecated stuff that is no longer used in ::gentoo is removed.
   Since it causes failures in global scope, there's little risk
   of accidentally reintroducing its use.

3. python-any-r1 + python-r1 any-of API is now much more verbose.
   It is explaining why a particular implementations is selected
   or rejected.  In additional to that, a new python_has_version()
   wrapper is introduced that serves as a verbose alternative
   to has_version() for use in python_check_deps().  This particularly
   applies to USE=doc via distutils_enable_sphinx.  (requested by soap)

   Screenshot: https://pbs.twimg.com/media/FK1wBkFXIAElWm7?format=jpg

4. build_sphinx regression when Sphinx is not available for the current
   Python version is fixed.  It was broken by PEP 517 changes.

5. More complex inline Python invocations now use heredoc syntax
   instead of `-c` (thanks to arthurzam for the suggestion!).  This
   improves readability a lot.

6. python_optimize is also more verbose now.

7. python_gen* now accept stdlib versions in additional to exact
   interpreter names.  The primary use is replacing backport deps like:

 $(python_gen_cond_dep ... python3_7 pypy3)

   with more maintanable:

 $(python_gen_cond_dep ... 3.7)

   The big difference is that the latter doesn't need to be updated
   every time PyPy3 switches to a newer stdlib version.

8. The eclasses now issue a QA warning if the ebuild has been updated
   recently (i.e. in 2022, through looking up the Copyright line)
   and PYTHON_COMPAT still lists old implementations.  (requested
   by sam).

9. Minimum tomli dep is raised to aid people who don't update their
   systems often enough.

-- 
Best regards,
Michał Górny


Michał Górny (30):
  distutils-r1.eclass: Split backend getting code into a function
  distutils-r1.eclass: Get wheel name from the backend
  distutils-r1.eclass: Create distutils_pep517_install helper
  dev-python/isort: Switch to PEP 517 build
  python-r1.eclass: Remove deprecated python_gen_usedep
  python-any-r1.eclass: Move EPYTHON validity check to python_setup()
  python-utils-r1.eclass: Add function to run python_check_deps()
  python-any-r1.eclass: Explain the reason for interpreter choice
  python-utils-r1.eclass: Report _python_run_check_deps verbosely
  python-utils-r1.eclass: Inline python_is_installed
  distutils-r1.eclass: Fix has_version for distutils_enable_sphinx
  python-utils-r1.eclass: Add a verbose python_has_version() wrapper
  distutils-r1.eclass: Use python_has_version in ...enable_sphinx
  python-utils-r1.eclass: Fix sphinx_build for non-autodoc case
  python-utils-r1.eclass: Remove deprecated python_export
  python-utils-r1.eclass: Remove python_wrapper_setup
  python-single-r1.eclass: Inline & simplify USE-deps in gen_cond_dep
  python-r1.eclass: Improve comment for USE-dep generation
  python-utils-r1.eclass: Remove python_is_python3
  python-single-r1.eclass: Remove PYTHON_MULTI_USEDEP
  distutils-r1.eclass: Use heredoc instead of "python -c"
  python-utils-r1.eclass: Use heredoc instead of "python -c"
  python-utils-r1.eclass: Remove old phase check from python_optimize
  python-utils-r1.eclass: Add status messages to python_optimize
  python-utils-r1.eclass: Support matching impls by stdlib version
  dev-python/jaraco-text: Use python_gen_cond_dep w/ stdlib ver
  python-any-r1.eclass: Do not test EPYTHON twice
  python-utils-r1.eclass: Add QA check for obsolete PYTHON_COMPAT
  dev-libs/libwacom: Use python_has_version for verbose output
  distutils-r1.eclass: Add min version to tomli dep

 dev-libs/libwacom/libwacom-1.11.ebuild|   6 +-
 dev-libs/libwacom/libwacom-1.12.ebuild|   6 +-
 dev-python/isort/isort-5.10.1-r1.ebuild   |  65 +
 .../jaraco-text/jaraco-text-3.7.0-r1.ebuild   |   2 +-
 eclass/distutils-r1.eclass| 215 ++---
 eclass/python-any-r1.eclass   |  62 ++---
 eclass/python-r1.eclass   |  97 ++--
 eclass/python-single-r1.eclass|  68 +-
 eclass/python-utils-r1.eclass | 227 +++---
 eclass/tests/python-utils-r1.sh   |   5 -
 10 files changed, 382 insertio

[gentoo-dev] [PATCH 01/30] distutils-r1.eclass: Split backend getting code into a function

2022-02-06 Thread Michał Górny
Signed-off-by: Michał Górny 
---
 eclass/distutils-r1.eclass | 110 +
 1 file changed, 63 insertions(+), 47 deletions(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 2b5acb09d926..81eea83c67b3 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -922,6 +922,68 @@ _distutils-r1_backend_to_key() {
esac
 }
 
+# @FUNCTION: _distutils-r1_get_backend
+# @INTERNAL
+# @DESCRIPTION:
+# Read (or guess, in case of setuptools) the build-backend
+# for the package in the current directory.
+_distutils-r1_get_backend() {
+   debug-print-function ${FUNCNAME} "${@}"
+
+   local build_backend
+   if [[ -f pyproject.toml ]]; then
+   # if pyproject.toml exists, try getting the backend from it
+   # NB: this could fail if pyproject.toml doesn't list one
+   build_backend=$("${EPYTHON}" -c 'import tomli; \
+   print(tomli.load(open("pyproject.toml", "rb")) \
+   ["build-system"]["build-backend"])' 2>/dev/null)
+   fi
+   if [[ -z ${build_backend} && ${DISTUTILS_USE_PEP517} == setuptools &&
+   -f setup.py ]]
+   then
+   # use the legacy setuptools backend as a fallback
+   build_backend=setuptools.build_meta:__legacy__
+   fi
+   if [[ -z ${build_backend} ]]; then
+   die "Unable to obtain build-backend from pyproject.toml"
+   fi
+
+   if [[ ${DISTUTILS_USE_PEP517} != standalone ]]; then
+   # verify whether DISTUTILS_USE_PEP517 was set correctly
+   local expected_value=$(_distutils-r1_backend_to_key 
"${build_backend}")
+   if [[ ${DISTUTILS_USE_PEP517} != ${expected_value} ]]; then
+   eerror "DISTUTILS_USE_PEP517 does not match 
pyproject.toml!"
+   eerror "have: 
DISTUTILS_USE_PEP517=${DISTUTILS_USE_PEP517}"
+   eerror "expected: 
DISTUTILS_USE_PEP517=${expected_value}"
+   eerror "(backend: ${build_backend})"
+   die "DISTUTILS_USE_PEP517 value incorrect"
+   fi
+
+   # fix deprecated backends up
+   local new_backend=
+   case ${build_backend} in
+   flit.buildapi)
+   new_backend=flit_core.buildapi
+   ;;
+   poetry.masonry.api)
+   new_backend=poetry.core.masonry.api
+   ;;
+   esac
+
+   if [[ -n ${new_backend} ]]; then
+   if [[ ! -f ${T}/.distutils_deprecated_backend_warned 
]]; then
+   eqawarn "${build_backend} backend is 
deprecated.  Please see:"
+   eqawarn 
"https://projects.gentoo.org/python/guide/distutils.html#deprecated-pep-517-backends";
+   eqawarn "The eclass will be using 
${new_backend} instead."
+   > "${T}"/.distutils_deprecated_backend_warned 
|| die
+   fi
+   build_backend=${new_backend}
+   fi
+   fi
+
+   echo "${build_backend}"
+}
+
 # @FUNCTION: distutils-r1_python_compile
 # @USAGE: [additional-args...]
 # @DESCRIPTION:
@@ -968,53 +1030,7 @@ distutils-r1_python_compile() {
local -x WHEEL_BUILD_DIR=${BUILD_DIR}/wheel
mkdir -p "${WHEEL_BUILD_DIR}" || die
 
-   local build_backend
-   if [[ -f pyproject.toml ]]; then
-   build_backend=$("${EPYTHON}" -c 'import tomli; \
-   print(tomli.load(open("pyproject.toml", "rb")) \
-   ["build-system"]["build-backend"])' 
2>/dev/null)
-   fi
-   if [[ -z ${build_backend} && ${DISTUTILS_USE_PEP517} == 
setuptools &&
-   -f setup.py ]]
-   then
-   # use the legacy setuptools backend
-   build_backend=setuptools.build_meta:__legacy__
-   fi
-   [[ -z ${build_backend} ]] &&
-   die "Unable to obtain build-backend from pyproject.toml"
-
-   if [[ ${DISTUTILS_USE_PEP517} != standalone ]]; then
-   local expected_value=$(_distutils-r1_backend_to_key 
"${build_backend}")
-   if [[ ${DISTUTILS_USE_PEP517} != ${expected_value} ]]; 
then
-   eerror "DISTUTILS_USE_PEP517 does not match 
pyproject.toml!"
-   eerror "have: 
DISTUTILS_USE_PEP517=${DISTUTILS_USE_PEP517}"
-   eerror "expected: 
DISTUTILS_USE_PEP517=${expected_value}"
-   eerror "(backend: ${build_backend})"
-   die "DISTUTIL

[gentoo-dev] [PATCH 02/30] distutils-r1.eclass: Get wheel name from the backend

2022-02-06 Thread Michał Górny
Use the wheel name returned by build_wheel() rather than trying to guess
it from WHEEL_DIR.

Signed-off-by: Michał Górny 
---
 eclass/distutils-r1.eclass | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 81eea83c67b3..22070f6b74f4 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -1032,22 +1032,18 @@ distutils-r1_python_compile() {
 
local build_backend=$(_distutils-r1_get_backend)
einfo "  Building the wheel via ${build_backend}"
-   "${EPYTHON}" -c "import ${build_backend%:*}; \
+   local wheel=$("${EPYTHON}" -c "import ${build_backend%:*}; \
import os; \
-   
${build_backend/:/.}.build_wheel(os.environ['WHEEL_BUILD_DIR'])" ||
-   die "Wheel build failed"
-
-   local wheel=( "${WHEEL_BUILD_DIR}"/*.whl )
-   if [[ ${#wheel[@]} -ne 1 ]]; then
-   die "Incorrect number of wheels created (${#wheel[@]}): 
${wheel[*]}"
-   fi
+   
print(${build_backend/:/.}.build_wheel(os.environ['WHEEL_BUILD_DIR']))" ||
+   die "Wheel build failed")
+   [[ -n ${wheel} ]] || die "No wheel name returned"
 
local root=${BUILD_DIR}/install
einfo "  Installing the wheel to ${root}"
# NB: --compile-bytecode does not produce the correct paths,
# and python_optimize doesn't handle being called outside D,
# so we just defer compiling until the final merge
-   "${EPYTHON}" -m installer -d "${root}" "${wheel}" \
+   "${EPYTHON}" -m installer -d "${root}" 
"${WHEEL_BUILD_DIR}/${wheel}" \
--no-compile-bytecode ||
die "installer failed"
 
-- 
2.35.1




[gentoo-dev] [PATCH 03/30] distutils-r1.eclass: Create distutils_pep517_install helper

2022-02-06 Thread Michał Górny
Split the wheel build & install logic into a a new helper.

Signed-off-by: Michał Górny 
---
 eclass/distutils-r1.eclass | 77 --
 1 file changed, 48 insertions(+), 29 deletions(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 22070f6b74f4..814ee85a2b1f 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -984,6 +984,53 @@ _distutils-r1_get_backend() {
echo "${build_backend}"
 }
 
+# @FUNCTION: distutils_pep517_install
+# @USAGE: []
+# @DESCRIPTION:
+# Build the wheel for the package in the current directory using PEP 517
+# backend and install it into .  If  is not specified,
+# ${BUILD_DIR}/install is used.
+#
+# This function is intended for expert use only.  It does not handle
+# wrapping executables.
+distutils_pep517_install() {
+   debug-print-function ${FUNCNAME} "${@}"
+
+   local root=${1:-${BUILD_DIR}/install}
+   local -x WHEEL_BUILD_DIR=${BUILD_DIR}/wheel
+   mkdir -p "${WHEEL_BUILD_DIR}" || die
+
+   local build_backend=$(_distutils-r1_get_backend)
+   einfo "  Building the wheel for ${PWD#${WORKDIR}/} via ${build_backend}"
+   local wheel=$("${EPYTHON}" -c "import ${build_backend%:*}; \
+   import os; \
+   
print(${build_backend/:/.}.build_wheel(os.environ['WHEEL_BUILD_DIR']))" ||
+   die "Wheel build failed")
+   [[ -n ${wheel} ]] || die "No wheel name returned"
+
+   einfo "  Installing the wheel to ${root}"
+   # NB: --compile-bytecode does not produce the correct paths,
+   # and python_optimize doesn't handle being called outside D,
+   # so we just defer compiling until the final merge
+   # NB: we override sys.prefix & sys.exec_prefix because otherwise
+   # installer would use virtualenv's prefix
+   local -x PYTHON_PREFIX=${EPREFIX}/usr
+   "${EPYTHON}" -c 'import os, sys; sys.prefix = sys.exec_prefix = 
os.environ["PYTHON_PREFIX"]; from installer.__main__ import main; 
main(sys.argv[1:])' \
+   -d "${root}" "${WHEEL_BUILD_DIR}/${wheel}" 
--no-compile-bytecode ||
+   die "installer failed"
+
+   # remove installed licenses
+   find "${root}$(python_get_sitedir)" \
+   '(' -path '*.dist-info/COPYING*' -o \
+   -path '*.dist-info/LICENSE*' ')' -delete || die
+
+   # clean the build tree; otherwise we may end up with PyPy3
+   # extensions duplicated into CPython dists
+   if [[ ${DISTUTILS_USE_PEP517:-setuptools} == setuptools ]]; then
+   esetup.py clean -a
+   fi
+}
+
 # @FUNCTION: distutils-r1_python_compile
 # @USAGE: [additional-args...]
 # @DESCRIPTION:
@@ -1027,36 +1074,8 @@ distutils-r1_python_compile() {
addpredict /usr/lib/portage/pym
addpredict /usr/local # bug 498232
 
-   local -x WHEEL_BUILD_DIR=${BUILD_DIR}/wheel
-   mkdir -p "${WHEEL_BUILD_DIR}" || die
-
-   local build_backend=$(_distutils-r1_get_backend)
-   einfo "  Building the wheel via ${build_backend}"
-   local wheel=$("${EPYTHON}" -c "import ${build_backend%:*}; \
-   import os; \
-   
print(${build_backend/:/.}.build_wheel(os.environ['WHEEL_BUILD_DIR']))" ||
-   die "Wheel build failed")
-   [[ -n ${wheel} ]] || die "No wheel name returned"
-
local root=${BUILD_DIR}/install
-   einfo "  Installing the wheel to ${root}"
-   # NB: --compile-bytecode does not produce the correct paths,
-   # and python_optimize doesn't handle being called outside D,
-   # so we just defer compiling until the final merge
-   "${EPYTHON}" -m installer -d "${root}" 
"${WHEEL_BUILD_DIR}/${wheel}" \
-   --no-compile-bytecode ||
-   die "installer failed"
-
-   # remove installed licenses
-   find "${root}$(python_get_sitedir)" \
-   '(' -path '*.dist-info/COPYING*' -o \
-   -path '*.dist-info/LICENSE*' ')' -delete || die
-
-   # clean the build tree; otherwise we may end up with PyPy3
-   # extensions duplicated into CPython dists
-   if [[ ${DISTUTILS_USE_PEP517:-setuptools} == setuptools ]]; then
-   esetup.py clean -a
-   fi
+   distutils_pep517_install "${root}"
 
# copy executables to python-exec directory
# we do it early so that we can alter bindir recklessly
-- 
2.35.1




[gentoo-dev] [PATCH 04/30] dev-python/isort: Switch to PEP 517 build

2022-02-06 Thread Michał Górny
Signed-off-by: Michał Górny 
---
 dev-python/isort/isort-5.10.1-r1.ebuild | 65 +
 1 file changed, 65 insertions(+)
 create mode 100644 dev-python/isort/isort-5.10.1-r1.ebuild

diff --git a/dev-python/isort/isort-5.10.1-r1.ebuild 
b/dev-python/isort/isort-5.10.1-r1.ebuild
new file mode 100644
index ..11d6b04236b8
--- /dev/null
+++ b/dev-python/isort/isort-5.10.1-r1.ebuild
@@ -0,0 +1,65 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+DISTUTILS_USE_PEP517=poetry
+PYTHON_COMPAT=( python3_{8..10} )
+
+inherit distutils-r1
+
+DESCRIPTION="A python utility/library to sort imports"
+HOMEPAGE="https://pypi.org/project/isort/";
+SRC_URI="
+   https://github.com/PyCQA/isort/archive/${PV}.tar.gz
+   -> ${P}.gh.tar.gz"
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv 
~s390 ~sparc ~x86"
+
+RDEPEND="
+   dev-python/toml[${PYTHON_USEDEP}]"
+BDEPEND="
+   test? (
+   dev-python/black[${PYTHON_USEDEP}]
+   dev-python/colorama[${PYTHON_USEDEP}]
+   dev-python/hypothesis[${PYTHON_USEDEP}]
+   dev-python/natsort[${PYTHON_USEDEP}]
+   dev-python/pylama[${PYTHON_USEDEP}]
+   dev-python/pytest-mock[${PYTHON_USEDEP}]
+   dev-vcs/git
+   )
+"
+
+distutils_enable_tests pytest
+
+src_prepare() {
+   # unbundle toml
+   sed -i -e 's:from ._vendored ::' isort/settings.py || die
+   rm -r isort/_vendored || die
+   # remove upper bounds from example plugin deps
+   # (already removed upstream)
+   sed -i -e 's:\^:>=:' example*/pyproject.toml || die
+
+   distutils-r1_src_prepare
+}
+
+python_test() {
+   cp -a "${BUILD_DIR}"/{install,test} || die
+   local -x PATH=${BUILD_DIR}/test/usr/bin:${PATH}
+
+   # Install necessary plugins
+   local p
+   for p in example*/; do
+   pushd "${p}" >/dev/null || die
+   distutils_pep517_install "${BUILD_DIR}"/test
+   popd >/dev/null || die
+   done
+
+   local EPYTEST_IGNORE=(
+   # Excluded from upstream's test script
+   tests/unit/test_deprecated_finders.py
+   )
+   epytest tests/unit
+}
-- 
2.35.1




[gentoo-dev] [PATCH 05/30] python-r1.eclass: Remove deprecated python_gen_usedep

2022-02-06 Thread Michał Górny
This function is deprecated for some time already and there are no more
consumers left in ::gentoo.

Signed-off-by: Michał Górny 
---
 eclass/python-r1.eclass | 43 +
 1 file changed, 1 insertion(+), 42 deletions(-)

diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass
index 40ad4ef4bbf8..f9a9e9465b40 100644
--- a/eclass/python-r1.eclass
+++ b/eclass/python-r1.eclass
@@ -294,8 +294,7 @@ _python_validate_useflags() {
 # or quote the fnmatch patterns to prevent accidental shell filename
 # expansion.
 #
-# This is an internal function used to implement python_gen_cond_dep
-# and deprecated python_gen_usedep.
+# This is an internal function used to implement python_gen_cond_dep.
 _python_gen_usedep() {
debug-print-function ${FUNCNAME} "${@}"
 
@@ -316,46 +315,6 @@ _python_gen_usedep() {
echo "${out// /,}"
 }
 
-# @FUNCTION: python_gen_usedep
-# @USAGE:  [...]
-# @DESCRIPTION:
-# DEPRECATED.  Please use python_gen_cond_dep instead.
-#
-# Output a USE dependency string for Python implementations which
-# are both in PYTHON_COMPAT and match any of the patterns passed
-# as parameters to the function.
-#
-# The patterns are fnmatch-style patterns (matched via bash
-# == operator against PYTHON_COMPAT values).  Remember to escape
-# or quote the fnmatch patterns to prevent accidental shell filename
-# expansion.
-#
-# When all implementations are requested, please use ${PYTHON_USEDEP}
-# instead. Please also remember to set an appropriate REQUIRED_USE
-# to avoid ineffective USE flags.
-#
-# Example:
-# @CODE
-# PYTHON_COMPAT=( python{2_7,3_4} )
-# BDEPEND="doc? ( dev-python/epydoc[$(python_gen_usedep 'python2*')] )"
-# @CODE
-#
-# It will cause the dependency to look like:
-# @CODE
-# BDEPEND="doc? ( dev-python/epydoc[python_targets_python2_7?] )"
-# @CODE
-python_gen_usedep() {
-   debug-print-function ${FUNCNAME} "${@}"
-
-   # output only once, during some reasonable phase
-   # (avoid spamming cache regen runs)
-   if [[ ${EBUILD_PHASE} == setup ]]; then
-   eqawarn "python_gen_usedep() is deprecated. Please use 
python_gen_cond_dep instead."
-   fi
-   [[ ${EAPI} == [67] ]] || die "${FUNCNAME} banned in EAPI ${EAPI}"
-   _python_gen_usedep "${@}"
-}
-
 # @FUNCTION: python_gen_useflags
 # @USAGE: [...]
 # @DESCRIPTION:
-- 
2.35.1




[gentoo-dev] [PATCH 06/30] python-any-r1.eclass: Move EPYTHON validity check to python_setup()

2022-02-06 Thread Michał Górny
Move the EPYTHON validity check from _python_EPYTHON_supported()
to python_setup() where it belongs.  This avoids unnecessarily retesting
implementations taken from PYTHON_COMPAT and paves the way towards
moving the common logic to python-utils-r1.

Signed-off-by: Michał Górny 
---
 eclass/python-any-r1.eclass | 36 ++--
 1 file changed, 14 insertions(+), 22 deletions(-)

diff --git a/eclass/python-any-r1.eclass b/eclass/python-any-r1.eclass
index 282c449f2a03..4c832384ed7a 100644
--- a/eclass/python-any-r1.eclass
+++ b/eclass/python-any-r1.eclass
@@ -283,28 +283,15 @@ _python_EPYTHON_supported() {
local EPYTHON=${1}
local i=${EPYTHON/./_}
 
-   case "${i}" in
-   python*|jython*|pypy*)
-   ;;
-   *)
-   ewarn "Invalid EPYTHON: ${EPYTHON}"
-   return 1
-   ;;
-   esac
-
-   if has "${i}" "${_PYTHON_SUPPORTED_IMPLS[@]}"; then
-   if python_is_installed "${i}"; then
-   if declare -f python_check_deps >/dev/null; then
-   local PYTHON_USEDEP="python_targets_${i}(-)"
-   local 
PYTHON_SINGLE_USEDEP="python_single_target_${i}(-)"
-   python_check_deps
-   return ${?}
-   fi
-
-   return 0
+   if python_is_installed "${i}"; then
+   if declare -f python_check_deps >/dev/null; then
+   local PYTHON_USEDEP="python_targets_${i}(-)"
+   local 
PYTHON_SINGLE_USEDEP="python_single_target_${i}(-)"
+   python_check_deps
+   return ${?}
fi
-   elif ! has "${i}" "${_PYTHON_ALL_IMPLS[@]}"; then
-   ewarn "Invalid EPYTHON: ${EPYTHON}"
+
+   return 0
fi
return 1
 }
@@ -338,7 +325,12 @@ python_setup() {
 
# first, try ${EPYTHON}... maybe it's good enough for us.
if [[ ${EPYTHON} ]]; then
-   if _python_EPYTHON_supported "${EPYTHON}"; then
+   local impl=${EPYTHON/./_}
+   if ! has "${impl}" "${_PYTHON_SUPPORTED_IMPLS[@]}"; then
+   einfo "EPYTHON (${EPYTHON}) not supported by the 
package"
+   elif ! has "${impl}" "${_PYTHON_ALL_IMPLS[@]}"; then
+   ewarn "Invalid EPYTHON: ${EPYTHON}"
+   elif _python_EPYTHON_supported "${EPYTHON}"; then
_python_export EPYTHON PYTHON
_python_wrapper_setup
einfo "Using ${EPYTHON} to build"
-- 
2.35.1