1 |
Signed-off-by: Michał Górny <mgorny@g.o> |
2 |
--- |
3 |
eclass/pypi.eclass | 19 ++++++++++++++----- |
4 |
eclass/tests/pypi.sh | 3 +++ |
5 |
2 files changed, 17 insertions(+), 5 deletions(-) |
6 |
|
7 |
diff --git a/eclass/pypi.eclass b/eclass/pypi.eclass |
8 |
index be0e498fcbf3..f4367b3fbfec 100644 |
9 |
--- a/eclass/pypi.eclass |
10 |
+++ b/eclass/pypi.eclass |
11 |
@@ -11,12 +11,20 @@ |
12 |
# @DESCRIPTION: |
13 |
# The pypi.eclass can be used to easily obtain URLs for artifacts |
14 |
# uploaded to PyPI.org. When inherited, the eclass defaults SRC_URI |
15 |
-# to fetch ${P}.tar.gz sdist. |
16 |
+# and S to fetch .tar.gz sdist. The project filename is normalized |
17 |
+# by default, and the version is translated using |
18 |
+# pypi_translate_version. |
19 |
# |
20 |
-# If necessary, SRC_URI can be overriden by the ebuild. Two helper |
21 |
-# functions, pypi_sdist_url and pypi_wheel_url are provided to generate |
22 |
-# URLs to artifacts of specified type, with customizable project name. |
23 |
-# Additionally, pypi_wheel_name can be used to generate wheel filename. |
24 |
+# If necessary, SRC_URI and S can be overriden by the ebuild. Two |
25 |
+# helper functions, pypi_sdist_url and pypi_wheel_url are provided |
26 |
+# to generate URLs to artifacts of specified type, with customizable |
27 |
+# URL components. Additionally, pypi_wheel_name can be used to generate |
28 |
+# wheel filename. |
29 |
+# |
30 |
+# pypi_normalize_name can be used to normalize an arbitrary project name |
31 |
+# according to sdist/wheel normalization rules. pypi_translate_version |
32 |
+# can be used to translate a Gentoo version string into its PEP 440 |
33 |
+# equivalent. |
34 |
# |
35 |
# @EXAMPLE: |
36 |
# @CODE@ |
37 |
@@ -193,5 +201,6 @@ pypi_wheel_url() { |
38 |
} |
39 |
|
40 |
SRC_URI="$(pypi_sdist_url)" |
41 |
+S="${WORKDIR}/$(pypi_normalize_name "${PN}")-$(pypi_translate_version "${PV}")" |
42 |
|
43 |
fi |
44 |
diff --git a/eclass/tests/pypi.sh b/eclass/tests/pypi.sh |
45 |
index e114549633a0..ebfcdb630856 100755 |
46 |
--- a/eclass/tests/pypi.sh |
47 |
+++ b/eclass/tests/pypi.sh |
48 |
@@ -7,6 +7,7 @@ source tests-common.sh || exit |
49 |
|
50 |
PN=Foo.Bar |
51 |
PV=1.2.3_beta2 |
52 |
+WORKDIR='<WORKDIR>' |
53 |
|
54 |
inherit pypi |
55 |
|
56 |
@@ -89,5 +90,7 @@ test-eq "pypi_sdist_url --no-normalize Flask-BabelEx 4 .zip" \ |
57 |
|
58 |
test-eq 'declare -p SRC_URI' \ |
59 |
'declare -- SRC_URI="https://files.pythonhosted.org/packages/source/F/Foo.Bar/foo_bar-1.2.3b2.tar.gz"' |
60 |
+test-eq 'declare -p S' \ |
61 |
+ 'declare -- S="<WORKDIR>/foo_bar-1.2.3b2"' |
62 |
|
63 |
texit |
64 |
-- |
65 |
2.39.1 |