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