Skip to content

Commit

Permalink
python: Include PYPI_PN opportunities in PythonInlinePyPIURI
Browse files Browse the repository at this point in the history
Fixes #568

Signed-off-by: Michał Górny <[email protected]>
Closes: #569
Signed-off-by: Arthur Zamarin <[email protected]>
  • Loading branch information
mgorny authored and arthurzam committed Mar 24, 2023
1 parent 5704c77 commit 583f156
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 85 deletions.
13 changes: 9 additions & 4 deletions src/pkgcheck/checks/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,22 +708,25 @@ def __init__(
replacement: typing.Optional[tuple[str, ...]] = None,
normalize: typing.Optional[bool] = None,
append: typing.Optional[bool] = None,
pypi_pn: typing.Optional[str] = None,
**kwargs,
) -> None:
super().__init__(**kwargs)
self.url = url
self.replacement = tuple(replacement) if replacement is not None else None
self.normalize = normalize
self.append = append
self.pypi_pn = pypi_pn

@property
def desc(self) -> str:
if self.replacement is None:
no_norm = "" if self.normalize else "set PYPI_NO_NORMALIZE=1, "
pypi_pn = "" if self.pypi_pn is None else f"set PYPI_PN={self.pypi_pn}, "
final = "use SRC_URI+= for other URIs" if self.append else "remove SRC_URI"
return (
"inline PyPI URI found matching pypi.eclass default, inherit the eclass, "
f"{no_norm}and {final} instead"
f"{no_norm}{pypi_pn}and {final} instead"
)
else:
return (
Expand Down Expand Up @@ -823,9 +826,11 @@ def check_pypi_mirror(self, pkg, fetchables):
if not normalize and filename_pn != pn:
# ignore malformed URLs
return
if pn == pkg.package:
yield PythonInlinePyPIURI(uri, normalize=normalize, append=append, pkg=pkg)
return
pn, _ = self.simplify_pn_pv(pn, None, pkg, True)
yield PythonInlinePyPIURI(
uri, normalize=normalize, append=append, pypi_pn=pn, pkg=pkg
)
return

# otherwise, yield result for every URL, with suggested replacement
for uri, dist_filename in pypi_uris:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "0", "url": "https://files.pythonhosted.org/packages/source/P/PythonInlinePyPIURL/PythonInlinePyPIURL-0.zip", "replacement": ["pypi_sdist_url", "--no-normalize", "\"${PN}\"", "\"${PV}\"", ".zip"], "normalize": null, "append": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "1_alpha1", "url": "https://files.pythonhosted.org/packages/source/P/PythonInlinePyPIURL/PythonInlinePyPIURL-1a1.tar.gz", "replacement": null, "normalize": false, "append": false}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "1_alpha1-r1", "url": "https://files.pythonhosted.org/packages/source/P/PythonInlinePyPIURL/PythonInlinePyPIURL-1a1.tar.gz", "replacement": null, "normalize": false, "append": true}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "2_p4", "url": "https://files.pythonhosted.org/packages/source/P/PythonInlinePyPIURL/pythoninlinepypiurl-2.post4.tar.gz", "replacement": null, "normalize": true, "append": false}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "2_p4-r1", "url": "https://files.pythonhosted.org/packages/source/P/PythonInlinePyPIURL/pythoninlinepypiurl-2.post4.tar.gz", "replacement": null, "normalize": true, "append": true}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "3", "url": "https://files.pythonhosted.org/packages/py3/p/pypi-url/pypi_url-3-py3-none-any.whl", "replacement": ["pypi_wheel_url", "--unpack", "pypi-url"], "normalize": null, "append": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "3", "url": "https://files.pythonhosted.org/packages/source/p/pypi-url/pypi-url-3.zip", "replacement": ["pypi_sdist_url", "--no-normalize", "pypi-url", "\"${PV}\"", ".zip"], "normalize": null, "append": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "3-r1", "url": "https://files.pythonhosted.org/packages/py3/p/pypi-url/pypi_url-3-py3-none-any.whl", "replacement": ["pypi_wheel_url", "pypi-url"], "normalize": null, "append": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "3-r1", "url": "https://files.pythonhosted.org/packages/source/p/pypi-url/pypi-url-3.tar.gz", "replacement": ["pypi_sdist_url", "--no-normalize", "pypi-url"], "normalize": null, "append": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "4", "url": "https://files.pythonhosted.org/packages/cp310/P/PythonInlinePyPIURL/pythoninlinepypiurl-4-cp310-cp310-linux_x86_64.whl", "replacement": ["pypi_wheel_url", "\"${PN}\"", "\"${PV}\"", "cp310", "cp310-linux_x86_64"], "normalize": null, "append": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "4", "url": "https://files.pythonhosted.org/packages/source/p/pypi-url/pypi_url-4.tar.gz", "replacement": ["pypi_sdist_url", "pypi-url"], "normalize": null, "append": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "python-inline-pypi-url", "version": "0", "url": "https://files.pythonhosted.org/packages/source/p/python.inline-pypi-url/python.inline-pypi-url-0.tar.gz", "replacement": ["pypi_sdist_url", "--no-normalize", "\"${PN/-/.}\""], "normalize": null, "append": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "python-inline-pypi-url", "version": "1", "url": "https://files.pythonhosted.org/packages/source/p/python.inline.pypi.url/python.inline.pypi.url-1.tar.gz", "replacement": ["pypi_sdist_url", "--no-normalize", "\"${PN//-/.}\""], "normalize": null, "append": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "python-inline-pypi-url", "version": "100", "url": "https://files.pythonhosted.org/packages/source/p/python_inline-pypi-url/python_inline-pypi-url-100.tar.gz", "replacement": ["pypi_sdist_url", "--no-normalize", "\"${PN/-/_}\""], "normalize": null, "append": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "python-inline-pypi-url", "version": "200", "url": "https://files.pythonhosted.org/packages/source/P/Python-inline-pypi-url/Python-inline-pypi-url-200.tar.gz", "replacement": ["pypi_sdist_url", "--no-normalize", "\"${PN^}\""], "normalize": null, "append": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "python-inline-pypi-url", "version": "1000", "url": "https://files.pythonhosted.org/packages/source/p/python.inline-pypi-url/python_inline_pypi_url-1000.tar.gz", "replacement": ["pypi_sdist_url", "\"${PN/-/.}\""], "normalize": null, "append": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "python-inline-pypi-url", "version": "1000-r1", "url": "https://files.pythonhosted.org/packages/source/p/python.inline.pypi.url/python_inline_pypi_url-1000.tar.gz", "replacement": ["pypi_sdist_url", "\"${PN//-/.}\""], "normalize": null, "append": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "python-inline-pypi-url", "version": "1000-r100", "url": "https://files.pythonhosted.org/packages/source/p/python_inline-pypi-url/python_inline_pypi_url-1000.tar.gz", "replacement": ["pypi_sdist_url", "\"${PN/-/_}\""], "normalize": null, "append": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "python-inline-pypi-url", "version": "1000-r101", "url": "https://files.pythonhosted.org/packages/source/p/python_inline_pypi_url/python_inline_pypi_url-1000.tar.gz", "replacement": ["pypi_sdist_url", "\"${PN//-/_}\""], "normalize": null, "append": null}
{"__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": ["pypi_sdist_url", "\"${PN^}\""], "normalize": null, "append": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "0", "url": "https://files.pythonhosted.org/packages/source/P/PythonInlinePyPIURL/PythonInlinePyPIURL-0.zip", "replacement": ["pypi_sdist_url", "--no-normalize", "\"${PN}\"", "\"${PV}\"", ".zip"], "normalize": null, "append": null, "pypi_pn": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "1_alpha1", "url": "https://files.pythonhosted.org/packages/source/P/PythonInlinePyPIURL/PythonInlinePyPIURL-1a1.tar.gz", "replacement": null, "normalize": false, "append": false, "pypi_pn": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "1_alpha1-r1", "url": "https://files.pythonhosted.org/packages/source/P/PythonInlinePyPIURL/PythonInlinePyPIURL-1a1.tar.gz", "replacement": null, "normalize": false, "append": true, "pypi_pn": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "2_p4", "url": "https://files.pythonhosted.org/packages/source/P/PythonInlinePyPIURL/pythoninlinepypiurl-2.post4.tar.gz", "replacement": null, "normalize": true, "append": false, "pypi_pn": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "2_p4-r1", "url": "https://files.pythonhosted.org/packages/source/P/PythonInlinePyPIURL/pythoninlinepypiurl-2.post4.tar.gz", "replacement": null, "normalize": true, "append": true, "pypi_pn": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "3", "url": "https://files.pythonhosted.org/packages/py3/p/pypi-url/pypi_url-3-py3-none-any.whl", "replacement": ["pypi_wheel_url", "--unpack", "pypi-url"], "normalize": null, "append": null, "pypi_pn": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "3", "url": "https://files.pythonhosted.org/packages/source/p/pypi-url/pypi-url-3.zip", "replacement": ["pypi_sdist_url", "--no-normalize", "pypi-url", "\"${PV}\"", ".zip"], "normalize": null, "append": null, "pypi_pn": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "3-r1", "url": "https://files.pythonhosted.org/packages/py3/p/pypi-url/pypi_url-3-py3-none-any.whl", "replacement": ["pypi_wheel_url", "pypi-url"], "normalize": null, "append": null, "pypi_pn": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "3-r1", "url": "https://files.pythonhosted.org/packages/source/p/pypi-url/pypi-url-3.tar.gz", "replacement": ["pypi_sdist_url", "--no-normalize", "pypi-url"], "normalize": null, "append": null, "pypi_pn": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "4", "url": "https://files.pythonhosted.org/packages/cp310/P/PythonInlinePyPIURL/pythoninlinepypiurl-4-cp310-cp310-linux_x86_64.whl", "replacement": ["pypi_wheel_url", "\"${PN}\"", "\"${PV}\"", "cp310", "cp310-linux_x86_64"], "normalize": null, "append": null, "pypi_pn": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "PythonInlinePyPIURL", "version": "4", "url": "https://files.pythonhosted.org/packages/source/p/pypi-url/pypi_url-4.tar.gz", "replacement": ["pypi_sdist_url", "pypi-url"], "normalize": null, "append": null, "pypi_pn": null}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "python-inline-pypi-url", "version": "0", "url": "https://files.pythonhosted.org/packages/source/p/python.inline-pypi-url/python.inline-pypi-url-0.tar.gz", "replacement": null, "normalize": false, "append": false, "pypi_pn": "\"${PN/-/.}\""}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "python-inline-pypi-url", "version": "1", "url": "https://files.pythonhosted.org/packages/source/p/python.inline.pypi.url/python.inline.pypi.url-1.tar.gz", "replacement": null, "normalize": false, "append": false, "pypi_pn": "\"${PN//-/.}\""}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "python-inline-pypi-url", "version": "100", "url": "https://files.pythonhosted.org/packages/source/p/python_inline-pypi-url/python_inline-pypi-url-100.tar.gz", "replacement": null, "normalize": false, "append": false, "pypi_pn": "\"${PN/-/_}\""}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "python-inline-pypi-url", "version": "200", "url": "https://files.pythonhosted.org/packages/source/P/Python-inline-pypi-url/Python-inline-pypi-url-200.tar.gz", "replacement": null, "normalize": false, "append": false, "pypi_pn": "\"${PN^}\""}
{"__class__": "PythonInlinePyPIURI", "category": "PythonFetchableCheck", "package": "python-inline-pypi-url", "version": "1000", "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": "1000-r1", "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": "1000-r100", "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": "1000-r101", "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": "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}
Loading

0 comments on commit 583f156

Please sign in to comment.