1 |
commit: 4d3fe7a396ce39cfe22c324b03d4b48fd359da77 |
2 |
Author: Michael Orlitzky <mjo <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Mar 18 15:13:33 2018 +0000 |
4 |
Commit: Michael Orlitzky <mjo <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Mar 23 23:34:26 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4d3fe7a3 |
7 |
|
8 |
dev-python/pyzor: new revision to fix some open bugs. |
9 |
|
10 |
Lots of changes all at once: |
11 |
|
12 |
* Update to EAPI=6. |
13 |
* Remove an old pkg_postinst() notice about a relocated executable. |
14 |
* Add IUSE=gdbm to make the gdbm daemon backend optional. |
15 |
* Only require a (gdbm, mysql, redis) backend with USE=pyzord. |
16 |
* Add a patch submitted upstream (by me) to fix a unicode crash. |
17 |
* Require sphinx with USE=doc (bug 636752). |
18 |
* Remove version constraints on redis-py and gevent (bug 643692). |
19 |
* Use HOMEPAGE to make SRC_URI fit on one line. |
20 |
* Add die() to "mv" and "rm" commands in src_install. |
21 |
* Removed seemingly-unnecessary DISTUTILS_IN_SOURCE_BUILD=1. |
22 |
* Added myself to metadata.xml as a maintainer. |
23 |
* Improved the back-end database engine USE flag descriptions. |
24 |
|
25 |
Bug: https://bugs.gentoo.org/636752 |
26 |
Bug: https://bugs.gentoo.org/643692 |
27 |
Package-Manager: Portage-2.3.19, Repoman-2.3.6 |
28 |
|
29 |
.../read-stdin-as-binary-in-get_input_msg.patch | 45 ++++++++++++++ |
30 |
dev-python/pyzor/metadata.xml | 22 +++++-- |
31 |
dev-python/pyzor/pyzor-1.0.0-r1.ebuild | 70 ++++++++++++++++++++++ |
32 |
3 files changed, 133 insertions(+), 4 deletions(-) |
33 |
|
34 |
diff --git a/dev-python/pyzor/files/read-stdin-as-binary-in-get_input_msg.patch b/dev-python/pyzor/files/read-stdin-as-binary-in-get_input_msg.patch |
35 |
new file mode 100644 |
36 |
index 00000000000..81668e36937 |
37 |
--- /dev/null |
38 |
+++ b/dev-python/pyzor/files/read-stdin-as-binary-in-get_input_msg.patch |
39 |
@@ -0,0 +1,45 @@ |
40 |
+From 6332a429ed415187599ecce7d8a169ee19f0bbe5 Mon Sep 17 00:00:00 2001 |
41 |
+From: Michael Orlitzky <michael@××××××××.com> |
42 |
+Date: Sun, 4 Mar 2018 17:34:33 -0500 |
43 |
+Subject: [PATCH 1/1] scripts/pyzor: read stdin as binary in _get_input_msg(). |
44 |
+ |
45 |
+Reading stdin in python-3.x is done as text, with a best-guess |
46 |
+encoding. But this can go awry: for example, if an iso-8859-1 message |
47 |
+is passed in and if python guesses the "utf-8" encoding, then read() |
48 |
+will fail with a UnicodeDecodeError on non-ASCII characters. For |
49 |
+example, the "copyright" symbol is a single byte 0xa9 in iso-8859-1, |
50 |
+and the utf-8 decoder can't handle it: |
51 |
+ |
52 |
+ UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa9... invalid |
53 |
+ start byte |
54 |
+ |
55 |
+Instead -- and as was done in python-2.x -- we can read stdin as |
56 |
+binary using the new get_binary_stdin() function. Afterwards, we use |
57 |
+email.message_from_bytes() instead of the email.message_from_file() |
58 |
+constructor to parse the byte data. The resulting function is able to |
59 |
+correctly parse these messages. |
60 |
+ |
61 |
+Closes: https://github.com/SpamExperts/pyzor/issues/64 |
62 |
+--- |
63 |
+ scripts/pyzor | 5 ++++- |
64 |
+ 1 file changed, 4 insertions(+), 1 deletion(-) |
65 |
+ |
66 |
+diff --git a/scripts/pyzor b/scripts/pyzor |
67 |
+index 567a7f9..1ba632f 100755 |
68 |
+--- a/scripts/pyzor |
69 |
++++ b/scripts/pyzor |
70 |
+@@ -171,7 +171,10 @@ def _get_input_digests(dummy): |
71 |
+ |
72 |
+ |
73 |
+ def _get_input_msg(digester): |
74 |
+- msg = email.message_from_file(sys.stdin) |
75 |
++ # Read and process stdin as bytes because we don't know its |
76 |
++ # encoding. Python-3.x will try to guess -- and can sometimes |
77 |
++ # guess wrong -- leading to decoding errors in read(). |
78 |
++ msg = email.message_from_bytes(get_binary_stdin().read()) |
79 |
+ digested = digester(msg).value |
80 |
+ yield digested |
81 |
+ |
82 |
+-- |
83 |
+2.13.6 |
84 |
+ |
85 |
|
86 |
diff --git a/dev-python/pyzor/metadata.xml b/dev-python/pyzor/metadata.xml |
87 |
index 601b2a90164..d88c249a89f 100644 |
88 |
--- a/dev-python/pyzor/metadata.xml |
89 |
+++ b/dev-python/pyzor/metadata.xml |
90 |
@@ -1,15 +1,29 @@ |
91 |
<?xml version="1.0" encoding="UTF-8"?> |
92 |
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> |
93 |
<pkgmetadata> |
94 |
+ <maintainer type="person"> |
95 |
+ <email>mjo@g.o</email> |
96 |
+ </maintainer> |
97 |
<maintainer type="project"> |
98 |
<email>python@g.o</email> |
99 |
<name>Python</name> |
100 |
</maintainer> |
101 |
<use> |
102 |
- <flag name="pyzord">enable support for pyzord</flag> |
103 |
- <flag name="mysql">Enables mysql support</flag> |
104 |
- <flag name="redis">Enables redis support</flag> |
105 |
- <flag name="gevent">Enable support for the gevent based handler</flag> |
106 |
+ <flag name="pyzord">Enable the pyzord server daemon</flag> |
107 |
+ <flag name="gdbm"> |
108 |
+ Enables the Gdbm back-end database engine for pyzord |
109 |
+ </flag> |
110 |
+ <flag name="mysql"> |
111 |
+ Enables the MySQL back-end database engine for pyzord through |
112 |
+ <pkg>dev-python/mysql-python</pkg>. Only works with python-2.x! |
113 |
+ </flag> |
114 |
+ <flag name="redis"> |
115 |
+ Enables the redis back-end database engine for pyzord through |
116 |
+ <pkg>dev-python/redis-py</pkg> |
117 |
+ </flag> |
118 |
+ <flag name="gevent"> |
119 |
+ Use <pkg>dev-python/gevent</pkg> to enable asynchronous operation |
120 |
+ </flag> |
121 |
</use> |
122 |
<upstream> |
123 |
<remote-id type="github">SpamExperts/pyzor</remote-id> |
124 |
|
125 |
diff --git a/dev-python/pyzor/pyzor-1.0.0-r1.ebuild b/dev-python/pyzor/pyzor-1.0.0-r1.ebuild |
126 |
new file mode 100644 |
127 |
index 00000000000..14e1ee84072 |
128 |
--- /dev/null |
129 |
+++ b/dev-python/pyzor/pyzor-1.0.0-r1.ebuild |
130 |
@@ -0,0 +1,70 @@ |
131 |
+# Copyright 1999-2018 Gentoo Foundation |
132 |
+# Distributed under the terms of the GNU General Public License v2 |
133 |
+ |
134 |
+EAPI=6 |
135 |
+PYTHON_COMPAT=( python{2_7,3_4,3_5} ) |
136 |
+ |
137 |
+inherit distutils-r1 |
138 |
+ |
139 |
+MY_PV="1-0-0" |
140 |
+DESCRIPTION="A distributed, collaborative spam detection and filtering network" |
141 |
+HOMEPAGE="https://github.com/SpamExperts/pyzor" |
142 |
+SRC_URI="${HOMEPAGE}/archive/release-${MY_PV}.tar.gz -> ${P}.tar.gz" |
143 |
+ |
144 |
+LICENSE="GPL-2" |
145 |
+SLOT="0" |
146 |
+KEYWORDS="~alpha ~amd64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~amd64-linux ~x86-linux" |
147 |
+ |
148 |
+IUSE="doc gdbm gevent mysql pyzord redis test" |
149 |
+ |
150 |
+# The mysql-python library is always required for the MySQL engine. We |
151 |
+# depend on it conditionally here because otherwise repoman will balk at |
152 |
+# the potential conflict between PYTHON_TARGETS and USE=mysql. But as a |
153 |
+# result, if you try to use the MySQL engine with python-3.x, it just |
154 |
+# won't work because you'll be missing the library. |
155 |
+RDEPEND="pyzord? ( |
156 |
+ gdbm? ( $(python_gen_impl_dep 'gdbm') ) |
157 |
+ mysql? ( $(python_gen_cond_dep \ |
158 |
+ 'dev-python/mysql-python[${PYTHON_USEDEP}]' python2_7) ) |
159 |
+ redis? ( dev-python/redis-py[${PYTHON_USEDEP}] ) |
160 |
+ gevent? ( dev-python/gevent[${PYTHON_USEDEP}] ) |
161 |
+)" |
162 |
+DEPEND="dev-python/setuptools[${PYTHON_USEDEP}] |
163 |
+ doc? ( dev-python/sphinx[${PYTHON_USEDEP}] ) |
164 |
+ test? ( ${RDEPEND} )" |
165 |
+ |
166 |
+# TODO: maybe upstream would support skipping tests for which the |
167 |
+# dependencies are missing? |
168 |
+REQUIRED_USE="pyzord? ( || ( gdbm mysql redis ) ) |
169 |
+ test? ( gdbm mysql redis )" |
170 |
+S="${WORKDIR}/${PN}-release-${MY_PV}" |
171 |
+ |
172 |
+PATCHES=( "${FILESDIR}/read-stdin-as-binary-in-get_input_msg.patch" ) |
173 |
+ |
174 |
+python_test() { |
175 |
+ # The suite is py2 friendly only |
176 |
+ if ! python_is_python3; then |
177 |
+ PYTHONPATH=. "${PYTHON}" ./tests/unit/__init__.py |
178 |
+ fi |
179 |
+} |
180 |
+ |
181 |
+python_compile_all() { |
182 |
+ use doc && emake -C docs html |
183 |
+} |
184 |
+ |
185 |
+python_install_all() { |
186 |
+ use doc && HTML_DOCS=( docs/.build/html/. ) |
187 |
+ distutils-r1_python_install_all |
188 |
+} |
189 |
+ |
190 |
+src_install () { |
191 |
+ distutils-r1_src_install |
192 |
+ |
193 |
+ if use pyzord; then |
194 |
+ dodir /usr/sbin |
195 |
+ mv "${D}"usr/bin/pyzord* "${ED}usr/sbin" \ |
196 |
+ || die "failed to relocate pyzord" |
197 |
+ else |
198 |
+ rm "${D}"usr/bin/pyzord* || die "failed to remove pyzord" |
199 |
+ fi |
200 |
+} |