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