From 64cfeeffd04e969fc70ada6ee25c585159b0b7bc Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Mon, 18 Jan 2021 14:14:28 -0800 Subject: [PATCH] pythonPackages.xmlsec: init at 1.3.9 --- .../python-modules/xmlsec/default.nix | 47 +++++++++++++++++++ .../xmlsec/reset-lxml-in-tests.patch | 22 +++++++++ pkgs/top-level/python-packages.nix | 4 ++ 3 files changed, 73 insertions(+) create mode 100644 pkgs/development/python-modules/xmlsec/default.nix create mode 100644 pkgs/development/python-modules/xmlsec/reset-lxml-in-tests.patch diff --git a/pkgs/development/python-modules/xmlsec/default.nix b/pkgs/development/python-modules/xmlsec/default.nix new file mode 100644 index 000000000000..82f4a968ba6e --- /dev/null +++ b/pkgs/development/python-modules/xmlsec/default.nix @@ -0,0 +1,47 @@ +{ lib +, fetchPypi +, buildPythonPackage +, pytestCheckHook +, libxslt +, libxml2 +, libtool +, pkg-config +, xmlsec +, pkgconfig +, setuptools-scm +, toml +, lxml +, hypothesis +}: + +buildPythonPackage rec { + pname = "xmlsec"; + version = "1.3.9"; + + src = fetchPypi { + inherit pname version; + sha256 = "1c4k42zv3plm6v65p7z6l5rxyf50h40d02nhc16vq7cjrfvdf4rx"; + }; + + # https://github.com/mehcode/python-xmlsec/issues/84#issuecomment-632930116 + patches = [ + ./reset-lxml-in-tests.patch + ]; + + nativeBuildInputs = [ pkg-config pkgconfig setuptools-scm toml ]; + + buildInputs = [ xmlsec libxslt libxml2 libtool ]; + + propagatedBuildInputs = [ lxml ]; + + # Full git clone required for test_doc_examples + checkInputs = [ pytestCheckHook hypothesis ]; + disabledTestPaths = [ "tests/test_doc_examples.py" ]; + + meta = with lib; { + description = "Python bindings for the XML Security Library"; + homepage = "https://github.com/mehcode/python-xmlsec"; + license = licenses.mit; + maintainers = with maintainers; [ zhaofengli ]; + }; +} diff --git a/pkgs/development/python-modules/xmlsec/reset-lxml-in-tests.patch b/pkgs/development/python-modules/xmlsec/reset-lxml-in-tests.patch new file mode 100644 index 000000000000..0968583faa63 --- /dev/null +++ b/pkgs/development/python-modules/xmlsec/reset-lxml-in-tests.patch @@ -0,0 +1,22 @@ +diff --git a/tests/base.py b/tests/base.py +index b05de1d..5ec356f 100644 +--- a/tests/base.py ++++ b/tests/base.py +@@ -94,6 +94,7 @@ class TestMemoryLeaks(unittest.TestCase): + + def load_xml(self, name, xpath=None): + """returns xml.etree""" ++ etree.set_default_parser(parser=etree.XMLParser()) + root = etree.parse(self.path(name)).getroot() + if xpath is None: + return root +diff --git a/tests/test_doc_examples.py b/tests/test_doc_examples.py +index 2fc490f..53d2377 100644 +--- a/tests/test_doc_examples.py ++++ b/tests/test_doc_examples.py +@@ -42,3 +42,5 @@ def test_doc_example(example): + """ + with cd(example.parent): + runpy.run_path(str(example)) ++ from lxml import etree ++ etree.set_default_parser(parser=etree.XMLParser()) diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index e4c40bce85a8..131e8c9e8d59 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -8632,6 +8632,10 @@ in { xmlschema = callPackage ../development/python-modules/xmlschema { }; + xmlsec = callPackage ../development/python-modules/xmlsec { + inherit (pkgs) libxslt libxml2 libtool pkg-config xmlsec; + }; + xmltodict = callPackage ../development/python-modules/xmltodict { }; xmodem = callPackage ../development/python-modules/xmodem { };