commit:     7ca3a4bd98b64c1a62ad8e9f2b174fe73d6e9ce2
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 25 17:24:51 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon Apr  3 18:26:35 2023 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=7ca3a4bd

python: Restore filename check in pypi.eclass default case

Restore the check for renamed distfile that was accidentally removed
while refactoring the code.  This prevents suggesting removing SRC_URI
when it would cause the distfile rename to be reverted.

Fixes: 5704c77f5cabed06be363df78ca03b6e66566a97
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
Closes: https://github.com/pkgcore/pkgcheck/pull/572
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcheck/checks/python.py                       |  7 ++++++-
 .../PythonInlinePyPIURI/expected.json               |  1 +
 .../PythonInlinePyPIURI/fix.patch                   | 21 +++++++++++++++++++++
 .../PythonInlinePyPIURL/Manifest                    |  1 +
 .../PythonInlinePyPIURL-2_p4-r2.ebuild              | 15 +++++++++++++++
 5 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/src/pkgcheck/checks/python.py b/src/pkgcheck/checks/python.py
index 0cd5d229..ae448360 100644
--- a/src/pkgcheck/checks/python.py
+++ b/src/pkgcheck/checks/python.py
@@ -820,7 +820,12 @@ class PythonFetchableCheck(Check):
 
             if source_match := PYPI_SDIST_URI_RE.match(uri):
                 pn, filename_pn, pv, suffix = source_match.groups()
-                if pv == self.translate_version(pkg.version) and suffix == 
".tar.gz":
+                translated_version = self.translate_version(pkg.version)
+                if (
+                    pv == translated_version
+                    and suffix == ".tar.gz"
+                    and filename == 
f"{filename_pn}-{translated_version}.tar.gz"
+                ):
                     append = len(uris) > 1
                     normalize = filename_pn == 
self.normalize_distribution_name(pn)
                     if not normalize and filename_pn != pn:

diff --git 
a/testdata/data/repos/python/PythonFetchableCheck/PythonInlinePyPIURI/expected.json
 
b/testdata/data/repos/python/PythonFetchableCheck/PythonInlinePyPIURI/expected.json
index 45757750..dfe74895 100644
--- 
a/testdata/data/repos/python/PythonFetchableCheck/PythonInlinePyPIURI/expected.json
+++ 
b/testdata/data/repos/python/PythonFetchableCheck/PythonInlinePyPIURI/expected.json
@@ -20,3 +20,4 @@
 {"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", 
"package": "python-inline-pypi-url", "version": "1000-r200", "url": 
"https://files.pythonhosted.org/packages/source/P/Python-inline-pypi-url/python_inline_pypi_url-1000.tar.gz";,
 "replacement": null, "normalize": true, "append": false, "pypi_pn": 
"\"${PN^}\""}
 {"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", 
"package": "python-inline-pypi-url", "version": "2000", "url": 
"https://files.pythonhosted.org/packages/source/p/python.inline-pypi-url/python_inline_pypi_url-2000.tar.gz";,
 "replacement": ["pypi_sdist_url", "\"${PN/-/.}\""], "normalize": null, 
"append": null, "pypi_pn": null}
 {"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", 
"package": "python-inline-pypi-url", "version": "2000", "url": 
"https://files.pythonhosted.org/packages/source/p/python.inline-pypi-url_vectors/python.inline-pypi-url_vectors-151.tar.gz";,
 "replacement": ["pypi_sdist_url", "--no-normalize", 
"python.inline-pypi-url_vectors", "151"], "normalize": null, "append": null, 
"pypi_pn": null}
+{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", 
"package": "PythonInlinePyPIURL", "version": "2_p4-r2", "url": 
"https://files.pythonhosted.org/packages/source/P/PythonInlinePyPIURL/pythoninlinepypiurl-2.post4.tar.gz";,
 "replacement": ["pypi_sdist_url", "\"${PN}\"", "2.post4"], "normalize": null, 
"append": null, "pypi_pn": null}

diff --git 
a/testdata/data/repos/python/PythonFetchableCheck/PythonInlinePyPIURI/fix.patch 
b/testdata/data/repos/python/PythonFetchableCheck/PythonInlinePyPIURI/fix.patch
index 28e27b9e..09bbcd62 100644
--- 
a/testdata/data/repos/python/PythonFetchableCheck/PythonInlinePyPIURI/fix.patch
+++ 
b/testdata/data/repos/python/PythonFetchableCheck/PythonInlinePyPIURI/fix.patch
@@ -341,3 +341,24 @@ diff -Naur 
python/PythonFetchableCheck/PythonInlinePyPIURL/PythonInlinePyPIURL-4
  "
  S=${WORKDIR}/${MY_P}
  
+diff -Naur 
python/PythonFetchableCheck/PythonInlinePyPIURL/PythonInlinePyPIURL-2_p4-r2.ebuild
 
