1{ lib, buildPythonPackage, python, pythonOlder, glibcLocales, fetchFromGitHub, ipaddress, six, simplejson }:
2
3buildPythonPackage rec {
4 pname = "mail-parser";
5 version = "3.12.0";
6
7 # no tests in PyPI tarball
8 src = fetchFromGitHub {
9 owner = "SpamScope";
10 repo = pname;
11 rev = "v${version}";
12 sha256 = "0p851jlly6bzcs70kd1lcjwmg4scwh1icymfc0f2y6rkh4kfsdhk";
13 };
14
15 LC_ALL = "en_US.utf-8";
16
17 # remove version bounds
18 prePatch = ''
19 sed -i -e 's/==.*//g' requirements.txt
20 ''
21 # ipaddress is part of the standard library of Python 3.3+
22 + lib.optionalString (!pythonOlder "3.3") ''
23 substituteInPlace requirements.txt \
24 --replace "ipaddress" ""
25 '';
26
27 nativeBuildInputs = [ glibcLocales ];
28 propagatedBuildInputs = [ simplejson six ] ++ lib.optional (pythonOlder "3.3") ipaddress;
29
30 # Taken from .travis.yml
31 checkPhase = ''
32 ${python.interpreter} tests/test_main.py
33 ${python.interpreter} -m mailparser -v
34 ${python.interpreter} -m mailparser -h
35 ${python.interpreter} -m mailparser -f tests/mails/mail_malformed_3 -j
36 cat tests/mails/mail_malformed_3 | ${python.interpreter} -m mailparser -k -j
37 '';
38
39 meta = with lib; {
40 description = "A mail parser for python 2 and 3";
41 homepage = "https://github.com/SpamScope/mail-parser";
42 license = licenses.asl20;
43 maintainers = with maintainers; [ psyanticy ];
44 };
45}