1{
2 lib,
3 pkgs,
4 buildPythonPackage,
5 fetchFromGitHub,
6 pythonOlder,
7 redis,
8 unittestCheckHook,
9 fetchpatch,
10}:
11
12buildPythonPackage rec {
13 pname = "walrus";
14 version = "0.9.3";
15 format = "setuptools";
16
17 disabled = pythonOlder "3.7";
18
19 src = fetchFromGitHub {
20 owner = "coleifer";
21 repo = "walrus";
22 rev = "refs/tags/${version}";
23 hash = "sha256-jinYMGSBAY8HTg92qU/iU5vGIrrDr5SeQG0XjsBVfcc=";
24 };
25
26 patches = [
27 # distutils has been deprecated, this wraps its import inside a try-catch
28 # and fallsback to a fallback import.
29 # Should not be necessary in future versions.
30 (fetchpatch {
31 url = "https://github.com/coleifer/walrus/commit/79e20c89aa4015017ef8a3e0b5c27ca2731dc9b2.patch";
32 hash = "sha256-hCpvki6SV3KYhicjjUMP4VrKMEerMjq2n1BgozXKDO8=";
33 })
34 ];
35
36 propagatedBuildInputs = [ redis ];
37
38 nativeCheckInputs = [ unittestCheckHook ];
39
40 preCheck = ''
41 ${pkgs.redis}/bin/redis-server &
42 REDIS_PID=$!
43 '';
44
45 postCheck = ''
46 kill $REDIS_PID
47 '';
48
49 pythonImportsCheck = [ "walrus" ];
50
51 __darwinAllowLocalNetworking = true;
52
53 meta = with lib; {
54 description = "Lightweight Python utilities for working with Redis";
55 homepage = "https://github.com/coleifer/walrus";
56 changelog = "https://github.com/coleifer/walrus/blob/${version}/CHANGELOG.md";
57 license = licenses.mit;
58 maintainers = with maintainers; [ mbalatsko ];
59 };
60}