1 |
Signed-off-by: Michał Górny <mgorny@g.o> |
2 |
--- |
3 |
eclass/pypi.eclass | 19 +++++++++++++++++++ |
4 |
eclass/tests/pypi.sh | 7 +++++++ |
5 |
2 files changed, 26 insertions(+) |
6 |
|
7 |
diff --git a/eclass/pypi.eclass b/eclass/pypi.eclass |
8 |
index dd24b8337e62..27bd17403100 100644 |
9 |
--- a/eclass/pypi.eclass |
10 |
+++ b/eclass/pypi.eclass |
11 |
@@ -54,6 +54,25 @@ pypi_normalize_name() { |
12 |
echo "${name,,}" |
13 |
} |
14 |
|
15 |
+# @FUNCTION: pypi_translate_version |
16 |
+# @USAGE: <version> |
17 |
+# @DESCRIPTION: |
18 |
+# Translate the specified Gentoo version into the usual Python |
19 |
+# counterpart. Assumes PEP 440 versions. |
20 |
+# |
21 |
+# Note that we do not have clear counterparts for the epoch segment, |
22 |
+# nor for development release segment. |
23 |
+pypi_translate_version() { |
24 |
+ [[ ${#} -ne 1 ]] && die "Usage: ${FUNCNAME} <version>" |
25 |
+ |
26 |
+ local version=${1} |
27 |
+ version=${version/_alpha/a} |
28 |
+ version=${version/_beta/b} |
29 |
+ version=${version/_rc/rc} |
30 |
+ version=${version/_p/.post} |
31 |
+ echo "${version}" |
32 |
+} |
33 |
+ |
34 |
# @FUNCTION: pypi_sdist_url |
35 |
# @USAGE: [--no-normalize] [<project> [<version> [<suffix>]]] |
36 |
# @DESCRIPTION: |
37 |
diff --git a/eclass/tests/pypi.sh b/eclass/tests/pypi.sh |
38 |
index 385b1c028bce..af5d714af748 100755 |
39 |
--- a/eclass/tests/pypi.sh |
40 |
+++ b/eclass/tests/pypi.sh |
41 |
@@ -32,6 +32,13 @@ test-eq "pypi_normalize_name foo___bar" foo_bar |
42 |
test-eq "pypi_normalize_name Flask-BabelEx" flask_babelex |
43 |
test-eq "pypi_normalize_name jaraco.context" jaraco_context |
44 |
|
45 |
+test-eq "pypi_translate_version 1.2.3" 1.2.3 |
46 |
+test-eq "pypi_translate_version 1.2.3_p101" 1.2.3.post101 |
47 |
+test-eq "pypi_translate_version 1.2.3_alpha4" 1.2.3a4 |
48 |
+test-eq "pypi_translate_version 1.2.3_beta1" 1.2.3b1 |
49 |
+test-eq "pypi_translate_version 1.2.3_rc2" 1.2.3rc2 |
50 |
+test-eq "pypi_translate_version 1.2.3_rc2_p1" 1.2.3rc2.post1 |
51 |
+ |
52 |
test-eq "pypi_wheel_name" foo_bar-1.2.3-py3-none-any.whl |
53 |
test-eq "pypi_wheel_name Flask-BabelEx" flask_babelex-1.2.3-py3-none-any.whl |
54 |
test-eq "pypi_wheel_name Flask-BabelEx 4" flask_babelex-4-py3-none-any.whl |
55 |
-- |
56 |
2.39.1 |