Merge updates from master

This commit is contained in:
Repository mirror & CI
2023-06-17 10:17:23 +00:00
3 changed files with 70 additions and 12 deletions

View File

@@ -70,14 +70,12 @@ _PYPI_ECLASS=1
# Internal normalization function, returns the result
# via _PYPI_NORMALIZED_NAME variable.
_pypi_normalize_name() {
local name=${1}
if shopt -p -q extglob; then
name=${name//+([._-])/_}
else
shopt -s extglob
name=${name//+([._-])/_}
shopt -u extglob
fi
# NB: it's fine to alter it unconditionally since this function is
# always called from a subshell or in global scope
# (via _pypi_set_globals)
shopt -s extglob
local name=${1//+([._-])/_}
shopt -u extglob
_PYPI_NORMALIZED_NAME="${name,,}"
}

View File

@@ -114,11 +114,18 @@ _python_verify_patterns() {
_python_set_impls() {
local i
if ! declare -p PYTHON_COMPAT &>/dev/null; then
die 'PYTHON_COMPAT not declared.'
# TODO: drop BASH_VERSINFO check when we require EAPI 8
if [[ ${BASH_VERSINFO[0]} -ge 5 ]]; then
[[ ${PYTHON_COMPAT@a} == *a* ]]
else
[[ $(declare -p PYTHON_COMPAT) == "declare -a"* ]]
fi
if [[ $(declare -p PYTHON_COMPAT) != "declare -a"* ]]; then
die 'PYTHON_COMPAT must be an array.'
if [[ ${?} -ne 0 ]]; then
if ! declare -p PYTHON_COMPAT &>/dev/null; then
die 'PYTHON_COMPAT not declared.'
else
die 'PYTHON_COMPAT must be an array.'
fi
fi
local obsolete=()

View File

@@ -0,0 +1,53 @@
#!/bin/bash
# Copyright 2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
source tests-common.sh || exit
export LC_ALL=C
ITERATIONS=10000
RUNS=3
doit() {
local i
for (( i = 0; i < ITERATIONS; i++ )); do
"${@}"
done
}
timeit() {
local real=()
local user=()
local x vr avg
einfo "Timing ${*}"
for (( x = 0; x < RUNS; x++ )); do
while read tt tv; do
case ${tt} in
real) real+=( ${tv} );;
user) user+=( ${tv} );;
esac
done < <( ( time -p doit "${@}" ) 2>&1 )
done
[[ ${#real[@]} == ${RUNS} ]] || die "Did not get ${RUNS} real times"
[[ ${#user[@]} == ${RUNS} ]] || die "Did not get ${RUNS} user times"
local xr avg
for x in real user; do
xr="${x}[*]"
avg=$(dc -S 3 -e "${ITERATIONS} ${RUNS} * ${!xr} + + / p")
printf '%s %4.0f it/s\n' "${x}" "${avg}"
done
}
PYTHON_COMPAT=( python3_{10..12} pypy3 )
inherit python-utils-r1
timeit _python_set_impls
texit