From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 38B2615A7D9 for ; Tue, 21 Mar 2023 05:44:04 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0066DE07F9; Tue, 21 Mar 2023 05:44:03 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A84F6E07F9 for ; Tue, 21 Mar 2023 05:44:02 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B2163341237 for ; Tue, 21 Mar 2023 05:44:01 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 88B3B8D4 for ; Tue, 21 Mar 2023 05:43:59 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1679376830.f36f134cbeb012ce50449f8089e9a46fa9e03c64.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/, eclass/tests/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/pypi.eclass eclass/tests/pypi.sh X-VCS-Directories: eclass/ eclass/tests/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: f36f134cbeb012ce50449f8089e9a46fa9e03c64 X-VCS-Branch: master Date: Tue, 21 Mar 2023 05:43:59 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: feb225cc-6f99-4718-b66c-9d9e0c0a9b60 X-Archives-Hash: 724cf881515211fa5a5eff863337f5d9 commit: f36f134cbeb012ce50449f8089e9a46fa9e03c64 Author: Michał Górny gentoo org> AuthorDate: Sat Mar 18 15:19:15 2023 +0000 Commit: Michał Górny gentoo org> CommitDate: Tue Mar 21 05:33:50 2023 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f36f134c pypi.eclass: Introduce PYPI_PN to override the default project name Introduce a convenience PYPI_PN variable that can be used to override the default project name. This is meant to be used primarily when upstream project name does not conform to Gentoo package naming rules, e.g. contains dots or uppercase letters. For example, instead of: SRC_URI="$(pypi_sdist_url --no-normalize "${PN/-/.}")" S=${WORKDIR}/${P/-/.} one can now specify: PYPI_NO_NORMALIZE=1 PYPI_PN=${PN/-/.} For PEP 625-conformant packages, instead of: SRC_URI="$(pypi_sdist_url "${PN/-/.}")" one can use: PYPI_PN=${PN/-/.} There's not much gain space-wise but it avoids having to specify the name twice. This can particularly be helpful for package names using PascalCase. Closes: https://github.com/gentoo/gentoo/pull/30210 Signed-off-by: Michał Górny gentoo.org> eclass/pypi.eclass | 35 ++++++++++++++++++++++++----------- eclass/tests/pypi.sh | 3 ++- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/eclass/pypi.eclass b/eclass/pypi.eclass index 79007a2ad0ed..ca3b6f67803d 100644 --- a/eclass/pypi.eclass +++ b/eclass/pypi.eclass @@ -50,6 +50,19 @@ _PYPI_ECLASS=1 # When set to a non-empty value, disables project name normalization # for the default SRC_URI and S values. +# @ECLASS_VARIABLE: PYPI_PN +# @PRE_INHERIT +# @DESCRIPTION: +# The PyPI project name. This should be overriden scarcely, generally +# when upstream project name does not conform to Gentoo naming rules, +# e.g. when it contains dots or uppercase letters. +# +# Example use: +# @CODE +# PYPI_PN=${PN/-/.} +# @CODE +: ${PYPI_PN:=${PN}} + # @FUNCTION: pypi_normalize_name # @USAGE: # @DESCRIPTION: @@ -99,9 +112,9 @@ pypi_translate_version() { # generated using build systems that did not follow PEP 625 # (i.e. the sdist name contains uppercase letters, hyphens or dots). # -# If is unspecified, it defaults to ${PN}. The package name -# is normalized according to the specification unless `--no-normalize` -# is passed. +# If is unspecified, it defaults to ${PYPI_PN}. The package +# name is normalized according to the specification unless +# `--no-normalize` is passed. # # If is unspecified, it defaults to ${PV} translated # via pypi_translate_version. If it is specified, then it is used @@ -121,7 +134,7 @@ pypi_sdist_url() { die "Usage: ${FUNCNAME} [--no-normalize] [ []]" fi - local project=${1-"${PN}"} + local project=${1-"${PYPI_PN}"} local version=${2-"$(pypi_translate_version "${PV}")"} local suffix=${3-.tar.gz} local fn_project=${project} @@ -135,8 +148,8 @@ pypi_sdist_url() { # @DESCRIPTION: # Output the wheel filename for the specified project/version tuple. # -# If is unspecified, it defaults to ${PN}. The package name -# is normalized according to the wheel specification. +# If is unspecified, it defaults to ${PYPI_PN}. The package +# name is normalized according to the wheel specification. # # If is unspecified, it defaults to ${PV} translated # via pypi_translate_version. If it is specified, then it is used @@ -154,7 +167,7 @@ pypi_wheel_name() { die "Usage: ${FUNCNAME} [ [ []]]" fi - local project=$(pypi_normalize_name "${1-"${PN}"}") + local project=$(pypi_normalize_name "${1-"${PYPI_PN}"}") local version=${2-"$(pypi_translate_version "${PV}")"} local pytag=${3-py3} local abitag=${4-none-any} @@ -172,7 +185,7 @@ pypi_wheel_name() { # the wheel contents will be unpacked straight into ${WORKDIR}. # You need to add a BDEPEND on app-arch/unzip. # -# If is unspecified, it defaults to ${PN}. +# If is unspecified, it defaults to ${PYPI_PN}. # # If is unspecified, it defaults to ${PV} translated # via pypi_translate_version. If it is specified, then it is used @@ -197,7 +210,7 @@ pypi_wheel_url() { fi local filename=$(pypi_wheel_name "${@}") - local project=${1-"${PN}"} + local project=${1-"${PYPI_PN}"} local version=${2-"$(pypi_translate_version "${PV}")"} local pytag=${3-py3} printf "https://files.pythonhosted.org/packages/%s" \ @@ -210,10 +223,10 @@ pypi_wheel_url() { if [[ ${PYPI_NO_NORMALIZE} ]]; then SRC_URI="$(pypi_sdist_url --no-normalize)" - S="${WORKDIR}/${PN}-$(pypi_translate_version "${PV}")" + S="${WORKDIR}/${PYPI_PN}-$(pypi_translate_version "${PV}")" else SRC_URI="$(pypi_sdist_url)" - S="${WORKDIR}/$(pypi_normalize_name "${PN}")-$(pypi_translate_version "${PV}")" + S="${WORKDIR}/$(pypi_normalize_name "${PYPI_PN}")-$(pypi_translate_version "${PV}")" fi fi diff --git a/eclass/tests/pypi.sh b/eclass/tests/pypi.sh index ebfcdb630856..471ac048b18a 100755 --- a/eclass/tests/pypi.sh +++ b/eclass/tests/pypi.sh @@ -5,7 +5,8 @@ EAPI=8 source tests-common.sh || exit -PN=Foo.Bar +PN=foo-bar +PYPI_PN=Foo.Bar PV=1.2.3_beta2 WORKDIR=''