summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2023-06-15 19:39:10 +0100
committerV3n3RiX <venerix@koprulu.sector>2023-06-15 19:39:10 +0100
commit3ba87279363a3a099c83d72faaf5b6bee1b23304 (patch)
tree7d4e3f6da46124be1284b7e40bb66a42b77eb846 /eclass
parentdb70871b2044b9bfde346d6f4027dafb0a013c4c (diff)
gentoo auto-resync : 15:06:2023 - 19:39:09
Diffstat (limited to 'eclass')
-rw-r--r--eclass/Manifest.gzbin37641 -> 37810 bytes
-rw-r--r--eclass/kernel-build.eclass2
-rw-r--r--eclass/pypi.eclass128
-rwxr-xr-xeclass/tests/pypi-bench.sh69
4 files changed, 160 insertions, 39 deletions
diff --git a/eclass/Manifest.gz b/eclass/Manifest.gz
index ba5f6e871eae..2e9e312fc134 100644
--- a/eclass/Manifest.gz
+++ b/eclass/Manifest.gz
Binary files differ
diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass
index da215a055a46..020557497ddc 100644
--- a/eclass/kernel-build.eclass
+++ b/eclass/kernel-build.eclass
@@ -28,7 +28,7 @@ esac
if [[ ! ${_KERNEL_BUILD_ECLASS} ]]; then
_KERNEL_BUILD_ECLASS=1
-PYTHON_COMPAT=( python3_{8..11} )
+PYTHON_COMPAT=( python3_{10..12} )
inherit multiprocessing python-any-r1 savedconfig toolchain-funcs kernel-install
diff --git a/eclass/pypi.eclass b/eclass/pypi.eclass
index 13dd56fa4fec..8a842c450ebc 100644
--- a/eclass/pypi.eclass
+++ b/eclass/pypi.eclass
@@ -63,6 +63,24 @@ _PYPI_ECLASS=1
# @CODE
: "${PYPI_PN:=${PN}}"
+# @FUNCTION: _pypi_normalize_name
+# @INTERNAL
+# @USAGE: <name>
+# @DESCRIPTION:
+# 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
+ _PYPI_NORMALIZED_NAME="${name,,}"
+}
+
# @FUNCTION: pypi_normalize_name
# @USAGE: <name>
# @DESCRIPTION:
@@ -75,12 +93,22 @@ _PYPI_ECLASS=1
pypi_normalize_name() {
[[ ${#} -ne 1 ]] && die "Usage: ${FUNCNAME} <name>"
- local name=${1}
- local shopt_save=$(shopt -p extglob)
- shopt -s extglob
- name=${name//+([._-])/_}
- ${shopt_save}
- echo "${name,,}"
+ local _PYPI_NORMALIZED_NAME
+ _pypi_normalize_name "${@}"
+ echo "${_PYPI_NORMALIZED_NAME}"
+}
+
+# @FUNCTION: _pypi_translate_version
+# @USAGE: <version>
+# @DESCRIPTION:
+# Internal version translation function, returns the result
+# via _PYPI_TRANSLATED_VERSION variable.
+_pypi_translate_version() {
+ local version=${1}
+ version=${version/_alpha/a}
+ version=${version/_beta/b}
+ version=${version/_rc/rc}
+ _PYPI_TRANSLATED_VERSION=${version/_p/.post}
}
# @FUNCTION: pypi_translate_version
@@ -94,12 +122,34 @@ pypi_normalize_name() {
pypi_translate_version() {
[[ ${#} -ne 1 ]] && die "Usage: ${FUNCNAME} <version>"
- local version=${1}
- version=${version/_alpha/a}
- version=${version/_beta/b}
- version=${version/_rc/rc}
- version=${version/_p/.post}
- echo "${version}"
+ local _PYPI_TRANSLATED_VERSION
+ _pypi_translate_version "${@}"
+ echo "${_PYPI_TRANSLATED_VERSION}"
+}
+
+# @FUNCTION: _pypi_sdist_url
+# @INTERNAL
+# @USAGE: [--no-normalize] [<project> [<version> [<suffix>]]]
+# @DESCRIPTION:
+# Internal sdist generated, returns the result via _PYPI_SDIST_URL
+# variable.
+_pypi_sdist_url() {
+ local normalize=1
+ if [[ ${1} == --no-normalize ]]; then
+ normalize=
+ shift
+ fi
+
+ if [[ ${#} -gt 3 ]]; then
+ die "Usage: ${FUNCNAME} [--no-normalize] <project> [<version> [<suffix>]]"
+ fi
+
+ local project=${1-"${PYPI_PN}"}
+ local version=${2-"$(pypi_translate_version "${PV}")"}
+ local suffix=${3-.tar.gz}
+ local _PYPI_NORMALIZED_NAME=${project}
+ [[ ${normalize} ]] && _pypi_normalize_name "${_PYPI_NORMALIZED_NAME}"
+ _PYPI_SDIST_URL="https://files.pythonhosted.org/packages/source/${project::1}/${project}/${_PYPI_NORMALIZED_NAME}-${version}${suffix}"
}
# @FUNCTION: pypi_sdist_url
@@ -124,23 +174,9 @@ pypi_translate_version() {
# If <format> is unspecified, it defaults to ".tar.gz". Another valid
# value is ".zip" (please remember to add a BDEPEND on app-arch/unzip).
pypi_sdist_url() {
- local normalize=1
- if [[ ${1} == --no-normalize ]]; then
- normalize=
- shift
- fi
-
- if [[ ${#} -gt 3 ]]; then
- die "Usage: ${FUNCNAME} [--no-normalize] <project> [<version> [<suffix>]]"
- fi
-
- local project=${1-"${PYPI_PN}"}
- local version=${2-"$(pypi_translate_version "${PV}")"}
- local suffix=${3-.tar.gz}
- local fn_project=${project}
- [[ ${normalize} ]] && fn_project=$(pypi_normalize_name "${project}")
- printf "https://files.pythonhosted.org/packages/source/%s" \
- "${project::1}/${project}/${fn_project}-${version}${suffix}"
+ local _PYPI_SDIST_URL
+ _pypi_sdist_url "${@}"
+ echo "${_PYPI_SDIST_URL}"
}
# @FUNCTION: pypi_wheel_name
@@ -167,11 +203,12 @@ pypi_wheel_name() {
die "Usage: ${FUNCNAME} <project> [<version> [<python-tag> [<abi-platform-tag>]]]"
fi
- local project=$(pypi_normalize_name "${1-"${PYPI_PN}"}")
+ local _PYPI_NORMALIZED_NAME
+ _pypi_normalize_name "${1:-"${PYPI_PN}"}"
local version=${2-"$(pypi_translate_version "${PV}")"}
local pytag=${3-py3}
local abitag=${4-none-any}
- echo "${project}-${version}-${pytag}-${abitag}.whl"
+ echo "${_PYPI_NORMALIZED_NAME}-${version}-${pytag}-${abitag}.whl"
}
# @FUNCTION: pypi_wheel_url
@@ -221,12 +258,27 @@ pypi_wheel_url() {
fi
}
-if [[ ${PYPI_NO_NORMALIZE} ]]; then
- SRC_URI="$(pypi_sdist_url --no-normalize)"
- S="${WORKDIR}/${PYPI_PN}-$(pypi_translate_version "${PV}")"
-else
- SRC_URI="$(pypi_sdist_url)"
- S="${WORKDIR}/$(pypi_normalize_name "${PYPI_PN}")-$(pypi_translate_version "${PV}")"
-fi
+# @FUNCTION: _pypi_set_globals
+# @INTERNAL
+# @DESCRIPTION:
+# Set global variables, SRC_URI and S.
+_pypi_set_globals() {
+ local _PYPI_SDIST_URL _PYPI_TRANSLATED_VERSION
+ _pypi_translate_version "${PV}"
+
+ if [[ ${PYPI_NO_NORMALIZE} ]]; then
+ _pypi_sdist_url --no-normalize "${PYPI_PN}" "${_PYPI_TRANSLATED_VERSION}"
+ S="${WORKDIR}/${PYPI_PN}-${_PYPI_TRANSLATED_VERSION}"
+ else
+ local _PYPI_NORMALIZED_NAME
+ _pypi_normalize_name "${PYPI_PN}"
+ _pypi_sdist_url "${PYPI_PN}" "${_PYPI_TRANSLATED_VERSION}"
+ S="${WORKDIR}/${_PYPI_NORMALIZED_NAME}-${_PYPI_TRANSLATED_VERSION}"
+ fi
+
+ SRC_URI=${_PYPI_SDIST_URL}
+}
+
+_pypi_set_globals
fi
diff --git a/eclass/tests/pypi-bench.sh b/eclass/tests/pypi-bench.sh
new file mode 100755
index 000000000000..cce93527b729
--- /dev/null
+++ b/eclass/tests/pypi-bench.sh
@@ -0,0 +1,69 @@
+#!/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=1000
+RUNS=3
+
+doit() {
+ local i
+ for (( i = 0; i < ITERATIONS; i++ )); do
+ _pypi_set_globals
+ done
+}
+
+timeit() {
+ einfo "Timing PYPI_PN=\"${PYPI_PN}\" PV=\"${PV}\" PYPI_NO_NORMALIZE=${PYPI_NO_NORMALIZE}"
+
+ local real=()
+ local user=()
+ local x vr avg
+
+ 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
+}
+
+PN=foo-bar
+PYPI_PN=Foo.Bar
+PV=1.2.3_beta2
+WORKDIR='<WORKDIR>'
+
+inherit pypi
+timeit
+
+PV=1.2.3
+timeit
+PYPI_NO_NORMALIZE=1 timeit
+
+PN=foobar
+PYPI_PN=FooBar
+timeit
+PYPI_NO_NORMALIZE=1 timeit
+
+PYPI_PN=foobar
+timeit
+PYPI_NO_NORMALIZE=1 timeit
+
+texit