Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 2/2] pypi.eclass: Add PYPI_NO_NORMALIZE control var
Date: Sat, 11 Feb 2023 11:45:53
Message-Id: 20230211114509.2077813-2-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 1/2] pypi.eclass: Normalize PN and translate PV for S as well by "Michał Górny"
1 Signed-off-by: Michał Górny <mgorny@g.o>
2 ---
3 eclass/pypi.eclass | 19 ++++++++++++++++---
4 1 file changed, 16 insertions(+), 3 deletions(-)
5
6 diff --git a/eclass/pypi.eclass b/eclass/pypi.eclass
7 index f4367b3fbfec..182b0b6b8c3e 100644
8 --- a/eclass/pypi.eclass
9 +++ b/eclass/pypi.eclass
10 @@ -12,7 +12,8 @@
11 # The pypi.eclass can be used to easily obtain URLs for artifacts
12 # uploaded to PyPI.org. When inherited, the eclass defaults SRC_URI
13 # and S to fetch .tar.gz sdist. The project filename is normalized
14 -# by default, and the version is translated using
15 +# by default (unless PYPI_NO_NORMALIZE is set prior to inheriting
16 +# the eclass), and the version is translated using
17 # pypi_translate_version.
18 #
19 # If necessary, SRC_URI and S can be overriden by the ebuild. Two
20 @@ -42,6 +43,13 @@ esac
21 if [[ ! ${_PYPI_ECLASS} ]]; then
22 _PYPI_ECLASS=1
23
24 +# @ECLASS_VARIABLE: PYPI_NO_NORMALIZE
25 +# @PRE_INHERIT
26 +# @DEFAULT_UNSET
27 +# @DESCRIPTION:
28 +# When set to a non-empty value, disables project name normalization
29 +# for the default SRC_URI and S values.
30 +
31 # @FUNCTION: pypi_normalize_name
32 # @USAGE: <name>
33 # @DESCRIPTION:
34 @@ -200,7 +208,12 @@ pypi_wheel_url() {
35 fi
36 }
37
38 -SRC_URI="$(pypi_sdist_url)"
39 -S="${WORKDIR}/$(pypi_normalize_name "${PN}")-$(pypi_translate_version "${PV}")"
40 +if [[ ${PYPI_NO_NORMALIZE} ]]; then
41 + SRC_URI="$(pypi_sdist_url --no-normalize)"
42 + S="${WORKDIR}/${PN}-$(pypi_translate_version "${PV}")"
43 +else
44 + SRC_URI="$(pypi_sdist_url)"
45 + S="${WORKDIR}/$(pypi_normalize_name "${PN}")-$(pypi_translate_version "${PV}")"
46 +fi
47
48 fi
49 --
50 2.39.1