fixed/PythonFetchableCheck/PythonInlinePyPIURL/PythonInlinePyPIURL-2_p4-r2.ebuild
+--- 
python/PythonFetchableCheck/PythonInlinePyPIURL/PythonInlinePyPIURL-2_p4-r2.ebuild
 2023-03-25 18:33:03.235669903 +0100
++++ 
fixed/PythonFetchableCheck/PythonInlinePyPIURL/PythonInlinePyPIURL-2_p4-r2.ebuild
  2023-03-25 18:37:09.307850231 +0100
+@@ -3,13 +3,14 @@
+ 
+ EAPI=8
+ 
+-MY_P=${PN,,}-${PV/_p/.post}
++PYPI_PN=${PN,,}
++inherit pypi
++
+ DESCRIPTION="Ebuild with PyPI URL"
+ HOMEPAGE="https://example.com";
+ SRC_URI="
+-      mirror://pypi/${PN::1}/${PN}/${MY_P}.tar.gz -> python-${MY_P}.tar.gz
++      $(pypi_sdist_url) -> python-${MY_P}.tar.gz
+ "
+-S=${WORKDIR}/${MY_P}
+ 
+ LICENSE="BSD"
+ SLOT="0"

diff --git 
a/testdata/repos/python/PythonFetchableCheck/PythonInlinePyPIURL/Manifest 
b/testdata/repos/python/PythonFetchableCheck/PythonInlinePyPIURL/Manifest
index 39d6377a..7b6a198a 100644
--- a/testdata/repos/python/PythonFetchableCheck/PythonInlinePyPIURL/Manifest
+++ b/testdata/repos/python/PythonFetchableCheck/PythonInlinePyPIURL/Manifest
@@ -8,3 +8,4 @@ DIST pypi_url-3-py3-none-any.whl.zip 153310 BLAKE2B 
b7484cd9bebe912f9c8877c0f09d
 DIST pythoninlinepypiurl-4-cp310-cp310-linux_x86_64.whl 153310 BLAKE2B 
b7484cd9bebe912f9c8877c0f09df059130c2dc5c4da8c926f8df7945bcb7b255cdf810ce8cd16a987fb5bca3d1e71c088cd894968641db5dfae1c4c059df836
 SHA512 
86ff9e1c4b9353b1fbb475c7bb9d2a97bd9db8421ea5190b5a84832930b34cb5b79f8c3da68a5eb8db334f06851ec129cc6611a371e47b7c5de7a615feec5e05
 DIST pypi_url-4.tar.gz 153310 BLAKE2B 
b7484cd9bebe912f9c8877c0f09df059130c2dc5c4da8c926f8df7945bcb7b255cdf810ce8cd16a987fb5bca3d1e71c088cd894968641db5dfae1c4c059df836
 SHA512 
86ff9e1c4b9353b1fbb475c7bb9d2a97bd9db8421ea5190b5a84832930b34cb5b79f8c3da68a5eb8db334f06851ec129cc6611a371e47b7c5de7a615feec5e05
 DIST pythoninlinepypiurl-2.post4.tar.gz 153310 BLAKE2B 
b7484cd9bebe912f9c8877c0f09df059130c2dc5c4da8c926f8df7945bcb7b255cdf810ce8cd16a987fb5bca3d1e71c088cd894968641db5dfae1c4c059df836
 SHA512 
86ff9e1c4b9353b1fbb475c7bb9d2a97bd9db8421ea5190b5a84832930b34cb5b79f8c3da68a5eb8db334f06851ec129cc6611a371e47b7c5de7a615feec5e05
+DIST python-pythoninlinepypiurl-2.post4.tar.gz 153310 BLAKE2B 
b7484cd9bebe912f9c8877c0f09df059130c2dc5c4da8c926f8df7945bcb7b255cdf810ce8cd16a987fb5bca3d1e71c088cd894968641db5dfae1c4c059df836
 SHA512 
86ff9e1c4b9353b1fbb475c7bb9d2a97bd9db8421ea5190b5a84832930b34cb5b79f8c3da68a5eb8db334f06851ec129cc6611a371e47b7c5de7a615feec5e05

diff --git 
a/testdata/repos/python/PythonFetchableCheck/PythonInlinePyPIURL/PythonInlinePyPIURL-2_p4-r2.ebuild
 
b/testdata/repos/python/PythonFetchableCheck/PythonInlinePyPIURL/PythonInlinePyPIURL-2_p4-r2.ebuild
new file mode 100644
index 00000000..8565c774
--- /dev/null
+++ 
b/testdata/repos/python/PythonFetchableCheck/PythonInlinePyPIURL/PythonInlinePyPIURL-2_p4-r2.ebuild
@@ -0,0 +1,15 @@
+# Copyright 2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+MY_P=${PN,,}-${PV/_p/.post}
+DESCRIPTION="Ebuild with PyPI URL"
+HOMEPAGE="https://example.com";
+SRC_URI="
+       mirror://pypi/${PN::1}/${PN}/${MY_P}.tar.gz -> python-${MY_P}.tar.gz
+"
+S=${WORKDIR}/${MY_P}
+
+LICENSE="BSD"
+SLOT="0"

Reply via email to