1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 pythonOlder,
6 fetchFromGitHub,
7 setuptools,
8 click,
9 watchdog,
10 portalocker,
11 pytestCheckHook,
12 pytest-cov-stub,
13 sqlalchemy,
14 pymongo,
15 dnspython,
16 pymongo-inmemory,
17 pandas,
18 birch,
19}:
20
21buildPythonPackage rec {
22 pname = "cachier";
23 version = "4.1.0";
24 pyproject = true;
25
26 disabled = pythonOlder "3.8";
27
28 src = fetchFromGitHub {
29 owner = "python-cachier";
30 repo = "cachier";
31 tag = "v${version}";
32 hash = "sha256-FmrwH5Ksmgt0HA5eUN5LU36P5sY4PymRKsUWVkQlvBo=";
33 };
34
35 pythonRemoveDeps = [ "setuptools" ];
36
37 nativeBuildInputs = [
38 setuptools
39 ];
40
41 dependencies = [
42 watchdog
43 portalocker
44 # not listed as dep, but needed to run main script entrypoint
45 click
46 ];
47
48 nativeCheckInputs = [
49 pytestCheckHook
50 pytest-cov-stub
51 sqlalchemy
52 pymongo
53 dnspython
54 pymongo-inmemory
55 pandas
56 birch
57 ];
58
59 disabledTests = [
60 # touches network
61 "test_mongetter_default_param"
62 "test_stale_after_applies_dynamically"
63 "test_next_time_applies_dynamically"
64 "test_wait_for_calc_"
65 "test_precache_value"
66 "test_ignore_self_in_methods"
67 "test_mongo_index_creation"
68 "test_mongo_core"
69
70 # don't test formatting
71 "test_flake8"
72
73 # slow, spawns 800+ threads
74 "test_inotify_instance_limit_reached"
75
76 # timing sensitive
77 "test_being_calc_next_time"
78 "test_pickle_being_calculated"
79 ]
80 ++ lib.optionals stdenv.hostPlatform.isDarwin [
81 # sensitive to host file system
82 # Unhandled exception in FSEventsEmitter - RuntimeError: Cannot add watch - it is already scheduled
83 "test_bad_cache_file"
84 "test_delete_cache_file"
85 ];
86
87 disabledTestPaths = [
88 # Keeps breaking due to concurrent access or failing to close the db between tests.
89 "tests/test_sql_core.py"
90 ];
91
92 preBuild = ''
93 export HOME="$(mktemp -d)"
94 '';
95
96 pythonImportsCheck = [ "cachier" ];
97
98 meta = {
99 homepage = "https://github.com/python-cachier/cachier";
100 changelog = "https://github.com/python-cachier/cachier/releases/tag/${src.tag}";
101 description = "Persistent, stale-free, local and cross-machine caching for functions";
102 mainProgram = "cachier";
103 maintainers = with lib.maintainers; [ pbsds ];
104 license = lib.licenses.mit;
105 };
106}