Signed-off-by: Michał Górny <[email protected]>
---
 eclass/pypi.eclass   | 19 ++++++++++++++-----
 eclass/tests/pypi.sh |  3 +++
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/eclass/pypi.eclass b/eclass/pypi.eclass
index be0e498fcbf3..f4367b3fbfec 100644
--- a/eclass/pypi.eclass
+++ b/eclass/pypi.eclass
@@ -11,12 +11,20 @@
 # @DESCRIPTION:
 # The pypi.eclass can be used to easily obtain URLs for artifacts
 # uploaded to PyPI.org.  When inherited, the eclass defaults SRC_URI
-# to fetch ${P}.tar.gz sdist.
+# and S to fetch .tar.gz sdist.  The project filename is normalized
+# by default, and the version is translated using
+# pypi_translate_version.
 #
-# If necessary, SRC_URI can be overriden by the ebuild.  Two helper
-# functions, pypi_sdist_url and pypi_wheel_url are provided to generate
-# URLs to artifacts of specified type, with customizable project name.
-# Additionally, pypi_wheel_name can be used to generate wheel filename.
+# If necessary, SRC_URI and S can be overriden by the ebuild.  Two
+# helper functions, pypi_sdist_url and pypi_wheel_url are provided
+# to generate URLs to artifacts of specified type, with customizable
+# URL components.  Additionally, pypi_wheel_name can be used to generate
+# wheel filename.
+#
+# pypi_normalize_name can be used to normalize an arbitrary project name
+# according to sdist/wheel normalization rules.  pypi_translate_version
+# can be used to translate a Gentoo version string into its PEP 440
+# equivalent.
 #
 # @EXAMPLE:
 # @CODE@
@@ -193,5 +201,6 @@ pypi_wheel_url() {
 }
 
 SRC_URI="$(pypi_sdist_url)"
+S="${WORKDIR}/$(pypi_normalize_name "${PN}")-$(pypi_translate_version "${PV}")"
 
 fi
diff --git a/eclass/tests/pypi.sh b/eclass/tests/pypi.sh
index e114549633a0..ebfcdb630856 100755
--- a/eclass/tests/pypi.sh
+++ b/eclass/tests/pypi.sh
@@ -7,6 +7,7 @@ source tests-common.sh || exit
 
 PN=Foo.Bar
 PV=1.2.3_beta2
+WORKDIR='<WORKDIR>'
 
 inherit pypi
 
@@ -89,5 +90,7 @@ test-eq "pypi_sdist_url --no-normalize Flask-BabelEx 4 .zip" \
 
 test-eq 'declare -p SRC_URI' \
        'declare -- 
SRC_URI="https://files.pythonhosted.org/packages/source/F/Foo.Bar/foo_bar-1.2.3b2.tar.gz";'
+test-eq 'declare -p S' \
+       'declare -- S="<WORKDIR>/foo_bar-1.2.3b2"'
 
 texit
-- 
2.39.1


Reply via email to