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 6529F158083 for ; Mon, 9 Sep 2024 18:08:38 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 89088E2A00; Mon, 9 Sep 2024 18:08:37 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (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 6BF9EE2A00 for ; Mon, 9 Sep 2024 18:08:37 +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 9FD19342F9A for ; Mon, 9 Sep 2024 18:08:36 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 350171CC8 for ; Mon, 9 Sep 2024 18:08:35 +0000 (UTC) From: "Ulrich Müller" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Ulrich Müller" Message-ID: <1725905084.492506adede9d96c661699b90295b70e50f30160.ulm@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/ X-VCS-Repository: proj/portage X-VCS-Files: lib/portage/eapi.py X-VCS-Directories: lib/portage/ X-VCS-Committer: ulm X-VCS-Committer-Name: Ulrich Müller X-VCS-Revision: 492506adede9d96c661699b90295b70e50f30160 X-VCS-Branch: master Date: Mon, 9 Sep 2024 18:08:35 +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: 73be0bec-b09e-41f8-ac59-42315f0a3ce0 X-Archives-Hash: 63bc3f0549a821157e930419f5464a5a commit: 492506adede9d96c661699b90295b70e50f30160 Author: Ulrich Müller gentoo org> AuthorDate: Thu Jun 20 06:02:31 2024 +0000 Commit: Ulrich Müller gentoo org> CommitDate: Mon Sep 9 18:04:44 2024 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=492506ad eapi.py: Use attrs instead of hardcoding EAPIs in functions Adding new attrs as needed. Their name is the same as the corresponding PMS feature label (if one exists). Signed-off-by: Ulrich Müller gentoo.org> lib/portage/eapi.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/lib/portage/eapi.py b/lib/portage/eapi.py index ee691d311d..86b27bdbc5 100644 --- a/lib/portage/eapi.py +++ b/lib/portage/eapi.py @@ -41,7 +41,7 @@ def eapi_has_strong_blocks(eapi: str) -> bool: def eapi_has_src_prepare_and_src_configure(eapi: str) -> bool: - return eapi not in ("0", "1") + return _get_eapi_attrs(eapi).src_prepare_src_configure def eapi_supports_prefix(eapi: str) -> bool: @@ -77,15 +77,15 @@ def eapi_exports_ECLASSDIR(eapi: str) -> bool: def eapi_has_pkg_pretend(eapi: str) -> bool: - return eapi not in ("0", "1", "2", "3") + return _get_eapi_attrs(eapi).pkg_pretend def eapi_has_implicit_rdepend(eapi: str) -> bool: - return eapi in ("0", "1", "2", "3") + return _get_eapi_attrs(eapi).rdepend_depend def eapi_has_dosed_dohard(eapi: str) -> bool: - return eapi in ("0", "1", "2", "3") + return _get_eapi_attrs(eapi).dosed_dohard def eapi_has_required_use(eapi: str) -> bool: @@ -109,11 +109,11 @@ def eapi_has_repo_deps(eapi: str) -> bool: def eapi_supports_stable_use_forcing_and_masking(eapi: str) -> bool: - return eapi not in ("0", "1", "2", "3", "4", "4-slot-abi") + return _get_eapi_attrs(eapi).stablemask def eapi_allows_directories_on_profile_level_and_repository_level(eapi: str) -> bool: - return eapi not in ("0", "1", "2", "3", "4", "4-slot-abi", "5", "6") + return _get_eapi_attrs(eapi).profile_file_dirs def eapi_allows_package_provided(eapi: str) -> bool: @@ -150,6 +150,7 @@ _eapi_attrs = collections.namedtuple( "allows_package_provided", "bdepend", "broot", + "dosed_dohard", "empty_groups_always_true", "exports_AA", "exports_EBUILD_PHASE_FUNC", @@ -164,14 +165,19 @@ _eapi_attrs = collections.namedtuple( "iuse_effective", "posixish_locale", "path_variables_end_with_trailing_slash", + "pkg_pretend", "prefix", + "profile_file_dirs", + "rdepend_depend", "repo_deps", "required_use", "required_use_at_most_one_of", "selective_src_uri_restriction", "slot_operator", "slot_deps", + "src_prepare_src_configure", "src_uri_arrows", + "stablemask", "strong_blocks", "sysroot", "use_deps", @@ -223,6 +229,7 @@ def _get_eapi_attrs(eapi_str: Optional[str]) -> _eapi_attrs: allows_package_provided=True, bdepend=False, broot=True, + dosed_dohard=False, empty_groups_always_true=False, exports_AA=False, exports_EBUILD_PHASE_FUNC=True, @@ -236,15 +243,20 @@ def _get_eapi_attrs(eapi_str: Optional[str]) -> _eapi_attrs: iuse_defaults=True, iuse_effective=False, path_variables_end_with_trailing_slash=False, + pkg_pretend=True, posixish_locale=False, prefix=True, + profile_file_dirs=False, + rdepend_depend=False, repo_deps=True, required_use=True, required_use_at_most_one_of=True, selective_src_uri_restriction=True, slot_deps=True, slot_operator=True, + src_prepare_src_configure=True, src_uri_arrows=True, + stablemask=True, strong_blocks=True, sysroot=True, use_deps=True, @@ -256,6 +268,7 @@ def _get_eapi_attrs(eapi_str: Optional[str]) -> _eapi_attrs: allows_package_provided=eapi <= Eapi("6"), bdepend=eapi >= Eapi("7"), broot=eapi >= Eapi("7"), + dosed_dohard=eapi <= Eapi("3"), empty_groups_always_true=eapi <= Eapi("6"), exports_AA=eapi <= Eapi("3"), exports_EBUILD_PHASE_FUNC=eapi >= Eapi("5"), @@ -269,15 +282,20 @@ def _get_eapi_attrs(eapi_str: Optional[str]) -> _eapi_attrs: iuse_defaults=eapi >= Eapi("1"), iuse_effective=eapi >= Eapi("5"), path_variables_end_with_trailing_slash=eapi <= Eapi("6"), + pkg_pretend=eapi >= Eapi("4"), posixish_locale=eapi >= Eapi("6"), prefix=eapi >= Eapi("3"), + profile_file_dirs=eapi >= Eapi("7"), + rdepend_depend=eapi <= Eapi("3"), repo_deps=False, required_use=eapi >= Eapi("4"), required_use_at_most_one_of=eapi >= Eapi("5"), selective_src_uri_restriction=eapi >= Eapi("8"), slot_deps=eapi >= Eapi("1"), slot_operator=eapi >= Eapi("5"), + src_prepare_src_configure=eapi >= Eapi("2"), src_uri_arrows=eapi >= Eapi("2"), + stablemask=eapi >= Eapi("5"), strong_blocks=eapi >= Eapi("2"), sysroot=eapi >= Eapi("7"), use_deps=eapi >= Eapi("2"),