1 |
Signed-off-by: Michał Górny <mgorny@g.o> |
2 |
--- |
3 |
eclass/pypi.eclass | 21 +++++++++++++++------ |
4 |
eclass/tests/pypi.sh | 24 ++++++++++++------------ |
5 |
2 files changed, 27 insertions(+), 18 deletions(-) |
6 |
|
7 |
diff --git a/eclass/pypi.eclass b/eclass/pypi.eclass |
8 |
index 27bd17403100..be0e498fcbf3 100644 |
9 |
--- a/eclass/pypi.eclass |
10 |
+++ b/eclass/pypi.eclass |
11 |
@@ -87,7 +87,10 @@ pypi_translate_version() { |
12 |
# is normalized according to the specification unless `--no-normalize` |
13 |
# is passed. |
14 |
# |
15 |
-# If <version> is unspecified, it defaults to ${PV}. |
16 |
+# If <version> is unspecified, it defaults to ${PV} translated |
17 |
+# via pypi_translate_version. If it is specified, then it is used |
18 |
+# verbatim (the function can be called explicitly to translate custom |
19 |
+# version number). |
20 |
# |
21 |
# If <format> is unspecified, it defaults to ".tar.gz". Another valid |
22 |
# value is ".zip" (please remember to add a BDEPEND on app-arch/unzip). |
23 |
@@ -103,7 +106,7 @@ pypi_sdist_url() { |
24 |
fi |
25 |
|
26 |
local project=${1-"${PN}"} |
27 |
- local version=${2-"${PV}"} |
28 |
+ local version=${2-"$(pypi_translate_version "${PV}")"} |
29 |
local suffix=${3-.tar.gz} |
30 |
local fn_project=${project} |
31 |
[[ ${normalize} ]] && fn_project=$(pypi_normalize_name "${project}") |
32 |
@@ -119,7 +122,10 @@ pypi_sdist_url() { |
33 |
# If <package> is unspecified, it defaults to ${PN}. The package name |
34 |
# is normalized according to the wheel specification. |
35 |
# |
36 |
-# If <version> is unspecified, it defaults to ${PV}. |
37 |
+# If <version> is unspecified, it defaults to ${PV} translated |
38 |
+# via pypi_translate_version. If it is specified, then it is used |
39 |
+# verbatim (the function can be called explicitly to translate custom |
40 |
+# version number). |
41 |
# |
42 |
# If <python-tag> is unspecified, it defaults to "py3". It can also be |
43 |
# "py2.py3", or a specific version in case of non-pure wheels. |
44 |
@@ -133,7 +139,7 @@ pypi_wheel_name() { |
45 |
fi |
46 |
|
47 |
local project=$(pypi_normalize_name "${1-"${PN}"}") |
48 |
- local version=${2-"${PV}"} |
49 |
+ local version=${2-"$(pypi_translate_version "${PV}")"} |
50 |
local pytag=${3-py3} |
51 |
local abitag=${4-none-any} |
52 |
echo "${project}-${version}-${pytag}-${abitag}.whl" |
53 |
@@ -152,7 +158,10 @@ pypi_wheel_name() { |
54 |
# |
55 |
# If <package> is unspecified, it defaults to ${PN}. |
56 |
# |
57 |
-# If <version> is unspecified, it defaults to ${PV}. |
58 |
+# If <version> is unspecified, it defaults to ${PV} translated |
59 |
+# via pypi_translate_version. If it is specified, then it is used |
60 |
+# verbatim (the function can be called explicitly to translate custom |
61 |
+# version number). |
62 |
# |
63 |
# If <python-tag> is unspecified, it defaults to "py3". It can also be |
64 |
# "py2.py3", or a specific version in case of non-pure wheels. |
65 |
@@ -173,7 +182,7 @@ pypi_wheel_url() { |
66 |
|
67 |
local filename=$(pypi_wheel_name "${@}") |
68 |
local project=${1-"${PN}"} |
69 |
- local version=${2-"${PV}"} |
70 |
+ local version=${2-"$(pypi_translate_version "${PV}")"} |
71 |
local pytag=${3-py3} |
72 |
printf "https://files.pythonhosted.org/packages/%s" \ |
73 |
"${pytag}/${project::1}/${project}/${filename}" |
74 |
diff --git a/eclass/tests/pypi.sh b/eclass/tests/pypi.sh |
75 |
index af5d714af748..e114549633a0 100755 |
76 |
--- a/eclass/tests/pypi.sh |
77 |
+++ b/eclass/tests/pypi.sh |
78 |
@@ -6,7 +6,7 @@ EAPI=8 |
79 |
source tests-common.sh || exit |
80 |
|
81 |
PN=Foo.Bar |
82 |
-PV=1.2.3 |
83 |
+PV=1.2.3_beta2 |
84 |
|
85 |
inherit pypi |
86 |
|
87 |
@@ -39,8 +39,8 @@ test-eq "pypi_translate_version 1.2.3_beta1" 1.2.3b1 |
88 |
test-eq "pypi_translate_version 1.2.3_rc2" 1.2.3rc2 |
89 |
test-eq "pypi_translate_version 1.2.3_rc2_p1" 1.2.3rc2.post1 |
90 |
|
91 |
-test-eq "pypi_wheel_name" foo_bar-1.2.3-py3-none-any.whl |
92 |
-test-eq "pypi_wheel_name Flask-BabelEx" flask_babelex-1.2.3-py3-none-any.whl |
93 |
+test-eq "pypi_wheel_name" foo_bar-1.2.3b2-py3-none-any.whl |
94 |
+test-eq "pypi_wheel_name Flask-BabelEx" flask_babelex-1.2.3b2-py3-none-any.whl |
95 |
test-eq "pypi_wheel_name Flask-BabelEx 4" flask_babelex-4-py3-none-any.whl |
96 |
test-eq "pypi_wheel_name Flask-BabelEx 4 py2.py3" \ |
97 |
flask_babelex-4-py2.py3-none-any.whl |
98 |
@@ -48,9 +48,9 @@ test-eq "pypi_wheel_name cryptography 39.0.1 cp36 abi3-manylinux_2_28_x86_64" \ |
99 |
cryptography-39.0.1-cp36-abi3-manylinux_2_28_x86_64.whl |
100 |
|
101 |
test-eq "pypi_wheel_url" \ |
102 |
- https://files.pythonhosted.org/packages/py3/F/Foo.Bar/foo_bar-1.2.3-py3-none-any.whl |
103 |
+ https://files.pythonhosted.org/packages/py3/F/Foo.Bar/foo_bar-1.2.3b2-py3-none-any.whl |
104 |
test-eq "pypi_wheel_url Flask-BabelEx" \ |
105 |
- https://files.pythonhosted.org/packages/py3/F/Flask-BabelEx/flask_babelex-1.2.3-py3-none-any.whl |
106 |
+ https://files.pythonhosted.org/packages/py3/F/Flask-BabelEx/flask_babelex-1.2.3b2-py3-none-any.whl |
107 |
test-eq "pypi_wheel_url Flask-BabelEx 4" \ |
108 |
https://files.pythonhosted.org/packages/py3/F/Flask-BabelEx/flask_babelex-4-py3-none-any.whl |
109 |
test-eq "pypi_wheel_url Flask-BabelEx 4 py2.py3" \ |
110 |
@@ -59,9 +59,9 @@ test-eq "pypi_wheel_url cryptography 39.0.1 cp36 abi3-manylinux_2_28_x86_64" \ |
111 |
https://files.pythonhosted.org/packages/cp36/c/cryptography/cryptography-39.0.1-cp36-abi3-manylinux_2_28_x86_64.whl |
112 |
|
113 |
test-eq "pypi_wheel_url --unpack" \ |
114 |
- "https://files.pythonhosted.org/packages/py3/F/Foo.Bar/foo_bar-1.2.3-py3-none-any.whl -> foo_bar-1.2.3-py3-none-any.whl.zip" |
115 |
+ "https://files.pythonhosted.org/packages/py3/F/Foo.Bar/foo_bar-1.2.3b2-py3-none-any.whl -> foo_bar-1.2.3b2-py3-none-any.whl.zip" |
116 |
test-eq "pypi_wheel_url --unpack Flask-BabelEx" \ |
117 |
- "https://files.pythonhosted.org/packages/py3/F/Flask-BabelEx/flask_babelex-1.2.3-py3-none-any.whl -> flask_babelex-1.2.3-py3-none-any.whl.zip" |
118 |
+ "https://files.pythonhosted.org/packages/py3/F/Flask-BabelEx/flask_babelex-1.2.3b2-py3-none-any.whl -> flask_babelex-1.2.3b2-py3-none-any.whl.zip" |
119 |
test-eq "pypi_wheel_url --unpack Flask-BabelEx 4" \ |
120 |
"https://files.pythonhosted.org/packages/py3/F/Flask-BabelEx/flask_babelex-4-py3-none-any.whl -> flask_babelex-4-py3-none-any.whl.zip" |
121 |
test-eq "pypi_wheel_url --unpack Flask-BabelEx 4 py2.py3" \ |
122 |
@@ -70,24 +70,24 @@ test-eq "pypi_wheel_url --unpack cryptography 39.0.1 cp36 abi3-manylinux_2_28_x8 |
123 |
"https://files.pythonhosted.org/packages/cp36/c/cryptography/cryptography-39.0.1-cp36-abi3-manylinux_2_28_x86_64.whl -> cryptography-39.0.1-cp36-abi3-manylinux_2_28_x86_64.whl.zip" |
124 |
|
125 |
test-eq "pypi_sdist_url" \ |
126 |
- https://files.pythonhosted.org/packages/source/F/Foo.Bar/foo_bar-1.2.3.tar.gz |
127 |
+ https://files.pythonhosted.org/packages/source/F/Foo.Bar/foo_bar-1.2.3b2.tar.gz |
128 |
test-eq "pypi_sdist_url Flask-BabelEx" \ |
129 |
- https://files.pythonhosted.org/packages/source/F/Flask-BabelEx/flask_babelex-1.2.3.tar.gz |
130 |
+ https://files.pythonhosted.org/packages/source/F/Flask-BabelEx/flask_babelex-1.2.3b2.tar.gz |
131 |
test-eq "pypi_sdist_url Flask-BabelEx 4" \ |
132 |
https://files.pythonhosted.org/packages/source/F/Flask-BabelEx/flask_babelex-4.tar.gz |
133 |
test-eq "pypi_sdist_url Flask-BabelEx 4 .zip" \ |
134 |
https://files.pythonhosted.org/packages/source/F/Flask-BabelEx/flask_babelex-4.zip |
135 |
|
136 |
test-eq "pypi_sdist_url --no-normalize" \ |
137 |
- https://files.pythonhosted.org/packages/source/F/Foo.Bar/Foo.Bar-1.2.3.tar.gz |
138 |
+ https://files.pythonhosted.org/packages/source/F/Foo.Bar/Foo.Bar-1.2.3b2.tar.gz |
139 |
test-eq "pypi_sdist_url --no-normalize Flask-BabelEx" \ |
140 |
- https://files.pythonhosted.org/packages/source/F/Flask-BabelEx/Flask-BabelEx-1.2.3.tar.gz |
141 |
+ https://files.pythonhosted.org/packages/source/F/Flask-BabelEx/Flask-BabelEx-1.2.3b2.tar.gz |
142 |
test-eq "pypi_sdist_url --no-normalize Flask-BabelEx 4" \ |
143 |
https://files.pythonhosted.org/packages/source/F/Flask-BabelEx/Flask-BabelEx-4.tar.gz |
144 |
test-eq "pypi_sdist_url --no-normalize Flask-BabelEx 4 .zip" \ |
145 |
https://files.pythonhosted.org/packages/source/F/Flask-BabelEx/Flask-BabelEx-4.zip |
146 |
|
147 |
test-eq 'declare -p SRC_URI' \ |
148 |
- 'declare -- SRC_URI="https://files.pythonhosted.org/packages/source/F/Foo.Bar/foo_bar-1.2.3.tar.gz"' |
149 |
+ 'declare -- SRC_URI="https://files.pythonhosted.org/packages/source/F/Foo.Bar/foo_bar-1.2.3b2.tar.gz"' |
150 |
|
151 |
texit |
152 |
-- |
153 |
2.39.1 |