Skip to content

Commit e3d3539

Browse files
authored
Merge pull request #323 from nosnilmot/lxml-workaround
Remove lxml version restriction
2 parents 96ad99e + 01a154c commit e3d3539

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ Installation
8888

8989
* python 2.7 // python 3.6
9090
* [xmlsec](https://pypi.python.org/pypi/xmlsec) Python bindings for the XML Security Library.
91+
* [lxml](https://pypi.python.org/pypi/lxml) Python bindings for the libxml2 and libxslt libraries.
9192
* [isodate](https://pypi.python.org/pypi/isodate) An ISO 8601 date/time/
9293
duration parser and formatter
9394

@@ -115,6 +116,14 @@ $ pip install python3-saml
115116

116117
If you want to know how a project can handle python packages review this [guide](https://packaging.python.org/en/latest/tutorial.html) and review this [sampleproject](https://github.com/pypa/sampleproject)
117118

119+
#### NOTE ####
120+
To avoid ``libxml2`` library version incompatibilities between ``xmlsec`` and ``lxml`` it is recommended that ``lxml`` is not installed from binary.
121+
122+
This can be ensured by executing:
123+
```
124+
$ pip install --force-reinstall --no-binary lxml lxml
125+
```
126+
118127
Security Warning
119128
----------------
120129

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
},
3535
test_suite='tests',
3636
install_requires=[
37-
'lxml<4.7.1',
37+
'lxml>=4.6.5',
3838
'isodate>=0.6.1',
3939
'xmlsec>=1.3.9'
4040
],

tests/src/OneLogin/saml2_tests/xml_utils_test.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import json
55
import unittest
6+
import xmlsec
67

78
from base64 import b64decode
89
from lxml import etree
@@ -32,6 +33,29 @@ def file_contents(self, filename):
3233
f.close()
3334
return content
3435

36+
def testLibxml2(self):
37+
"""
38+
Tests that libxml2 versions used by xmlsec and lxml are compatible
39+
40+
If this test fails, reinstall lxml without using binary to ensure it is
41+
linked to same version of libxml2 as xmlsec:
42+
pip install --force-reinstall --no-binary lxml lxml
43+
44+
See https://bugs.launchpad.net/lxml/+bug/1960668
45+
"""
46+
env = etree.fromstring('<xml></xml>')
47+
sig = xmlsec.template.create(
48+
env,
49+
xmlsec.Transform.EXCL_C14N,
50+
xmlsec.Transform.RSA_SHA256,
51+
ns="ds"
52+
)
53+
54+
ds = etree.QName(sig).namespace
55+
cm = sig.find(".//{%s}CanonicalizationMethod" % ds)
56+
57+
self.assertIsNotNone(cm)
58+
3559
def testValidateXML(self):
3660
"""
3761
Tests the validate_xml method of the OneLogin_Saml2_XML

0 commit comments

Comments
 (0)