Gentoo Archives: gentoo-commits

From: Andrew Ammerlaan <andrewammerlaan@××××××.net>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/guru:master commit in: dev-python/hunter/
Date: Sun, 29 Mar 2020 13:21:36
Message-Id: 1585474143.853d6212365a0203373062f8b7e97290e551fa15.andrewammerlaan@gentoo
1 commit: 853d6212365a0203373062f8b7e97290e551fa15
2 Author: Alessandro Barbieri <lssndrbarbieri <AT> gmail <DOT> com>
3 AuthorDate: Sun Mar 29 09:19:07 2020 +0000
4 Commit: Andrew Ammerlaan <andrewammerlaan <AT> riseup <DOT> net>
5 CommitDate: Sun Mar 29 09:29:03 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=853d6212
7
8 dev-python/hunter: new package
9
10 Package-Manager: Portage-2.3.96, Repoman-2.3.22
11 Signed-off-by: Alessandro Barbieri <lssndrbarbieri <AT> gmail.com>
12
13 dev-python/hunter/Manifest | 1 +
14 dev-python/hunter/hunter-3.1.3.ebuild | 40 +++++++++++++++++++
15 dev-python/hunter/metadata.xml | 73 +++++++++++++++++++++++++++++++++++
16 3 files changed, 114 insertions(+)
17
18 diff --git a/dev-python/hunter/Manifest b/dev-python/hunter/Manifest
19 new file mode 100644
20 index 0000000..18d2364
21 --- /dev/null
22 +++ b/dev-python/hunter/Manifest
23 @@ -0,0 +1 @@
24 +DIST hunter-3.1.3.tar.gz 422149 BLAKE2B 2834b3daa6be461b78d468aa331a587a476b7109f5ff9c70b27bb51b26f6a390d2074425f4d98ddc692d4e11f1ee14a77f5066650e82687ebaa586051afab4c8 SHA512 ea9cc935240526d2942568073cecfb2bef32d7caedd0b370850b208a56c652bf356ba0e5675281946419aafd966cbff148490f6f4439d0d808335a3e831adbf7
25
26 diff --git a/dev-python/hunter/hunter-3.1.3.ebuild b/dev-python/hunter/hunter-3.1.3.ebuild
27 new file mode 100644
28 index 0000000..ed9012f
29 --- /dev/null
30 +++ b/dev-python/hunter/hunter-3.1.3.ebuild
31 @@ -0,0 +1,40 @@
32 +# Copyright 1999-2020 Gentoo Authors
33 +# Distributed under the terms of the GNU General Public License v2
34 +
35 +EAPI=7
36 +
37 +PYTHON_COMPAT=( python3_6 )
38 +
39 +inherit distutils-r1
40 +
41 +DESCRIPTION="Hunter is a flexible code tracing toolkit"
42 +HOMEPAGE="
43 + https://github.com/ionelmc/python-hunter
44 + https://pypi.org/project/hunter
45 +"
46 +SRC_URI="https://github.com/ionelmc/python-${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
47 +
48 +LICENSE="BSD-2"
49 +SLOT="0"
50 +KEYWORDS="~amd64 ~x86"
51 +
52 +RDEPEND="
53 + dev-python/colorama[${PYTHON_USEDEP}]
54 +"
55 +DEPEND="
56 + ${RDEPEND}
57 + test? (
58 + dev-python/aspectlib[${PYTHON_USEDEP}]
59 + dev-python/manhole[${PYTHON_USEDEP}]
60 + dev-python/process-tests[${PYTHON_USEDEP}]
61 + dev-python/pytest-benchmark[${PYTHON_USEDEP}]
62 + dev-python/pytest-travis-fold[${PYTHON_USEDEP}]
63 + )
64 +"
65 +BDEPEND="
66 + dev-python/cython[${PYTHON_USEDEP}]
67 + >=dev-python/setuptools_scm-3.3.1[${PYTHON_USEDEP}]
68 +"
69 +
70 +distutils_enable_tests pytest
71 +distutils_enable_sphinx docs ">=dev-python/sphinx-py3doc-enhanced-theme-2.3.2"
72
73 diff --git a/dev-python/hunter/metadata.xml b/dev-python/hunter/metadata.xml
74 new file mode 100644
75 index 0000000..0fd2af6
76 --- /dev/null
77 +++ b/dev-python/hunter/metadata.xml
78 @@ -0,0 +1,73 @@
79 +<?xml version="1.0" encoding="UTF-8"?>
80 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
81 +
82 +<pkgmetadata>
83 + <maintainer type="person">
84 + <email>lssndrbarbieri@×××××.com</email>
85 + <name>Alessandro Barbieri</name>
86 + </maintainer>
87 + <longdescription>
88 +Hunter is a flexible code tracing toolkit, not for measuring coverage, but for debugging, logging, inspection and other nefarious purposes. It has a simple Python API, a convenient terminal API and a CLI tool to attach to processes.
89 +Design notes
90 +
91 +Hunter doesn't do everything. As a design goal of this library some things are made intentionally austere and verbose (to avoid complexity, confusion and inconsistency). This has few consequences:
92 +
93 + There are Operators but there's no negation operator. Instead you're expected to negate a Query object, eg: ~Q(module='re').
94 + There are no specialized operators or filters - all filters behave exactly the same. For example:
95 + No filter for packages. You're expected to filter by module with an operator.
96 + No filter for arguments, return values or variables. You're expected to write your own filter function and deal with the problems of poking into objects.
97 + Layering is minimal. There's are some helpers that do some argument processing and conversions to save you some typing but that's about it.
98 + The library doesn't try to hide the mechanics of tracing in Python - it's 1:1 regarding what Python sends to a trace function if you'd be using sys.settrace.
99 + Doesn't have any storage. You are expected to redirect output to a file.
100 +
101 +You should look at it like it's a tool to help you understand and debug big applications, or a framework ridding you of the boring parts of settrace, not something that helps you learn Python.
102 +FAQ
103 +Why not Smiley?
104 +
105 +There's some obvious overlap with smiley but there are few fundamental differences:
106 +
107 + Complexity. Smiley is simply over-engineered:
108 + It uses IPC and a SQL database.
109 + It has a webserver. Lots of dependencies.
110 + It uses threads. Side-effects and subtle bugs are introduced in your code.
111 + It records everything. Tries to dump any variable. Often fails and stops working.
112 +
113 + Why do you need all that just to debug some stuff in a terminal? Simply put, it's a nice idea but the design choices work against you when you're already neck-deep into debugging your own code. In my experience Smiley has been very buggy and unreliable. Your mileage may vary of course.
114 +
115 + Tracing long running code. This will make Smiley record lots of data, making it unusable.
116 +
117 + Now because Smiley records everything, you'd think it's better suited for short programs. But alas, if your program runs quickly then it's pointless to record the execution. You can just run it again.
118 +
119 + It seems there's only one situation where it's reasonable to use Smiley: tracing io-bound apps remotely. Those apps don't execute lots of code, they just wait on network so Smiley's storage won't blow out of proportion and tracing overhead might be acceptable.
120 +
121 + Use-cases. It seems to me Smiley's purpose is not really debugging code, but more of a "non interactive monitoring" tool.
122 +
123 +In contrast, Hunter is very simple:
124 +
125 + Few dependencies.
126 +
127 + Low overhead (tracing/filtering code has an optional Cython extension).
128 +
129 + No storage. This simplifies lots of things.
130 +
131 + The only cost is that you might need to run the code multiple times to get the filtering/actions right. This means Hunter is not really suited for "post-mortem" debugging. If you can't reproduce the problem anymore then Hunter won't be of much help.
132 +
133 +Why not pytrace?
134 +
135 +Pytrace is another tracer tool. It seems quite similar to Smiley - it uses a sqlite database for the events, threads and IPC, thus it's reasonable to expect the same kind of problems.
136 +Why not PySnooper or snoop?
137 +
138 +snoop is a refined version of PySnooper. Both are more suited to tracing small programs or functions as the output is more verbose and less suited to the needs of tracing a big application where Hunter provides more flexible setup, filtering capabilities, speed and brevity.
139 +Why not coverage?
140 +
141 +For purposes of debugging coverage is a great tool but only as far as "debugging by looking at what code is (not) run". Checking branch coverage is good but it will only get you as far.
142 +
143 +From the other perspective, you'd be wondering if you could use Hunter to measure coverage-like things. You could do it but for that purpose Hunter is very "rough": it has no builtin storage. You'd have to implement your own storage. You can do it but it wouldn't give you any advantage over making your own tracer if you don't need to "pre-filter" whatever you're recording.
144 +
145 +In other words, filtering events is the main selling point of Hunter - it's fast (cython implementation) and the query API is flexible enough.
146 + </longdescription>
147 + <upstream>
148 + <remote-id type="github">python-hyper/hyper-h2</remote-id>
149 + <remote-id type="pypi">h2</remote-id>
150 + </upstream>
151 +</pkgmetadata>