1{
2 lib,
3 stdenv,
4 bottle,
5 buildPythonPackage,
6 fetchpatch,
7 fetchPypi,
8 pytestCheckHook,
9 pythonAtLeast,
10}:
11
12buildPythonPackage rec {
13 pname = "pympler";
14 version = "1.0.1";
15
16 src = fetchPypi {
17 pname = "Pympler";
18 inherit version;
19 sha256 = "993f1a3599ca3f4fcd7160c7545ad06310c9e12f70174ae7ae8d4e25f6c5d3fa";
20 };
21
22 patches = [
23 # Fixes a TypeError on Python 3.11
24 # (see https://github.com/pympler/pympler/issues/148)
25 # https://github.com/pympler/pympler/pull/149
26 (fetchpatch {
27 name = "Pympler-python-3.11-compat.patch";
28 url = "https://github.com/pympler/pympler/commit/0fd8ad8da39207bd0dcb28bdac0407e04744c965.patch";
29 hash = "sha256-6MK0AuhVhQkUzlk29HUh1+mSbfsVTBJ1YBtYNIFhh7U=";
30 })
31 ];
32
33 nativeCheckInputs = [ pytestCheckHook ];
34
35 # There is a version of bottle bundled with Pympler, but it is broken on
36 # Python 3.11. Fortunately, Pympler will preferentially import an external
37 # bottle if it is available, so we make it an explicit dependency.
38 propagatedBuildInputs = [ bottle ];
39
40 disabledTests =
41 [
42 # 'AssertionError: 'function (test.muppy.test_summary.func)' != 'function (muppy.test_summary.func)'
43 # https://github.com/pympler/pympler/issues/134
44 "test_repr_function"
45 ]
46 ++ lib.optionals (pythonAtLeast "3.11") [
47 # https://github.com/pympler/pympler/issues/148
48 "test_findgarbage"
49 "test_get_tree"
50 "test_prune"
51 ];
52
53 doCheck = stdenv.hostPlatform.isLinux;
54
55 meta = with lib; {
56 description = "Tool to measure, monitor and analyze memory behavior";
57 homepage = "https://pythonhosted.org/Pympler/";
58 license = licenses.asl20;
59 };
60}