summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2023-02-10 14:47:42 +0100
committerMichał Górny <mgorny@gentoo.org>2023-02-12 20:00:45 +0100
commit65e9578ab8ff9bf3b752659296128833810697cb (patch)
tree032d40b1ff241f068973c1b8e11587e548084b9d /eclass/pypi.eclass
parentpypi.eclass: Normalize sdist filenames by default (diff)
downloadgentoo-65e9578ab8ff9bf3b752659296128833810697cb.tar.gz
gentoo-65e9578ab8ff9bf3b752659296128833810697cb.tar.bz2
gentoo-65e9578ab8ff9bf3b752659296128833810697cb.zip
pypi.eclass: Add a version translation function
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass/pypi.eclass')
-rw-r--r--eclass/pypi.eclass19
1 files changed, 19 insertions, 0 deletions
diff --git a/eclass/pypi.eclass b/eclass/pypi.eclass
index dd24b8337e62..27bd17403100 100644
--- a/eclass/pypi.eclass
+++ b/eclass/pypi.eclass
@@ -54,6 +54,25 @@ pypi_normalize_name() {
echo "${name,,}"
}
+# @FUNCTION: pypi_translate_version
+# @USAGE: <version>
+# @DESCRIPTION:
+# Translate the specified Gentoo version into the usual Python
+# counterpart. Assumes PEP 440 versions.
+#
+# Note that we do not have clear counterparts for the epoch segment,
+# nor for development release segment.
+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}"
+}
+
# @FUNCTION: pypi_sdist_url
# @USAGE: [--no-normalize] [<project> [<version> [<suffix>]]]
# @DESCRIPTION: