1 |
commit: 09eaf73828ac4bc0794332448c2dd6144fb429e6 |
2 |
Author: Louis Sautier <sbraz <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Sep 17 18:52:41 2020 +0000 |
4 |
Commit: Louis Sautier <sbraz <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Sep 17 19:05:24 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=09eaf738 |
7 |
|
8 |
dev-python/tempita: add python 3.9 support by removing cgi.escape |
9 |
|
10 |
Package-Manager: Portage-3.0.7, Repoman-3.0.1 |
11 |
Signed-off-by: Louis Sautier <sbraz <AT> gentoo.org> |
12 |
|
13 |
.../tempita/files/tempita-0.5.3-cgi-escape.patch | 31 +++++++++++++ |
14 |
dev-python/tempita/tempita-0.5.3-r3.ebuild | 52 ++++++++++++++++++++++ |
15 |
2 files changed, 83 insertions(+) |
16 |
|
17 |
diff --git a/dev-python/tempita/files/tempita-0.5.3-cgi-escape.patch b/dev-python/tempita/files/tempita-0.5.3-cgi-escape.patch |
18 |
new file mode 100644 |
19 |
index 00000000000..d411d28ced4 |
20 |
--- /dev/null |
21 |
+++ b/dev-python/tempita/files/tempita-0.5.3-cgi-escape.patch |
22 |
@@ -0,0 +1,31 @@ |
23 |
+diff --git a/tempita/__init__.py b/tempita/__init__.py |
24 |
+index 137ba2d..acc2fd9 100755 |
25 |
+--- a/tempita/__init__.py |
26 |
++++ b/tempita/__init__.py |
27 |
+@@ -31,12 +31,12 @@ can use ``__name='tmpl.html'`` to set the name of the template. |
28 |
+ If there are syntax errors ``TemplateError`` will be raised. |
29 |
+ """ |
30 |
+ |
31 |
+-import cgi |
32 |
+ import os |
33 |
+ import re |
34 |
+ import sys |
35 |
+ import tokenize |
36 |
+ from cStringIO import StringIO |
37 |
++from html import escape |
38 |
+ from urllib import quote as url_quote |
39 |
+ from tempita._looper import looper |
40 |
+ from tempita.compat3 import bytes, basestring_, next, is_unicode, coerce_text |
41 |
+@@ -445,10 +445,10 @@ def html_quote(value, force=True): |
42 |
+ if not isinstance(value, basestring_): |
43 |
+ value = coerce_text(value) |
44 |
+ if sys.version >= "3" and isinstance(value, bytes): |
45 |
+- value = cgi.escape(value.decode('latin1'), 1) |
46 |
++ value = escape(value.decode('latin1'), 1) |
47 |
+ value = value.encode('latin1') |
48 |
+ else: |
49 |
+- value = cgi.escape(value, 1) |
50 |
++ value = escape(value, 1) |
51 |
+ if sys.version < "3": |
52 |
+ if is_unicode(value): |
53 |
+ value = value.encode('ascii', 'xmlcharrefreplace') |
54 |
|
55 |
diff --git a/dev-python/tempita/tempita-0.5.3-r3.ebuild b/dev-python/tempita/tempita-0.5.3-r3.ebuild |
56 |
new file mode 100644 |
57 |
index 00000000000..d455c913ca0 |
58 |
--- /dev/null |
59 |
+++ b/dev-python/tempita/tempita-0.5.3-r3.ebuild |
60 |
@@ -0,0 +1,52 @@ |
61 |
+# Copyright 1999-2020 Gentoo Authors |
62 |
+# Distributed under the terms of the GNU General Public License v2 |
63 |
+ |
64 |
+EAPI=7 |
65 |
+ |
66 |
+PYTHON_COMPAT=( pypy3 python3_{6,7,8,9} ) |
67 |
+# The package uses pkg_resources |
68 |
+DISTUTILS_USE_SETUPTOOLS=manual |
69 |
+ |
70 |
+inherit distutils-r1 |
71 |
+ |
72 |
+MY_COMMIT="97392d008cc8" |
73 |
+ |
74 |
+DESCRIPTION="A very small text templating language" |
75 |
+HOMEPAGE="https://pypi.org/project/Tempita/" |
76 |
+# Tests are not published on PyPI |
77 |
+SRC_URI="https://bitbucket.org/ianb/${PN}/get/${MY_COMMIT}.tar.gz -> ${P}-bitbucket.tar.gz" |
78 |
+S="${WORKDIR}/ianb-${PN}-${MY_COMMIT}" |
79 |
+ |
80 |
+LICENSE="MIT" |
81 |
+SLOT="0" |
82 |
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux" |
83 |
+IUSE="test" |
84 |
+RESTRICT="!test? ( test )" |
85 |
+ |
86 |
+RDEPEND="dev-python/setuptools[${PYTHON_USEDEP}]" |
87 |
+BDEPEND=" |
88 |
+ dev-python/setuptools[${PYTHON_USEDEP}] |
89 |
+ test? ( dev-python/pytest[${PYTHON_USEDEP}] ) |
90 |
+" |
91 |
+ |
92 |
+PATCHES=( |
93 |
+ "${FILESDIR}/${P}-pypy-tests.patch" |
94 |
+ # cgi.escape has been removed in Python 3.9 |
95 |
+ "${FILESDIR}/${P}-cgi-escape.patch" |
96 |
+) |
97 |
+ |
98 |
+distutils_enable_sphinx docs |
99 |
+ |
100 |
+python_prepare_all() { |
101 |
+ # Remove reference to a non-existent CSS file |
102 |
+ # in order to make sphinx use its default theme. |
103 |
+ sed -i '/^html_style =/d' docs/conf.py || die |
104 |
+ distutils-r1_python_prepare_all |
105 |
+} |
106 |
+ |
107 |
+python_test() { |
108 |
+ # We need to append to sys.path, otherwise pytest imports |
109 |
+ # the module from ${S} (before it was 2to3'd) |
110 |
+ pytest --import-mode=append -vv tests/test_template.txt docs/index.txt \ |
111 |
+ || die "Tests failed with ${EPYTHON}" |
112 |
+} |