diff options
author | V3n3RiX <venerix@koprulu.sector> | 2024-02-03 11:44:27 +0000 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2024-02-03 11:44:27 +0000 |
commit | 79e5685b8db7602719212510574962664af2b036 (patch) | |
tree | 9ba712c7c9bf3e76035ea6f13b256516cfb217f9 /dev-python/httpbin | |
parent | ab5404adfda90358dfaba11eba5579f3f2b7f186 (diff) |
gentoo auto-resync : 03:02:2024 - 11:44:27
Diffstat (limited to 'dev-python/httpbin')
-rw-r--r-- | dev-python/httpbin/Manifest | 3 | ||||
-rw-r--r-- | dev-python/httpbin/files/httpbin-0.10.1-optional-flasgger.patch | 87 | ||||
-rw-r--r-- | dev-python/httpbin/httpbin-0.10.1-r4.ebuild (renamed from dev-python/httpbin/httpbin-0.10.1-r3.ebuild) | 23 |
3 files changed, 107 insertions, 6 deletions
diff --git a/dev-python/httpbin/Manifest b/dev-python/httpbin/Manifest index 37c02f68e5de..376a9632841c 100644 --- a/dev-python/httpbin/Manifest +++ b/dev-python/httpbin/Manifest @@ -1,4 +1,5 @@ +AUX httpbin-0.10.1-optional-flasgger.patch 3009 BLAKE2B 4e71b09cedce87f58fae6295f91efbe89e7619a8f9a778e145c34e21b2f974b37547930b331e949f656a950aef057f497e81dc6e255ff33c2f1d0ea596e45d28 SHA512 c57143d4e31c6d74d2155cb8539807ec472ffda7060fbd0e694267c06c21f9cea1b6e62003563d0cbb9dcbd1b6a515855ba5cf358fd216a9ee495bc9964d6c4f AUX httpbin-0.10.1-werkzeug-3.patch 2753 BLAKE2B eb335f980867d0f55b4f790689b890c4c92246e870f3714fcda88ec302491ff76e6cc46929d227d0ef3b5b5682152d0ad83dd97e46a16729282de1497935c5e5 SHA512 b232558f609425f7cb674bf34fa0116c76e69d93ce52df656a4d76a7fec8e5a9d6f872abc681bbafede7aa5c7187439a695fbbf18ebc5c8271001bc7776a7fb7 DIST httpbin-0.10.1.tar.gz 107058 BLAKE2B a46732946fc3454e2ae71c4eec4f88521e190b736445c54f555021a273a75f57acbc9234237e6973a21fc3bf8f71d8c8b51d6422d719f03546ecd6887a20fe1b SHA512 e3b851253c347893a80e866e7d0188c572f2a87a540125de3d9cbe0b8c3f1ddfab2c60ee3ffde3fd7274fc662294c978c39b1b52acfd92c52fd552966da203be -EBUILD httpbin-0.10.1-r3.ebuild 1007 BLAKE2B 1030be1cbd991eb38eff944ed9f677662de228c61906e55f6941e03b6df552ef199865303e538960aa8564ab6335eb0327c8f9a113de751b19b9a646ef6e85dc SHA512 5b054c9957180e6fd3594882afcd352974e214470d77e97276c3fe9713bcbd2d19f6ca14daee2c7c310de172c1de14f6fd6695780758603ede97d045ae7b67eb +EBUILD httpbin-0.10.1-r4.ebuild 1273 BLAKE2B 8e9f8928bb6a813c87e7928b6f4364a1b5103efd9458196f02c323bdbbf83f1626d563d321494c12a2ca70aab06232ebd7f5c4fa4263ca804b15264dda04dddb SHA512 6e712edf26e963d4b43db50538b3d1868a0056141c4f95cde4850127421e042b2e2c2d271ea18e1698ffde93c4930fa1918eab165bf19f1a2da36a573c9f4c35 MISC metadata.xml 445 BLAKE2B c577334830bc0d51f9df221e224c231c254b3db9129e4028d53cbd96a4481728e3b721b44f569c243deeecfb38e8dc81a7566a0b7ccd665d51b1a69a3687eb18 SHA512 fcdbd0c24e12d91df89af24befa6c9600f28083c3fe38e88ebec9856f4fb5c4c137c3b85f2271422c513bbd7c31a457f8290ebc2dd755d9117d57aa42883eec8 diff --git a/dev-python/httpbin/files/httpbin-0.10.1-optional-flasgger.patch b/dev-python/httpbin/files/httpbin-0.10.1-optional-flasgger.patch new file mode 100644 index 000000000000..c3d87ec4144d --- /dev/null +++ b/dev-python/httpbin/files/httpbin-0.10.1-optional-flasgger.patch @@ -0,0 +1,87 @@ +From 65e397d7332ab87e3b2455ff9dc99af24861b58b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org> +Date: Sat, 3 Feb 2024 11:20:00 +0100 +Subject: [PATCH] Support using httpbin without flasgger + +Make the dependency on flasgger optional. The dependency has been added +relatively recently (i.e. before the original package was abandoned but +after its last release), and it is only used to provide a more dynamic +landing page. This is unnecessary for use of httpbin for testing, +and it introduces an indirect dependency on Rust that is problematic. + +With this change, flasgger is no longer installed by default. It can be +enabled via "[flasgger]" extra. When flasgger is not available, httpbin +redirects to the "legacy" index page. +--- + httpbin/core.py | 17 +++++++++++++++-- + pyproject.toml | 4 +++- + tests/test_httpbin.py | 4 +++- + 3 files changed, 21 insertions(+), 4 deletions(-) + +diff --git a/httpbin/core.py b/httpbin/core.py +index a82c1b8..77576a4 100644 +--- a/httpbin/core.py ++++ b/httpbin/core.py +@@ -33,7 +33,10 @@ try: + except ImportError: # werkzeug < 2.1 + from werkzeug.wrappers import BaseResponse as Response + +-from flasgger import Swagger, NO_SANITIZER ++try: ++ from flasgger import Swagger, NO_SANITIZER ++except ImportError: ++ Swagger = None + + from . import filters + from .helpers import ( +@@ -165,7 +168,10 @@ swagger_config = { + "specs_route": "/", + } + +-swagger = Swagger(app, sanitizer=NO_SANITIZER, template=template, config=swagger_config) ++if Swagger is not None: ++ swagger = Swagger(app, sanitizer=NO_SANITIZER, template=template, config=swagger_config) ++else: ++ app.logger.warning("Swagger not found, legacy index will be used.") + + # Set up Bugsnag exception tracking, if desired. To use Bugsnag, install the + # Bugsnag Python client with the command "pip install bugsnag", and set the +@@ -244,6 +250,13 @@ def set_cors_headers(response): + # ------ + + ++if Swagger is None: ++ @app.route("/") ++ def no_flasgger_index(): ++ """Redirect to legacy index if flasgger is not available.""" ++ return redirect(url_for("view_landing_page")) ++ ++ + @app.route("/legacy") + def view_landing_page(): + """Generates Landing Page in legacy layout.""" +diff --git a/tests/test_httpbin.py b/tests/test_httpbin.py +index 6b75124..2ce63a6 100755 +--- a/tests/test_httpbin.py ++++ b/tests/test_httpbin.py +@@ -10,6 +10,7 @@ from hashlib import md5, sha256, sha512 + from io import BytesIO + + import httpbin ++from httpbin.core import Swagger + from httpbin.helpers import parse_multi_value_header + + +@@ -115,7 +116,8 @@ class HttpbinTestCase(unittest.TestCase): + + def test_index(self): + response = self.app.get('/', headers={'User-Agent': 'test'}) +- self.assertEqual(response.status_code, 200) ++ self.assertEqual(response.status_code, ++ 200 if Swagger is not None else 302) + + def get_data(self, response): + if 'get_data' in dir(response): +-- +2.43.0 + diff --git a/dev-python/httpbin/httpbin-0.10.1-r3.ebuild b/dev-python/httpbin/httpbin-0.10.1-r4.ebuild index 5d029ef8a9f6..d34c543e7976 100644 --- a/dev-python/httpbin/httpbin-0.10.1-r3.ebuild +++ b/dev-python/httpbin/httpbin-0.10.1-r4.ebuild @@ -1,4 +1,4 @@ -# Copyright 1999-2023 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 @@ -6,7 +6,7 @@ EAPI=8 DISTUTILS_USE_PEP517=setuptools PYTHON_COMPAT=( python3_{10..12} pypy3 ) -inherit distutils-r1 pypi +inherit distutils-r1 optfeature pypi DESCRIPTION="HTTP Request and Response Service" HOMEPAGE=" @@ -17,16 +17,23 @@ HOMEPAGE=" LICENSE="|| ( MIT ISC )" SLOT="0" KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~loong ~mips ppc ppc64 ~riscv ~s390 sparc x86" +IUSE="test-rust" RDEPEND=" dev-python/brotlicffi[${PYTHON_USEDEP}] dev-python/decorator[${PYTHON_USEDEP}] - dev-python/flasgger[${PYTHON_USEDEP}] >=dev-python/flask-2.2.4[${PYTHON_USEDEP}] dev-python/itsdangerous[${PYTHON_USEDEP}] dev-python/markupsafe[${PYTHON_USEDEP}] dev-python/six[${PYTHON_USEDEP}] " +BDEPEND=" + test? ( + test-rust? ( + dev-python/flasgger[${PYTHON_USEDEP}] + ) + ) +" distutils_enable_tests pytest @@ -34,9 +41,15 @@ src_prepare() { local PATCHES=( # https://github.com/psf/httpbin/pull/29 "${FILESDIR}/${P}-werkzeug-3.patch" + # https://github.com/psf/httpbin/pull/44 (simplified) + "${FILESDIR}/${P}-optional-flasgger.patch" ) - # unpin greenlet - sed -i -e '/greenlet/d' pyproject.toml || die + # remove unnecessary deps + sed -i -e '/greenlet/d' -e '/flasgger/d' pyproject.toml || die distutils-r1_src_prepare } + +pkg_postinst() { + optfeature "Fancy index" dev-python/flasgger +} |