Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-unearth for openSUSE:Factory checked in at 2022-12-07 17:35:09 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-unearth (Old) and /work/SRC/openSUSE:Factory/.python-unearth.new.1835 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-unearth" Wed Dec 7 17:35:09 2022 rev:2 rq:1040780 version:0.6.2 Changes: -------- --- /work/SRC/openSUSE:Factory/python-unearth/python-unearth.changes 2022-08-20 20:28:31.241328973 +0200 +++ /work/SRC/openSUSE:Factory/.python-unearth.new.1835/python-unearth.changes 2022-12-07 17:36:28.353034405 +0100 @@ -1,0 +2,13 @@ +Tue Dec 6 17:07:50 UTC 2022 - Yogalakshmi Arunachalam <yarunacha...@suse.com> + +- Update to version 0.6.2 + * Features + Log the file size when downloading - by @frostming in #22 (9514a) + Use token as the username if not specified Close #18 - by @frostming in #18 (6d2a6) + Add more logs about the caches - by @frostming (e0000) + * Bug Fixes + Cache the index fetch result in memory - by @frostming (eacc0) + * Chores + Add python 3.11 to the test matrix - by @frostming (25338) + +------------------------------------------------------------------- Old: ---- unearth-0.6.1.tar.gz New: ---- unearth-0.6.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-unearth.spec ++++++ --- /var/tmp/diff_new_pack.OuwdWh/_old 2022-12-07 17:36:28.777036726 +0100 +++ /var/tmp/diff_new_pack.OuwdWh/_new 2022-12-07 17:36:28.785036771 +0100 @@ -17,7 +17,7 @@ Name: python-unearth -Version: 0.6.1 +Version: 0.6.2 Release: 0 Summary: A utility to fetch and download python packages License: MIT @@ -34,7 +34,7 @@ Requires: python-packaging >= 20 Requires: python-requests >= 2.25 Requires(post): update-alternatives -Requires(postun): update-alternatives +Requires(postun):update-alternatives BuildArch: noarch %if 0%{?python_version_nodots} < 38 Requires: python-cached-property >= 1.5.2 ++++++ unearth-0.6.1.tar.gz -> unearth-0.6.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/unearth-0.6.1/PKG-INFO new/unearth-0.6.2/PKG-INFO --- old/unearth-0.6.1/PKG-INFO 2022-07-27 03:51:47.756154300 +0200 +++ new/unearth-0.6.2/PKG-INFO 2022-11-23 03:47:28.657159600 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: unearth -Version: 0.6.1 +Version: 0.6.2 Summary: A utility to fetch and download python packages License: MIT Author-email: Frost Ming <miangh...@gmail.com> @@ -18,76 +18,77 @@ Project-URL: Homepage, https://github.com/frostming/unearth Project-URL: Repository, https://github.com/frostming/unearth Description-Content-Type: text/markdown -Description: # unearth - - <!--index start--> - - [](https://github.com/frostming/unearth/actions?query=workflow%3Aci) - [](https://pypi.org/project/unearth/) - [](https://github.com/psf/black) - [](https://pdm.fming.dev) - - A utility to fetch and download python packages - - > _NOTICE_ This project is still in its early stage and the API may change before 1.0 release. - - ## Why this project? - - This project exists as the last piece to complete the puzzle of a package manager. The other pieces are: - - - [resolvelib](https://pypi.org/project/resolvelib/) - Resolves concrete dependencies from a set of (abstract) requirements. - - [unearth](https://pypi.org/project/unearth/) _(This project)_ - Finds and downloads the best match(es) for a given requirement. - - [build](https://pypi.org/project/build/) - Builds wheels from the source code. - - [installer](https://pypi.org/project/installer/) - Installs packages from wheels. - - They provide all the low-level functionalities that are needed to resolve and install packages. - - ## Why not pip? - - The core functionality is basically extracted from pip. However, pip is not designed to be used as a library and hence the API is not very stable. - Unearth serves as a stable replacement for pip's `PackageFinder` API. It will follow the conventions of [Semantic Versioning](https://semver.org/) so that downstream projects can use it to develop their own package finding and downloading. - - ## Requirements - - unearth requires Python >=3.7 - - ## Installation - - ```bash - $ python -m pip install --upgrade unearth - ``` - - ## Quickstart - - Get the best matching candidate for a requirement: - - ```python - >>> from unearth import PackageFinder - >>> finder = PackageFinder(index_urls=['https://pypi.org/simple/']) - >>> result = finder.find_best_match("flask>=2") - >>> result.best_candidate - Package(name='flask', version='2.1.2', link=<Link https://files.pythonhosted.org/packages/ba/76/e9580e494eaf6f09710b0f3b9000c9c0363e44af5390be32bb0394165853/Flask-2.1.2-py3-none-any.whl#sha256=fad5b446feb0d6db6aec0c3184d16a8c1f6c3e464b511649c8918a9be100b4fe (from https://pypi.org/simple/flask)>) - ``` - - Using the CLI: - - ```bash - $ unearth "flask>=2" - { - "name": "flask", - "version": "2.1.2", - "link": { - "url": "https://files.pythonhosted.org/packages/ba/76/e9580e494eaf6f09710b0f3b9000c9c0363e44af5390be32bb0394165853/Flask-2.1.2-py3-none-any.whl#sha256=fad5b446feb0d6db6aec0c3184d16a8c1f6c3e464b511649c8918a9be100b4fe", - "comes_from": "https://pypi.org/simple/flask", - "yank_reason": null, - "requires_python": ">=3.7" - } - } - ``` - - <!--index end--> - - ## Documentation - - [Read the docs](https://unearth.readthedocs.io/en/latest/) + +# unearth + +<!--index start--> + +[](https://github.com/frostming/unearth/actions?query=workflow%3Aci) +[](https://pypi.org/project/unearth/) +[](https://github.com/psf/black) +[](https://pdm.fming.dev) + +A utility to fetch and download python packages + +> _NOTICE_ This project is still in its early stage and the API may change before 1.0 release. + +## Why this project? + +This project exists as the last piece to complete the puzzle of a package manager. The other pieces are: + +- [resolvelib](https://pypi.org/project/resolvelib/) - Resolves concrete dependencies from a set of (abstract) requirements. +- [unearth](https://pypi.org/project/unearth/) _(This project)_ - Finds and downloads the best match(es) for a given requirement. +- [build](https://pypi.org/project/build/) - Builds wheels from the source code. +- [installer](https://pypi.org/project/installer/) - Installs packages from wheels. + +They provide all the low-level functionalities that are needed to resolve and install packages. + +## Why not pip? + +The core functionality is basically extracted from pip. However, pip is not designed to be used as a library and hence the API is not very stable. +Unearth serves as a stable replacement for pip's `PackageFinder` API. It will follow the conventions of [Semantic Versioning](https://semver.org/) so that downstream projects can use it to develop their own package finding and downloading. + +## Requirements + +unearth requires Python >=3.7 + +## Installation + +```bash +$ python -m pip install --upgrade unearth +``` + +## Quickstart + +Get the best matching candidate for a requirement: + +```python +>>> from unearth import PackageFinder +>>> finder = PackageFinder(index_urls=['https://pypi.org/simple/']) +>>> result = finder.find_best_match("flask>=2") +>>> result.best_candidate +Package(name='flask', version='2.1.2', link=<Link https://files.pythonhosted.org/packages/ba/76/e9580e494eaf6f09710b0f3b9000c9c0363e44af5390be32bb0394165853/Flask-2.1.2-py3-none-any.whl#sha256=fad5b446feb0d6db6aec0c3184d16a8c1f6c3e464b511649c8918a9be100b4fe (from https://pypi.org/simple/flask)>) +``` + +Using the CLI: + +```bash +$ unearth "flask>=2" +{ + "name": "flask", + "version": "2.1.2", + "link": { + "url": "https://files.pythonhosted.org/packages/ba/76/e9580e494eaf6f09710b0f3b9000c9c0363e44af5390be32bb0394165853/Flask-2.1.2-py3-none-any.whl#sha256=fad5b446feb0d6db6aec0c3184d16a8c1f6c3e464b511649c8918a9be100b4fe", + "comes_from": "https://pypi.org/simple/flask", + "yank_reason": null, + "requires_python": ">=3.7" + } +} +``` + +<!--index end--> + +## Documentation + +[Read the docs](https://unearth.readthedocs.io/en/latest/) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/unearth-0.6.1/pyproject.toml new/unearth-0.6.2/pyproject.toml --- old/unearth-0.6.1/pyproject.toml 2022-07-27 03:51:35.035919700 +0200 +++ new/unearth-0.6.2/pyproject.toml 2022-11-23 03:47:14.640849600 +0100 @@ -28,7 +28,7 @@ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3 :: Only", ] -version = "0.6.1" +version = "0.6.2" [project.license] text = "MIT" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/unearth-0.6.1/src/unearth/auth.py new/unearth-0.6.2/src/unearth/auth.py --- old/unearth-0.6.1/src/unearth/auth.py 2022-07-27 03:51:35.035919700 +0200 +++ new/unearth-0.6.2/src/unearth/auth.py 2022-11-23 03:47:14.640849600 +0100 @@ -40,11 +40,12 @@ return cred.username, cred.password return None - if username: - logger.debug("Getting password from keyring for %s", url) - password = keyring.get_password(url, username) - if password: - return username, password + if not username: + username = "__token__" + logger.debug("Getting password from keyring for %s@%s", username, url) + password = keyring.get_password(url, username) + if password: + return username, password except Exception as exc: logger.warning( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/unearth-0.6.1/src/unearth/collector.py new/unearth-0.6.2/src/unearth/collector.py --- old/unearth-0.6.1/src/unearth/collector.py 2022-07-27 03:51:35.035919700 +0200 +++ new/unearth-0.6.2/src/unearth/collector.py 2022-11-23 03:47:14.640849600 +0100 @@ -1,6 +1,7 @@ """Collect links from simple index or find links location.""" from __future__ import annotations +import functools import logging import mimetypes from html.parser import HTMLParser @@ -86,23 +87,27 @@ yield from _collect_links_from_html(session, location) -def fetch_page(session: PyPISession, location: Link) -> HTMLPage | None: +@functools.lru_cache(maxsize=None) +def fetch_page(session: PyPISession, location: Link) -> HTMLPage: if location.is_vcs: - logger.warning("Skip %s because it is a VCS link.", location.redacted) - return None - try: - resp = _get_html_response(session, location) - except LinkCollectError as e: - logger.warning("Skip %s because of %s.", location.redacted, e) - return None + raise LinkCollectError("It is a VCS link.") + resp = _get_html_response(session, location) + from_cache = getattr(resp, "from_cache", False) + cache_text = " (from cache)" if from_cache else "" + logger.debug("Fetching HTML page %s%s", location.redacted, cache_text) return HTMLPage(Link(resp.url), resp.text) def _collect_links_from_html(session: PyPISession, location: Link) -> Iterable[Link]: if not session.is_secure_origin(location): return [] - page = fetch_page(session, location) - return parse_html_page(page) if page is not None else [] + try: + page = fetch_page(session, location) + except LinkCollectError as e: + logger.warning("Failed to collect links from %s: %s", location.redacted, e) + return [] + else: + return parse_html_page(page) def _is_html_file(file_url: str) -> bool: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/unearth-0.6.1/src/unearth/evaluator.py new/unearth-0.6.2/src/unearth/evaluator.py --- old/unearth-0.6.1/src/unearth/evaluator.py 2022-07-27 03:51:35.035919700 +0200 +++ new/unearth-0.6.2/src/unearth/evaluator.py 2022-11-23 03:47:14.640849600 +0100 @@ -57,7 +57,7 @@ impl: str | None = None platforms: list[str] | None = None - def __post_init__(self): + def __post_init__(self) -> None: self._valid_tags: list[Tag] | None = None def supported_tags(self) -> list[Tag]: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/unearth-0.6.1/src/unearth/finder.py new/unearth-0.6.2/src/unearth/finder.py --- old/unearth-0.6.1/src/unearth/finder.py 2022-07-27 03:51:35.035919700 +0200 +++ new/unearth-0.6.2/src/unearth/finder.py 2022-11-23 03:47:14.640849600 +0100 @@ -295,7 +295,7 @@ requirement: packaging.requirements.Requirement | str, allow_yanked: bool | None = None, allow_prereleases: bool | None = None, - hashes: dict[str, list[str]] = None, + hashes: dict[str, list[str]] | None = None, ) -> BestMatch: """Find the best match for the given requirement. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/unearth-0.6.1/src/unearth/preparer.py new/unearth-0.6.2/src/unearth/preparer.py --- old/unearth-0.6.1/src/unearth/preparer.py 2022-07-27 03:51:35.035919700 +0200 +++ new/unearth-0.6.2/src/unearth/preparer.py 2022-11-23 03:47:14.640849600 +0100 @@ -22,6 +22,7 @@ XZ_EXTENSIONS, ZIP_EXTENSIONS, display_path, + format_size, ) from unearth.vcs import vcs_support @@ -296,13 +297,16 @@ # A remote artfiact link, check the download dir first artifact = download_dir / link.filename if not _check_downloaded(artifact, hashes): - logger.info("Downloading %s to %s", link, artifact) resp = session.get(link.normalized, stream=True) try: resp.raise_for_status() except HTTPError as e: raise UnpackError(f"Download failed: {e}") from None - + if getattr(resp, "from_cache", False): + logger.info("Using cached %s", link) + else: + size = format_size(resp.headers.get("Content-Length", "")) + logger.info("Downloading %s (%s)", link, size) with artifact.open("wb") as f: for chunk in resp.iter_content(chunk_size=READ_CHUNK_SIZE): if chunk: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/unearth-0.6.1/src/unearth/utils.py new/unearth-0.6.2/src/unearth/utils.py --- old/unearth-0.6.1/src/unearth/utils.py 2022-07-27 03:51:35.035919700 +0200 +++ new/unearth-0.6.2/src/unearth/utils.py 2022-11-23 03:47:14.640849600 +0100 @@ -167,3 +167,18 @@ ext = base[-4:] + ext base = base[:-4] return base, ext + + +def format_size(size: str) -> str: + try: + int_size = int(size) + except (TypeError, ValueError): + return "size unknown" + if int_size > 1000 * 1000: + return f"{int_size / 1000.0 / 1000:.1f} MB" + elif int_size > 10 * 1000: + return f"{int(int_size / 1000)} kB" + elif int_size > 1000: + return f"{int_size / 1000.0:.1f} kB" + else: + return f"{int(int_size)} bytes" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/unearth-0.6.1/tests/test_collector.py new/unearth-0.6.2/tests/test_collector.py --- old/unearth-0.6.1/tests/test_collector.py 2022-07-27 03:51:35.039919600 +0200 +++ new/unearth-0.6.2/tests/test_collector.py 2022-11-23 03:47:14.644849800 +0100 @@ -19,7 +19,7 @@ ) ) assert not collected - assert "because it is a VCS link" in caplog.records[0].message + assert "It is a VCS link" in caplog.records[0].message def test_collect_links_from_404_page(pypi, session):