summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2023-02-05 18:22:09 +0100
committerMichał Górny <mgorny@gentoo.org>2023-02-07 15:25:10 +0100
commit3dc1956210bc3e7b6efc1ea88aad483989ec9049 (patch)
tree2a40ef73af3d3fbbe9b05de10be89c09077de8f2 /eclass
parentdev-python/pip: Remove redundant min. versions in 23.0 (diff)
downloadgentoo-3dc1956210bc3e7b6efc1ea88aad483989ec9049.tar.gz
gentoo-3dc1956210bc3e7b6efc1ea88aad483989ec9049.tar.bz2
gentoo-3dc1956210bc3e7b6efc1ea88aad483989ec9049.zip
pypi.eclass: Support --unpack in pypi_wheel_url
Add a handy `--unpack` option to pypi_wheel_url, that automatically renames the downloaded distfile to have .zip suffix. This is used e.g. in dev-python/installer and dev-python/tomli to have default_src_unpack unpack the wheels automatically. Closes: https://github.com/gentoo/gentoo/pull/29439 Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r--eclass/pypi.eclass26
1 files changed, 19 insertions, 7 deletions
diff --git a/eclass/pypi.eclass b/eclass/pypi.eclass
index 80860e422ad4..e9d3eec1268b 100644
--- a/eclass/pypi.eclass
+++ b/eclass/pypi.eclass
@@ -89,10 +89,16 @@ pypi_wheel_name() {
}
# @FUNCTION: pypi_wheel_url
-# @USAGE: [<project> [<version> [<python-tag> [<abi-platform-tag>]]]]
+# @USAGE: [--unpack] [<project> [<version> [<python-tag> [<abi-platform-tag>]]]]
# @DESCRIPTION:
# Output the URL to PyPI wheel for specified project/version tuple.
#
+# The `--unpack` option causes a SRC_URI with an arrow operator to
+# be generated, that adds a .zip suffix to the fetched distfile,
+# so that it is unpacked in default src_unpack(). Note that
+# the wheel contents will be unpacked straight into ${WORKDIR}.
+# You need to add a BDEPEND on app-arch/unzip.
+#
# If <package> is unspecified, it defaults to ${PN}.
#
# If <version> is unspecified, it defaults to ${PV}.
@@ -103,21 +109,27 @@ pypi_wheel_name() {
# If <abi-platform-tag> is unspecified, it defaults to "none-any".
# You need to specify the correct value for non-pure wheels,
# e.g. "abi3-linux_x86_64".
-#
-# Note that wheels are suffixed .whl by default and therefore are not
-# unpacked automatically. If you need automatic unpacking, use "->"
-# operator to rename it or call unzip directly. Remember to BDEPEND
-# on app-arch/unzip.
pypi_wheel_url() {
+ local unpack=
+ if [[ ${1} == --unpack ]]; then
+ unpack=1
+ shift
+ fi
+
if [[ ${#} -gt 4 ]]; then
die "Usage: ${FUNCNAME} <project> [<version> [<python-tag> [<abi-platform-tag>]]]"
fi
+ local filename=$(pypi_wheel_name "${@}")
local project=${1-"${PN}"}
local version=${2-"${PV}"}
local pytag=${3-py3}
printf "https://files.pythonhosted.org/packages/%s" \
- "${pytag}/${project::1}/${project}/$(pypi_wheel_name "${@}")"
+ "${pytag}/${project::1}/${project}/${filename}"
+
+ if [[ ${unpack} ]]; then
+ echo " -> ${filename}.zip"
+ fi
}
fi