diff options
Diffstat (limited to 'dev-python/requests-cache')
-rw-r--r-- | dev-python/requests-cache/Manifest | 5 | ||||
-rw-r--r-- | dev-python/requests-cache/files/requests-cache-0.9.3-cattrs-22.patch | 150 | ||||
-rw-r--r-- | dev-python/requests-cache/requests-cache-0.9.3-r1.ebuild (renamed from dev-python/requests-cache/requests-cache-0.9.3.ebuild) | 22 | ||||
-rw-r--r-- | dev-python/requests-cache/requests-cache-0.9.4.ebuild | 81 |
4 files changed, 253 insertions, 5 deletions
diff --git a/dev-python/requests-cache/Manifest b/dev-python/requests-cache/Manifest index dad4e46466a3..0ef95e820aa0 100644 --- a/dev-python/requests-cache/Manifest +++ b/dev-python/requests-cache/Manifest @@ -1,3 +1,6 @@ +AUX requests-cache-0.9.3-cattrs-22.patch 6925 BLAKE2B f753c154741fe3a6b6fb05db19ddeadff669e2175a2113709921a2356dd53f4b867be8f9a3b91c36cbeeb891f9261c956b8728acdc03183a678117190afbd026 SHA512 f3258aa033e197dece2eca00169a833259d44c91488780edcc945839960bbeeb28f77d7dea806eecabcefea20aaa9c1a8c3448a0d34da58f89083cc7e82a597c DIST requests-cache-0.9.3.gh.tar.gz 1541517 BLAKE2B a6096e8db01ccc7e6afa94ca35460ad79bbc503fe32fb272c3b43bb3344cb4a4e3c6f9240dc8d26a49b2ae4b564de72be22553b40847480487c150b192aa9490 SHA512 d413fbed156bd3fca48db8b153b01a883ee72d62f6e8982d490a5378dc188c19d0b3af5e37e6f47d19ed0ba11b3c0e01489720d56df12afcf1b47088e1541221 -EBUILD requests-cache-0.9.3.ebuild 1782 BLAKE2B 69f1b1c7f55295cc8e02e768b8b4b67e70d54699c0c7f02577f31978d10f7f20b9f4ad5d1337e1041aba8113ce4e3fe00fe838eb387fec728fe2e30edbdf6f33 SHA512 013a159d27e894d91513ea85f2816429264d4f3af2e5d8964afe250cf75b98971ff578d289d06dc9d52b154c74e0ee58affe39b5dd7fff9f35f61c202109bae5 +DIST requests-cache-0.9.4.gh.tar.gz 1541821 BLAKE2B 90f3ffe8f4213a47d19c1190f1201bb484473a4ee2fae82dff59c9e80bc8c154739e99f5024aa55b436f9e620d5594441df61e2db44e3cbb381d394c1b6b4a0b SHA512 66023dc8b153070a532f160af58ac2102f6b9d536a0045c4c62ad1d4175f59df6e7db5a25422f5610a2f17049270ad0b63c6023ddddf64235432a63d2cce9b91 +EBUILD requests-cache-0.9.3-r1.ebuild 1949 BLAKE2B e0f87b5e1577ff920cb56f50564e1faba6589f28b61fd9893167cc95e4ed515fe04bec4e312879d56017fd2d7459602a3cca0a7c738e103037913b92bd0a66b1 SHA512 d63349d0c19426433db1e4c27087255c52b57e646c09507c4422708360528169a3a12d6047af5853ce3ab18f74c0f8c50d1f231f6061a28dd53daa6f888b8d6b +EBUILD requests-cache-0.9.4.ebuild 1967 BLAKE2B 393418ec7ee8ea27588d22623aba1827c79fce7c89b5dd28dd9534bfd945fdf3ee8f8e6770967f6ebc5684e41f2c9b9a6ce789ea89158ed3d4aaed273462364d SHA512 29986b8746fe34e488c4e6646b4e68b5861a3f128b25f8d958ca182f42d851fb29bb7dff5fde407bb0aa2b850754d8bd04439052115fee7ca92ce310a3b35f13 MISC metadata.xml 470 BLAKE2B 83ea1b65050486c1ff410664b87a19e514102ec030ea0f3d4076d435503f6ad2dd16caf8ff0c947d064c93955a743fe45d14c4d64471613c9de65c33f6708b93 SHA512 54160c5daeea03d90c896e30f35ed6ce8e7a29280a5e1bb1d1b0c04b5899a48ed3261d400762bf9c92bb73ddb554bcaa533b620ecda691e43fe89c1d943b7b54 diff --git a/dev-python/requests-cache/files/requests-cache-0.9.3-cattrs-22.patch b/dev-python/requests-cache/files/requests-cache-0.9.3-cattrs-22.patch new file mode 100644 index 000000000000..258738158355 --- /dev/null +++ b/dev-python/requests-cache/files/requests-cache-0.9.3-cattrs-22.patch @@ -0,0 +1,150 @@ +From 7917ba0dd12901d88137d3f8b487307eda38d326 Mon Sep 17 00:00:00 2001 +From: Jordan Cook <jordan.cook@pioneer.com> +Date: Sat, 9 Apr 2022 13:33:32 -0500 +Subject: [PATCH] Add compatibility with cattrs 21.1+, and clean up preconf + module a bit + +--- + requests_cache/__init__.py | 2 +- + requests_cache/serializers/preconf.py | 89 +++++++++++++++------------ + 2 files changed, 49 insertions(+), 42 deletions(-) + +diff --git a/requests_cache/__init__.py b/requests_cache/__init__.py +index 87781ba..835586c 100644 +--- a/requests_cache/__init__.py ++++ b/requests_cache/__init__.py +@@ -17,4 +17,4 @@ try: + from .session import * + # Log and ignore ImportErrors, if imported outside a virtualenv (e.g., just to check __version__) + except ImportError as e: +- logger.warning(e) ++ logger.warning(e, exc_info=True) +diff --git a/requests_cache/serializers/preconf.py b/requests_cache/serializers/preconf.py +index ed19fb4..cb099b8 100644 +--- a/requests_cache/serializers/preconf.py ++++ b/requests_cache/serializers/preconf.py +@@ -1,3 +1,4 @@ ++# flake8: noqa: F841 + """The ``cattrs`` library includes a number of `pre-configured converters + <https://cattrs.readthedocs.io/en/latest/preconf.html>`_ that perform some pre-serialization steps + required for specific serialization formats. +@@ -14,69 +15,75 @@ class that raises an ``ImportError`` at initialization time instead of at import + """ + import pickle + from functools import partial +- +-from cattr.preconf import bson as bson_preconf +-from cattr.preconf import json as json_preconf +-from cattr.preconf import msgpack, orjson, pyyaml, tomlkit, ujson ++from importlib import import_module + + from .._utils import get_placeholder_class + from .cattrs import CattrStage + from .pipeline import SerializerPipeline, Stage + +-base_stage = ( +- CattrStage() +-) #: Base stage for all serializer pipelines (or standalone dict serializer) ++ ++def make_stage(preconf_module: str): ++ """Create a preconf serializer stage from a module name, if dependencies are installed""" ++ try: ++ return CattrStage(import_module(preconf_module).make_converter) ++ except ImportError as e: ++ return get_placeholder_class(e) ++ ++ ++base_stage = CattrStage() #: Base stage for all serializer pipelines + dict_serializer = base_stage #: Partial serializer that unstructures responses into dicts +-bson_preconf_stage = CattrStage(bson_preconf.make_converter) #: Pre-serialization steps for BSON +-json_preconf_stage = CattrStage(json_preconf.make_converter) #: Pre-serialization steps for JSON +-msgpack_preconf_stage = CattrStage(msgpack.make_converter) #: Pre-serialization steps for msgpack +-orjson_preconf_stage = CattrStage(orjson.make_converter) #: Pre-serialization steps for orjson +-yaml_preconf_stage = CattrStage(pyyaml.make_converter) #: Pre-serialization steps for YAML +-toml_preconf_stage = CattrStage(tomlkit.make_converter) #: Pre-serialization steps for TOML +-ujson_preconf_stage = CattrStage(ujson.make_converter) #: Pre-serialization steps for ultrajson +-pickle_serializer = SerializerPipeline( +- [base_stage, pickle], is_binary=True +-) #: Complete pickle serializer ++pickle_serializer = SerializerPipeline([base_stage, pickle], is_binary=True) #: Pickle serializer + utf8_encoder = Stage(dumps=str.encode, loads=lambda x: x.decode()) #: Encode to bytes ++bson_preconf_stage = make_stage('cattr.preconf.bson') #: Pre-serialization steps for BSON ++json_preconf_stage = make_stage('cattr.preconf.json') #: Pre-serialization steps for JSON ++msgpack_preconf_stage = make_stage('cattr.preconf.msgpack') #: Pre-serialization steps for msgpack ++orjson_preconf_stage = make_stage('cattr.preconf.orjson') #: Pre-serialization steps for orjson ++toml_preconf_stage = make_stage('cattr.preconf.tomlkit') #: Pre-serialization steps for TOML ++ujson_preconf_stage = make_stage('cattr.preconf.ujson') #: Pre-serialization steps for ultrajson ++yaml_preconf_stage = make_stage('cattr.preconf.pyyaml') #: Pre-serialization steps for YAML + + + # Safe pickle serializer +-try: ++def signer_stage(secret_key=None, salt='requests-cache') -> Stage: ++ """Create a stage that uses ``itsdangerous`` to add a signature to responses on write, and ++ validate that signature with a secret key on read. Can be used in a ++ :py:class:`.SerializerPipeline` in combination with any other serialization steps. ++ """ + from itsdangerous import Signer + +- def signer_stage(secret_key=None, salt='requests-cache') -> Stage: +- """Create a stage that uses ``itsdangerous`` to add a signature to responses on write, and +- validate that signature with a secret key on read. Can be used in a +- :py:class:`.SerializerPipeline` in combination with any other serialization steps. +- """ +- return Stage(Signer(secret_key=secret_key, salt=salt), dumps='sign', loads='unsign') +- +- def safe_pickle_serializer( +- secret_key=None, salt='requests-cache', **kwargs +- ) -> SerializerPipeline: +- """Create a serializer that uses ``pickle`` + ``itsdangerous`` to add a signature to +- responses on write, and validate that signature with a secret key on read. +- """ +- return SerializerPipeline( +- [base_stage, pickle, signer_stage(secret_key, salt)], is_binary=True +- ) ++ return Stage(Signer(secret_key=secret_key, salt=salt), dumps='sign', loads='unsign') ++ ++ ++def safe_pickle_serializer(secret_key=None, salt='requests-cache', **kwargs) -> SerializerPipeline: ++ """Create a serializer that uses ``pickle`` + ``itsdangerous`` to add a signature to ++ responses on write, and validate that signature with a secret key on read. ++ """ ++ return SerializerPipeline([base_stage, pickle, signer_stage(secret_key, salt)], is_binary=True) ++ + ++try: ++ import itsdangerous # noqa: F401 + except ImportError as e: + signer_stage = get_placeholder_class(e) + safe_pickle_serializer = get_placeholder_class(e) + + +-# BSON serializer +-try: ++def _get_bson_functions(): ++ """Handle different function names between pymongo's bson and standalone bson""" + try: +- from bson import decode as _bson_loads +- from bson import encode as _bson_dumps ++ import pymongo # noqa: F401 ++ ++ return {'dumps': 'encode', 'loads': 'decode'} + except ImportError: +- from bson import dumps as _bson_dumps +- from bson import loads as _bson_loads ++ return {'dumps': 'dumps', 'loads': 'loads'} ++ ++ ++# BSON serializer ++try: ++ import bson + + bson_serializer = SerializerPipeline( +- [bson_preconf_stage, Stage(dumps=_bson_dumps, loads=_bson_loads)], is_binary=True ++ [bson_preconf_stage, Stage(bson, **_get_bson_functions())], is_binary=True + ) #: Complete BSON serializer; uses pymongo's ``bson`` if installed, otherwise standalone ``bson`` codec + except ImportError as e: + bson_serializer = get_placeholder_class(e) +-- +2.35.1 + diff --git a/dev-python/requests-cache/requests-cache-0.9.3.ebuild b/dev-python/requests-cache/requests-cache-0.9.3-r1.ebuild index 46702860b1d5..1d237051f1ea 100644 --- a/dev-python/requests-cache/requests-cache-0.9.3.ebuild +++ b/dev-python/requests-cache/requests-cache-0.9.3-r1.ebuild @@ -11,11 +11,13 @@ inherit distutils-r1 optfeature HOMEPAGE=" https://pypi.org/project/requests-cache/ - https://github.com/reclosedev/requests-cache/" + https://github.com/reclosedev/requests-cache/ +" DESCRIPTION="Persistent cache for requests library" SRC_URI=" https://github.com/reclosedev/requests-cache/archive/v${PV}.tar.gz - -> ${P}.gh.tar.gz" + -> ${P}.gh.tar.gz +" LICENSE="BSD" SLOT="0" @@ -27,7 +29,8 @@ RDEPEND=" dev-python/cattrs[${PYTHON_USEDEP}] >=dev-python/requests-2.0.0[${PYTHON_USEDEP}] dev-python/urllib3[${PYTHON_USEDEP}] - >=dev-python/url-normalize-1.4[${PYTHON_USEDEP}]" + >=dev-python/url-normalize-1.4[${PYTHON_USEDEP}] +" BDEPEND=" test? ( dev-python/itsdangerous[${PYTHON_USEDEP}] @@ -36,10 +39,21 @@ BDEPEND=" dev-python/responses[${PYTHON_USEDEP}] dev-python/timeout-decorator[${PYTHON_USEDEP}] dev-python/ujson[${PYTHON_USEDEP}] - )" + ) +" distutils_enable_tests pytest +PATCHES=( + "${FILESDIR}"/${P}-cattrs-22.patch +) + +src_prepare() { + # unpin the dep + sed -i -e '/cattrs/s:\^:>=:' pyproject.toml || die + distutils-r1_src_prepare +} + python_test() { local EPYTEST_IGNORE=( # These require extra servers running diff --git a/dev-python/requests-cache/requests-cache-0.9.4.ebuild b/dev-python/requests-cache/requests-cache-0.9.4.ebuild new file mode 100644 index 000000000000..13d1ae62b521 --- /dev/null +++ b/dev-python/requests-cache/requests-cache-0.9.4.ebuild @@ -0,0 +1,81 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +DISTUTILS_USE_PEP517=poetry +PYTHON_COMPAT=( python3_{8..10} ) +PYTHON_REQ_USE="sqlite" + +inherit distutils-r1 optfeature + +HOMEPAGE=" + https://pypi.org/project/requests-cache/ + https://github.com/reclosedev/requests-cache/ +" +DESCRIPTION="Persistent cache for requests library" +SRC_URI=" + https://github.com/reclosedev/requests-cache/archive/v${PV}.tar.gz + -> ${P}.gh.tar.gz +" + +LICENSE="BSD" +SLOT="0" +KEYWORDS="~amd64 ~x86" + +RDEPEND=" + dev-python/attrs[${PYTHON_USEDEP}] + dev-python/appdirs[${PYTHON_USEDEP}] + dev-python/cattrs[${PYTHON_USEDEP}] + >=dev-python/requests-2.0.0[${PYTHON_USEDEP}] + dev-python/urllib3[${PYTHON_USEDEP}] + >=dev-python/url-normalize-1.4[${PYTHON_USEDEP}] +" +BDEPEND=" + test? ( + dev-python/itsdangerous[${PYTHON_USEDEP}] + dev-python/pytest-httpbin[${PYTHON_USEDEP}] + dev-python/requests-mock[${PYTHON_USEDEP}] + dev-python/responses[${PYTHON_USEDEP}] + dev-python/timeout-decorator[${PYTHON_USEDEP}] + dev-python/ujson[${PYTHON_USEDEP}] + ) +" + +distutils_enable_tests pytest + +PATCHES=( + "${FILESDIR}"/requests-cache-0.9.3-cattrs-22.patch +) + +src_prepare() { + # unpin the dep + sed -i -e '/cattrs/s:\^:>=:' pyproject.toml || die + distutils-r1_src_prepare +} + +python_test() { + local EPYTEST_IGNORE=( + # These require extra servers running + tests/integration/test_dynamodb.py + tests/integration/test_gridfs.py + tests/integration/test_mongodb.py + tests/integration/test_redis.py + ) + local EPYTEST_DESELECT=( + # Requires Internet access + tests/integration/test_compat.py::test_version_upgrade + ) + + local -x USE_PYTEST_HTTPBIN=true + epytest +} + +pkg_postinst() { + optfeature "redis backend" "dev-python/redis-py" + optfeature "MongoDB backend" "dev-python/pymongo" + + optfeature "JSON serialization" "dev-python/ujson" + optfeature "YAML serialization" "dev-python/pyyaml" + optfeature "signing serialized data" "dev-python/itsdangerous" +} |