1{
2 lib,
3 python,
4 buildPythonPackage,
5 fetchFromGitHub,
6 fetchpatch,
7 libmilter,
8 bsddb3,
9 pydns,
10 iana-etc,
11 libredirect,
12 pyasyncore,
13}:
14
15buildPythonPackage rec {
16 pname = "pymilter";
17 version = "1.0.5";
18 format = "setuptools";
19
20 src = fetchFromGitHub {
21 owner = "sdgathman";
22 repo = pname;
23 rev = "${pname}-${version}";
24 hash = "sha256-gZUWEDVZfDRiOOdG3lpiQldHxm/93l8qYVOHOEpHhzQ=";
25 };
26
27 buildInputs = [ libmilter ];
28 nativeCheckInputs = [ pyasyncore ];
29 propagatedBuildInputs = [
30 bsddb3
31 pydns
32 ];
33 patches = [
34 (fetchpatch {
35 name = "Remove-calls-to-the-deprecated-method-assertEquals";
36 url = "https://github.com/sdgathman/pymilter/pull/57.patch";
37 hash = "sha256-/5LlDR15nMR3l7rkVjT3w4FbDTFAAgNdERWlPNL2TVg=";
38 })
39 ];
40
41 preBuild = ''
42 sed -i 's/import thread/import _thread as thread/' Milter/greylist.py
43 '';
44
45 # requires /etc/resolv.conf
46 # testpolicy: requires makemap (#100419)
47 # using exec -a makemap smtpctl results in "unknown group smtpq"
48 preCheck = ''
49 echo "nameserver 127.0.0.1" > resolv.conf
50 export NIX_REDIRECTS=/etc/protocols=${iana-etc}/etc/protocols:/etc/resolv.conf=$(realpath resolv.conf)
51 export LD_PRELOAD=${libredirect}/lib/libredirect.so
52 sed -i '/testpolicy/d' test.py
53 rm testpolicy.py
54 '';
55
56 pythonImportsCheck = [ "Milter" ];
57
58 meta = with lib; {
59 homepage = "http://bmsi.com/python/milter.html";
60 description = "Python bindings for libmilter api";
61 maintainers = with maintainers; [ yorickvp ];
62 license = licenses.gpl2;
63 };
64}