aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/development/python-modules/mail-parser/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'infra/libkookie/nixpkgs/pkgs/development/python-modules/mail-parser/default.nix')
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/python-modules/mail-parser/default.nix45
1 files changed, 45 insertions, 0 deletions
diff --git a/infra/libkookie/nixpkgs/pkgs/development/python-modules/mail-parser/default.nix b/infra/libkookie/nixpkgs/pkgs/development/python-modules/mail-parser/default.nix
new file mode 100644
index 000000000000..94b575f3f468
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/python-modules/mail-parser/default.nix
@@ -0,0 +1,45 @@
+{ lib, buildPythonPackage, python, pythonOlder, glibcLocales, fetchFromGitHub, ipaddress, six, simplejson }:
+
+buildPythonPackage rec {
+ pname = "mail-parser";
+ version = "3.12.0";
+
+ # no tests in PyPI tarball
+ src = fetchFromGitHub {
+ owner = "SpamScope";
+ repo = pname;
+ rev = "v${version}";
+ sha256 = "0p851jlly6bzcs70kd1lcjwmg4scwh1icymfc0f2y6rkh4kfsdhk";
+ };
+
+ LC_ALL = "en_US.utf-8";
+
+ # remove version bounds
+ prePatch = ''
+ sed -i -e 's/==.*//g' requirements.txt
+ ''
+ # ipaddress is part of the standard library of Python 3.3+
+ + lib.optionalString (!pythonOlder "3.3") ''
+ substituteInPlace requirements.txt \
+ --replace "ipaddress" ""
+ '';
+
+ nativeBuildInputs = [ glibcLocales ];
+ propagatedBuildInputs = [ simplejson six ] ++ lib.optional (pythonOlder "3.3") ipaddress;
+
+ # Taken from .travis.yml
+ checkPhase = ''
+ ${python.interpreter} tests/test_main.py
+ ${python.interpreter} -m mailparser -v
+ ${python.interpreter} -m mailparser -h
+ ${python.interpreter} -m mailparser -f tests/mails/mail_malformed_3 -j
+ cat tests/mails/mail_malformed_3 | ${python.interpreter} -m mailparser -k -j
+ '';
+
+ meta = with lib; {
+ description = "A mail parser for python 2 and 3";
+ homepage = "https://github.com/SpamScope/mail-parser";
+ license = licenses.asl20;
+ maintainers = with maintainers; [ psyanticy ];
+ };
+}