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 (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 7048A1581EC for ; Fri, 22 Nov 2024 21:35:35 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A1672E0872; Fri, 22 Nov 2024 21:35:34 +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 69565E0872 for ; Fri, 22 Nov 2024 21:35:34 +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 82C13335D77 for ; Fri, 22 Nov 2024 21:35:33 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 222EF1295 for ; Fri, 22 Nov 2024 21:35:32 +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: <1732311314.3deb50dd5394ef306a911fdd37a1bf92ae658adc.mgorny@gentoo> Subject: [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/, ... X-VCS-Repository: proj/pkgcore/pkgcheck X-VCS-Files: src/pkgcheck/checks/python.py testdata/data/repos/python/PythonPackageNameCheck/PythonMismatchedPackageName/expected.json X-VCS-Directories: testdata/data/repos/python/PythonPackageNameCheck/PythonMismatchedPackageName/ src/pkgcheck/checks/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 3deb50dd5394ef306a911fdd37a1bf92ae658adc X-VCS-Branch: master Date: Fri, 22 Nov 2024 21:35:32 +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: d8fbb133-9ce5-4d4b-ac5b-8635ff3ee9c6 X-Archives-Hash: 58e1079f8319565ed4394e9c27c33076 commit: 3deb50dd5394ef306a911fdd37a1bf92ae658adc Author: Michał Górny gentoo org> AuthorDate: Fri Nov 22 15:07:02 2024 +0000 Commit: Michał Górny gentoo org> CommitDate: Fri Nov 22 21:35:14 2024 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=3deb50dd python: Enforce a stricter PyPI package naming policy Enforce a stricter package naming policy that requires using lowercase names and hyphens over underscores. Once this change lands, I'll update the Python Guide as well. Previously, the policy was to permit either forcing lowercase, or to follow upstream naming (and the name check, more liberally, was done case-insensitively), with a note to enforce consistency across different packages. This caused twofold problems. Firstly, not all packages ended up following the policy for consistent naming -- so we e.g. have flit-core but flit_scm, or flask but Frozen-Flask. Part of the problem is that 1) PyPI packages themselves, particularly third-party extensions, don't follow consistent naming themselves, and 2) some PyPI packages actually get "renamed" with case and/or hyphen changes. Secondly, this policy makes naming less predictable. In particular, with upstream name of "flit-scm", you don't immediately figure out it's "flit_scm" in Gentoo, or with "PyGithub" you can't guess whether to look for "PyGithub" or "pygithub". The changed policy will require changes to 44 packages in Gentoo. Closes: https://github.com/pkgcore/pkgcheck/pull/717 Signed-off-by: Michał Górny gentoo.org> src/pkgcheck/checks/python.py | 4 ++-- .../PythonPackageNameCheck/PythonMismatchedPackageName/expected.json | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pkgcheck/checks/python.py b/src/pkgcheck/checks/python.py index bacbdb5a..392241b2 100644 --- a/src/pkgcheck/checks/python.py +++ b/src/pkgcheck/checks/python.py @@ -946,5 +946,5 @@ class PythonPackageNameCheck(Check): return PROJECT_SYMBOL_NORMALIZE_RE.sub("-", project).lower() pypi_name = pypi_remotes[0].name - if normalize(pkg.package) != normalize(pypi_name): - yield PythonMismatchedPackageName(pypi_name.replace(".", "-"), pkg=pkg) + if pkg.package != normalize(pypi_name): + yield PythonMismatchedPackageName(normalize(pypi_name), pkg=pkg) diff --git a/testdata/data/repos/python/PythonPackageNameCheck/PythonMismatchedPackageName/expected.json b/testdata/data/repos/python/PythonPackageNameCheck/PythonMismatchedPackageName/expected.json index 3c85ada5..5142f6a8 100644 --- a/testdata/data/repos/python/PythonPackageNameCheck/PythonMismatchedPackageName/expected.json +++ b/testdata/data/repos/python/PythonPackageNameCheck/PythonMismatchedPackageName/expected.json @@ -1 +1,2 @@ -{"__class__": "PythonMismatchedPackageName", "category": "dev-python", "package": "PythonMismatchedPackageName1", "recommended": "MismatchedPackageName1"} +{"__class__": "PythonMismatchedPackageName", "category": "dev-python", "package": "PythonMismatchedPackageName0", "recommended": "pythonmismatchedpackagename0"} +{"__class__": "PythonMismatchedPackageName", "category": "dev-python", "package": "PythonMismatchedPackageName1", "recommended": "mismatchedpackagename1"}