diff options
Diffstat (limited to 'dev-python/flask-api')
-rw-r--r-- | dev-python/flask-api/Manifest | 2 | ||||
-rw-r--r-- | dev-python/flask-api/files/flask-api-3.1-flask-3.patch | 84 | ||||
-rw-r--r-- | dev-python/flask-api/flask-api-3.0.ebuild | 29 | ||||
-rw-r--r-- | dev-python/flask-api/flask-api-3.1-r2.ebuild | 42 |
4 files changed, 127 insertions, 30 deletions
diff --git a/dev-python/flask-api/Manifest b/dev-python/flask-api/Manifest index d0febe800a5f..a70221b4ff20 100644 --- a/dev-python/flask-api/Manifest +++ b/dev-python/flask-api/Manifest @@ -1 +1 @@ -DIST flask-api-3.0.tar.gz 249620 BLAKE2B 63ce0ce6a2d4755caf40c020fc6b88f3b585b0c30f5800df62c8e442f629b8b489917ff0f0d1266d941478336f38aa0560c144620f6c11d60cbd9e31870bf984 SHA512 c86b919f8681a73be166ddc50022faecb376b1b6f99bd0d78b2f2fc8b64f82bf82779dbdcfbcaa1c5e321ea2d286b95f1a1aab32864e6c3923417d7828c7c79a +DIST flask-api-3.1.gh.tar.gz 258812 BLAKE2B f62fb820a467575738deda299de33b87efc066dcc468adad28309cd848f6710a91187a599aba05981457fa8bd8c598ba3014639d7b5d3869434eea32a513a08e SHA512 158692b5d90f3c66231e26ee98df0496973a0fd1d9433041c0c19ff9255601af22cac7968273d2b27fc656f48dcf5e600e6eb939c7ed87f1af222d6fc47fc1ba diff --git a/dev-python/flask-api/files/flask-api-3.1-flask-3.patch b/dev-python/flask-api/files/flask-api-3.1-flask-3.patch new file mode 100644 index 000000000000..92eddb8d8df0 --- /dev/null +++ b/dev-python/flask-api/files/flask-api-3.1-flask-3.patch @@ -0,0 +1,84 @@ +From 9c998897f67d8aa959dc3005d7d22f36568b6938 Mon Sep 17 00:00:00 2001 +From: Arthur Taylor <arthur@codders.de> +Date: Sat, 21 Oct 2023 09:53:02 +0200 +Subject: [PATCH] Add compatibility code to deal with Flask and Werkzeug + deprecations + +--- + flask_api/helpers.py | 5 +++++ + flask_api/parsers.py | 2 +- + flask_api/renderers.py | 11 +++++++++-- + flask_api/request.py | 2 +- + 4 files changed, 16 insertions(+), 4 deletions(-) + create mode 100644 flask_api/helpers.py + +diff --git a/flask_api/helpers.py b/flask_api/helpers.py +new file mode 100644 +index 0000000..f83dd31 +--- /dev/null ++++ b/flask_api/helpers.py +@@ -0,0 +1,5 @@ ++def url_decode_stream(stream): ++ import urllib ++ body = stream.read() ++ body_str = body.decode() ++ return dict(urllib.parse.parse_qsl(body_str)) +diff --git a/flask_api/parsers.py b/flask_api/parsers.py +index 56f45f6..d056210 100644 +--- a/flask_api/parsers.py ++++ b/flask_api/parsers.py +@@ -2,8 +2,8 @@ + + from werkzeug.formparser import MultiPartParser as WerkzeugMultiPartParser + from werkzeug.formparser import default_stream_factory +-from werkzeug.urls import url_decode_stream + ++from flask_api.helpers import url_decode_stream + from flask_api import exceptions + + +diff --git a/flask_api/renderers.py b/flask_api/renderers.py +index a9aed23..b5951a2 100644 +--- a/flask_api/renderers.py ++++ b/flask_api/renderers.py +@@ -1,8 +1,8 @@ + import pydoc + import re + ++import flask + from flask import current_app, render_template, request +-from flask.globals import _request_ctx_stack + + from flask_api.compat import apply_markdown + from flask_api.mediatypes import MediaType +@@ -95,7 +95,14 @@ def render(self, data, media_type, **options): + mock_content = self._html_escape(text) + + # Determine the allowed methods on this view. +- adapter = _request_ctx_stack.top.url_adapter ++ if hasattr(flask, 'globals') and \ ++ hasattr(flask.globals, 'request_ctx'): ++ # update session for Flask >= 2.2 ++ ctx = flask.globals.request_ctx._get_current_object() ++ else: # pragma: no cover ++ # update session for Flask < 2.2 ++ ctx = flask._request_ctx_stack.top ++ adapter = ctx.url_adapter + allowed_methods = adapter.allowed_methods() + + endpoint = request.url_rule.endpoint +diff --git a/flask_api/request.py b/flask_api/request.py +index 33c3eaa..647dfc6 100644 +--- a/flask_api/request.py ++++ b/flask_api/request.py +@@ -2,9 +2,9 @@ + + from flask import Request + from werkzeug.datastructures import MultiDict +-from werkzeug.urls import url_decode_stream + from werkzeug.wsgi import get_content_length + ++from flask_api.helpers import url_decode_stream + from flask_api.negotiation import DefaultNegotiation + from flask_api.settings import default_settings + diff --git a/dev-python/flask-api/flask-api-3.0.ebuild b/dev-python/flask-api/flask-api-3.0.ebuild deleted file mode 100644 index 0d56985e7d61..000000000000 --- a/dev-python/flask-api/flask-api-3.0.ebuild +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=7 - -PYTHON_COMPAT=( pypy3 python3_{8..10} ) - -inherit distutils-r1 - -DESCRIPTION="Browsable web APIs for Flask" -HOMEPAGE="https://www.flaskapi.org/" -# pypi mirror don't have docs folder -SRC_URI="https://github.com/flask-api/flask-api/archive/v${PV}.tar.gz -> ${P}.tar.gz" - -LICENSE="BSD-2" -SLOT="0" -KEYWORDS="~amd64 ~x86" - -RDEPEND=" - dev-python/flask[${PYTHON_USEDEP}] - dev-python/markdown[${PYTHON_USEDEP}] -" - -distutils_enable_tests pytest - -python_install_all() { - local DOCS=( docs/about/release-notes.md docs/api-guide/* docs/index.md ) - distutils-r1_python_install_all -} diff --git a/dev-python/flask-api/flask-api-3.1-r2.ebuild b/dev-python/flask-api/flask-api-3.1-r2.ebuild new file mode 100644 index 000000000000..0f0ad223c49c --- /dev/null +++ b/dev-python/flask-api/flask-api-3.1-r2.ebuild @@ -0,0 +1,42 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +DISTUTILS_USE_PEP517=setuptools +PYTHON_COMPAT=( pypy3 python3_{10..12} ) + +inherit distutils-r1 + +DESCRIPTION="Browsable web APIs for Flask" +HOMEPAGE=" + https://github.com/flask-api/flask-api/ + https://pypi.org/project/Flask-API/ +" +# pypi mirror don't have docs folder +SRC_URI=" + https://github.com/flask-api/flask-api/archive/v${PV}.tar.gz + -> ${P}.gh.tar.gz +" + +LICENSE="BSD-2" +SLOT="0" +KEYWORDS="~amd64 ~arm64 ~x86" + +RDEPEND=" + dev-python/flask[${PYTHON_USEDEP}] + dev-python/markdown[${PYTHON_USEDEP}] + dev-python/werkzeug[${PYTHON_USEDEP}] +" + +distutils_enable_tests pytest + +PATCHES=( + # https://github.com/flask-api/flask-api/commit/9c998897f67d8aa959dc3005d7d22f36568b6938 + "${FILESDIR}/${P}-flask-3.patch" +) + +python_install_all() { + local DOCS=( docs/about/release-notes.md docs/api-guide/* docs/index.md ) + distutils-r1_python_install_all +} |