xmlsec 1.3.13__tar.gz → 1.3.14__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. {xmlsec-1.3.13 → xmlsec-1.3.14}/.pre-commit-config.yaml +7 -7
  2. {xmlsec-1.3.13 → xmlsec-1.3.14}/PKG-INFO +19 -13
  3. {xmlsec-1.3.13 → xmlsec-1.3.14}/README.rst +15 -12
  4. {xmlsec-1.3.13 → xmlsec-1.3.14}/pyproject.toml +40 -0
  5. {xmlsec-1.3.13 → xmlsec-1.3.14}/setup.cfg +3 -0
  6. {xmlsec-1.3.13 → xmlsec-1.3.14}/setup.py +147 -49
  7. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/common.h +1 -1
  8. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/constants.c +9 -4
  9. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/enc.c +12 -0
  10. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/keys.c +57 -1
  11. xmlsec-1.3.14/src/lxml.c +131 -0
  12. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/lxml.h +9 -0
  13. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/main.c +59 -4
  14. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/xmlsec/__init__.pyi +5 -0
  15. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/xmlsec/constants.pyi +1 -2
  16. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/xmlsec.egg-info/PKG-INFO +19 -13
  17. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/xmlsec.egg-info/SOURCES.txt +13 -11
  18. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/base.py +8 -23
  19. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/conftest.py +3 -2
  20. xmlsec-1.3.14/tests/data/sign5-out-xmlsec_1_2_36_to_37.xml +67 -0
  21. xmlsec-1.3.14/tests/softhsm_setup.py +332 -0
  22. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/test_ds.py +6 -3
  23. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/test_enc.py +4 -24
  24. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/test_main.py +2 -2
  25. xmlsec-1.3.14/tests/test_pkcs11.py +57 -0
  26. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/test_xmlsec.py +3 -3
  27. xmlsec-1.3.13/src/lxml.c +0 -43
  28. xmlsec-1.3.13/tests/data/enc-bad-in.xml +0 -208
  29. {xmlsec-1.3.13 → xmlsec-1.3.14}/.readthedocs.yaml +0 -0
  30. {xmlsec-1.3.13 → xmlsec-1.3.14}/LICENSE +0 -0
  31. {xmlsec-1.3.13 → xmlsec-1.3.14}/MANIFEST.in +0 -0
  32. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/constants.h +0 -0
  33. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/debug.h +0 -0
  34. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/ds.c +0 -0
  35. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/exception.c +0 -0
  36. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/exception.h +0 -0
  37. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/keys.h +0 -0
  38. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/platform.h +0 -0
  39. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/template.c +0 -0
  40. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/tree.c +0 -0
  41. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/utils.c +0 -0
  42. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/utils.h +0 -0
  43. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/xmlsec/py.typed +0 -0
  44. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/xmlsec/template.pyi +0 -0
  45. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/xmlsec/tree.pyi +0 -0
  46. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/xmlsec.egg-info/dependency_links.txt +0 -0
  47. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/xmlsec.egg-info/not-zip-safe +0 -0
  48. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/xmlsec.egg-info/requires.txt +0 -0
  49. {xmlsec-1.3.13 → xmlsec-1.3.14}/src/xmlsec.egg-info/top_level.txt +0 -0
  50. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/__init__.py +0 -0
  51. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/deskey.bin +0 -0
  52. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/doc.xml +0 -0
  53. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/dsacert.der +0 -0
  54. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/dsakey.der +0 -0
  55. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/enc1-in.xml +0 -0
  56. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/enc1-out.xml +0 -0
  57. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/enc2-in.xml +0 -0
  58. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/enc2-out.xml +0 -0
  59. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/enc3-in.xml +0 -0
  60. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/enc3-out.xml +0 -0
  61. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/enc_template.xml +0 -0
  62. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/rsacert.pem +0 -0
  63. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/rsakey.pem +0 -0
  64. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/rsapub.pem +0 -0
  65. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/sign1-in.xml +0 -0
  66. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/sign1-out.xml +0 -0
  67. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/sign2-in.xml +0 -0
  68. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/sign2-out.xml +0 -0
  69. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/sign3-in.xml +0 -0
  70. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/sign3-out.xml +0 -0
  71. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/sign4-in.xml +0 -0
  72. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/sign4-out.xml +0 -0
  73. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/sign5-in.xml +0 -0
  74. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/sign5-out.xml +0 -0
  75. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/sign6-in.bin +0 -0
  76. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/sign6-out.bin +0 -0
  77. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/data/sign_template.xml +0 -0
  78. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/test_constants.py +0 -0
  79. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/test_doc_examples.py +0 -0
  80. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/test_keys.py +0 -0
  81. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/test_templates.py +0 -0
  82. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/test_tree.py +0 -0
  83. {xmlsec-1.3.13 → xmlsec-1.3.14}/tests/test_type_stubs.py +0 -0
@@ -1,16 +1,15 @@
1
1
  # See https://pre-commit.com for more information
2
2
  # See https://pre-commit.com/hooks.html for more hooks
3
- exclude: ".*.diff" # exclude patches
4
3
  repos:
5
4
  - repo: https://github.com/psf/black
6
- rev: 22.6.0
5
+ rev: 24.3.0
7
6
  hooks:
8
7
  - id: black
9
8
  types: []
10
9
  files: ^.*.pyi?$
11
10
  exclude: ^doc/
12
11
  - repo: https://github.com/pre-commit/pre-commit-hooks
13
- rev: v4.3.0
12
+ rev: v4.6.0
14
13
  hooks:
15
14
  - id: no-commit-to-branch
16
15
  - id: trailing-whitespace
@@ -21,21 +20,22 @@ repos:
21
20
  - id: check-merge-conflict
22
21
  - id: check-json
23
22
  - id: detect-private-key
23
+ exclude: ^.*/rsakey.pem$
24
24
  - id: mixed-line-ending
25
25
  - id: pretty-format-json
26
26
  args: [--autofix]
27
27
  - repo: https://github.com/PyCQA/flake8
28
- rev: 5.0.4
28
+ rev: 7.0.0
29
29
  hooks:
30
30
  - id: flake8
31
31
  exclude: ^setup.py$
32
32
  additional_dependencies: [flake8-docstrings, flake8-bugbear, flake8-logging-format, flake8-builtins, flake8-eradicate, flake8-fixme, pep8-naming, flake8-pep3101, flake8-annotations-complexity,flake8-pyi]
33
33
  - repo: https://github.com/PyCQA/isort
34
- rev: 5.10.1
34
+ rev: 5.13.2
35
35
  hooks:
36
36
  - id: isort
37
37
  - repo: https://github.com/pre-commit/mirrors-mypy
38
- rev: v0.971
38
+ rev: v1.9.0
39
39
  hooks:
40
40
  - id: mypy
41
41
  exclude: (setup.py|tests/.*.py|doc/.*)
@@ -43,6 +43,6 @@ repos:
43
43
  files: ^.*.pyi?$
44
44
  additional_dependencies: [lxml-stubs,types-docutils]
45
45
  - repo: https://github.com/pre-commit/pygrep-hooks
46
- rev: v1.9.0
46
+ rev: v1.10.0
47
47
  hooks:
48
48
  - id: rst-backticks
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xmlsec
3
- Version: 1.3.13
3
+ Version: 1.3.14
4
4
  Summary: Python bindings for the XML Security Library
5
5
  Home-page: https://github.com/mehcode/python-xmlsec
6
6
  Author: Bulat Gaifullin
@@ -24,28 +24,34 @@ Classifier: Programming Language :: Python :: 3.6
24
24
  Classifier: Programming Language :: Python :: 3.7
25
25
  Classifier: Programming Language :: Python :: 3.8
26
26
  Classifier: Programming Language :: Python :: 3.9
27
+ Classifier: Programming Language :: Python :: 3.11
27
28
  Classifier: Topic :: Text Processing :: Markup :: XML
28
29
  Classifier: Typing :: Typed
29
30
  Requires-Python: >=3.5
31
+ Description-Content-Type: text/markdown
30
32
  License-File: LICENSE
33
+ Requires-Dist: lxml>=3.8
31
34
 
32
35
  python-xmlsec
33
36
  =============
34
37
 
35
38
  .. image:: https://img.shields.io/pypi/v/xmlsec.svg?logo=python&logoColor=white
36
39
  :target: https://pypi.python.org/pypi/xmlsec
37
- .. image:: https://img.shields.io/travis/com/mehcode/python-xmlsec/master.svg?logo=travis&logoColor=white&label=Travis%20CI
38
- :target: https://travis-ci.org/mehcode/python-xmlsec
40
+ .. image:: https://results.pre-commit.ci/badge/github/xmlsec/python-xmlsec/master.svg
41
+ :target: https://results.pre-commit.ci/latest/github/xmlsec/python-xmlsec/master
42
+ :alt: pre-commit.ci status
39
43
  .. image:: https://img.shields.io/appveyor/ci/hoefling/xmlsec/master.svg?logo=appveyor&logoColor=white&label=AppVeyor
40
44
  :target: https://ci.appveyor.com/project/hoefling/xmlsec
41
- .. image:: https://github.com/mehcode/python-xmlsec/workflows/manylinux2010/badge.svg
42
- :target: https://github.com/mehcode/python-xmlsec/actions?query=workflow%3A%22manylinux2010%22
43
- .. image:: https://github.com/mehcode/python-xmlsec/workflows/MacOS/badge.svg
44
- :target: https://github.com/mehcode/python-xmlsec/actions?query=workflow%3A%22MacOS%22
45
- .. image:: https://github.com/mehcode/python-xmlsec/workflows/linuxbrew/badge.svg
46
- :target: https://github.com/mehcode/python-xmlsec/actions?query=workflow%3A%22linuxbrew%22
47
- .. image:: https://codecov.io/gh/mehcode/python-xmlsec/branch/master/graph/badge.svg
48
- :target: https://codecov.io/gh/mehcode/python-xmlsec
45
+ .. image:: https://github.com/mehcode/python-xmlsec/actions/workflows/manylinux.yml/badge.svg
46
+ :target: https://github.com/mehcode/python-xmlsec/actions/workflows/manylinux.yml
47
+ .. image:: https://github.com/mehcode/python-xmlsec/actions/workflows/macosx.yml/badge.svg
48
+ :target: https://github.com/mehcode/python-xmlsec/actions/workflows/macosx.yml
49
+ .. image:: https://github.com/mehcode/python-xmlsec/actions/workflows/linuxbrew.yml/badge.svg
50
+ :target: https://github.com/mehcode/python-xmlsec/actions/workflows/linuxbrew.yml
51
+ .. image:: https://github.com/mehcode/python-xmlsec/actions/workflows/opensuse-tumbleweed.yml/badge.svg
52
+ :target: https://github.com/mehcode/python-xmlsec/actions/workflows/opensuse-tumbleweed.yml
53
+ .. image:: https://codecov.io/gh/xmlsec/python-xmlsec/branch/master/graph/badge.svg
54
+ :target: https://codecov.io/gh/xmlsec/python-xmlsec
49
55
  .. image:: https://img.shields.io/readthedocs/xmlsec/latest?logo=read-the-docs
50
56
  :target: https://xmlsec.readthedocs.io/en/latest/?badge=latest
51
57
  :alt: Documentation Status
@@ -65,7 +71,7 @@ Check the `examples <https://xmlsec.readthedocs.io/en/latest/examples.html>`_ se
65
71
  Requirements
66
72
  ************
67
73
  - ``libxml2 >= 2.9.1``
68
- - ``libxmlsec1 >= 1.2.18``
74
+ - ``libxmlsec1 >= 1.2.33``
69
75
 
70
76
  Install
71
77
  *******
@@ -164,7 +170,7 @@ Building from source
164
170
 
165
171
  .. code-block:: bash
166
172
 
167
- git clone https://github.com/mehcode/python-xmlsec.git
173
+ git clone https://github.com/xmlsec/python-xmlsec.git
168
174
 
169
175
  #. Change into the ``python-xmlsec`` root directory.
170
176
 
@@ -3,18 +3,21 @@ python-xmlsec
3
3
 
4
4
  .. image:: https://img.shields.io/pypi/v/xmlsec.svg?logo=python&logoColor=white
5
5
  :target: https://pypi.python.org/pypi/xmlsec
6
- .. image:: https://img.shields.io/travis/com/mehcode/python-xmlsec/master.svg?logo=travis&logoColor=white&label=Travis%20CI
7
- :target: https://travis-ci.org/mehcode/python-xmlsec
6
+ .. image:: https://results.pre-commit.ci/badge/github/xmlsec/python-xmlsec/master.svg
7
+ :target: https://results.pre-commit.ci/latest/github/xmlsec/python-xmlsec/master
8
+ :alt: pre-commit.ci status
8
9
  .. image:: https://img.shields.io/appveyor/ci/hoefling/xmlsec/master.svg?logo=appveyor&logoColor=white&label=AppVeyor
9
10
  :target: https://ci.appveyor.com/project/hoefling/xmlsec
10
- .. image:: https://github.com/mehcode/python-xmlsec/workflows/manylinux2010/badge.svg
11
- :target: https://github.com/mehcode/python-xmlsec/actions?query=workflow%3A%22manylinux2010%22
12
- .. image:: https://github.com/mehcode/python-xmlsec/workflows/MacOS/badge.svg
13
- :target: https://github.com/mehcode/python-xmlsec/actions?query=workflow%3A%22MacOS%22
14
- .. image:: https://github.com/mehcode/python-xmlsec/workflows/linuxbrew/badge.svg
15
- :target: https://github.com/mehcode/python-xmlsec/actions?query=workflow%3A%22linuxbrew%22
16
- .. image:: https://codecov.io/gh/mehcode/python-xmlsec/branch/master/graph/badge.svg
17
- :target: https://codecov.io/gh/mehcode/python-xmlsec
11
+ .. image:: https://github.com/mehcode/python-xmlsec/actions/workflows/manylinux.yml/badge.svg
12
+ :target: https://github.com/mehcode/python-xmlsec/actions/workflows/manylinux.yml
13
+ .. image:: https://github.com/mehcode/python-xmlsec/actions/workflows/macosx.yml/badge.svg
14
+ :target: https://github.com/mehcode/python-xmlsec/actions/workflows/macosx.yml
15
+ .. image:: https://github.com/mehcode/python-xmlsec/actions/workflows/linuxbrew.yml/badge.svg
16
+ :target: https://github.com/mehcode/python-xmlsec/actions/workflows/linuxbrew.yml
17
+ .. image:: https://github.com/mehcode/python-xmlsec/actions/workflows/opensuse-tumbleweed.yml/badge.svg
18
+ :target: https://github.com/mehcode/python-xmlsec/actions/workflows/opensuse-tumbleweed.yml
19
+ .. image:: https://codecov.io/gh/xmlsec/python-xmlsec/branch/master/graph/badge.svg
20
+ :target: https://codecov.io/gh/xmlsec/python-xmlsec
18
21
  .. image:: https://img.shields.io/readthedocs/xmlsec/latest?logo=read-the-docs
19
22
  :target: https://xmlsec.readthedocs.io/en/latest/?badge=latest
20
23
  :alt: Documentation Status
@@ -34,7 +37,7 @@ Check the `examples <https://xmlsec.readthedocs.io/en/latest/examples.html>`_ se
34
37
  Requirements
35
38
  ************
36
39
  - ``libxml2 >= 2.9.1``
37
- - ``libxmlsec1 >= 1.2.18``
40
+ - ``libxmlsec1 >= 1.2.33``
38
41
 
39
42
  Install
40
43
  *******
@@ -133,7 +136,7 @@ Building from source
133
136
 
134
137
  .. code-block:: bash
135
138
 
136
- git clone https://github.com/mehcode/python-xmlsec.git
139
+ git clone https://github.com/xmlsec/python-xmlsec.git
137
140
 
138
141
  #. Change into the ``python-xmlsec`` root directory.
139
142
 
@@ -45,3 +45,43 @@ known_third_party = ['lxml', 'pytest', '_pytest', 'hypothesis']
45
45
 
46
46
  [build-system]
47
47
  requires = ['setuptools>=42', 'wheel', 'setuptools_scm[toml]>=3.4', "pkgconfig>=1.5.1", "lxml>=3.8, !=4.7.0"]
48
+
49
+ [tool.cibuildwheel]
50
+ build-verbosity = 1
51
+ build-frontend = "build"
52
+ skip = [
53
+ "pp*",
54
+ "*-musllinux_i686",
55
+ # LXML doesn't publish wheels for these platforms, which makes it
56
+ # difficult for us to build wheels, so we exclude them.
57
+ "cp36-manylinux_aarch64",
58
+ "cp37-manylinux_aarch64",
59
+ "cp36-musllinux_aarch64",
60
+ "cp37-musllinux_aarch64",
61
+ ]
62
+ test-command = "pytest -v --color=yes {package}/tests"
63
+ before-test = "pip install -r requirements-test.txt"
64
+ test-skip = "*-macosx_arm64"
65
+
66
+ [tool.cibuildwheel.environment]
67
+ PYXMLSEC_STATIC_DEPS = "true"
68
+
69
+ [tool.cibuildwheel.linux]
70
+ archs = ["x86_64", "aarch64", "i686"]
71
+ environment-pass = [
72
+ "PYXMLSEC_LIBXML2_VERSION",
73
+ "PYXMLSEC_LIBXSLT_VERSION",
74
+ "PYXMLSEC_STATIC_DEPS",
75
+ "GH_TOKEN"
76
+ ]
77
+
78
+ [tool.cibuildwheel.macos]
79
+ archs = ["x86_64", "arm64"]
80
+ before-all = "brew install perl"
81
+
82
+ [tool.cibuildwheel.windows]
83
+ archs = ["AMD64", "x86"]
84
+
85
+ [[tool.cibuildwheel.overrides]]
86
+ select = "*-manylinux*"
87
+ before-all = "yum install -y perl-core"
@@ -18,6 +18,9 @@ upload_dir = doc/build/html
18
18
  [flake8]
19
19
  per-file-ignores =
20
20
  *.pyi: E301, E302, E305, E501, E701, F401, F822
21
+ doc/source/conf.py: D1
22
+ doc/source/examples/*.py: D1, E501
23
+ tests/*.py: D1
21
24
  exclude = .venv*,.git,*_pb2.pyi,build,dist,libs,.eggs,.direnv*
22
25
  max-line-length = 130
23
26
 
@@ -13,7 +13,8 @@ from distutils import log
13
13
  from distutils.errors import DistutilsError
14
14
  from distutils.version import StrictVersion as Version
15
15
  from pathlib import Path
16
- from urllib.request import urlcleanup, urljoin, urlopen, urlretrieve
16
+ from urllib.parse import urljoin
17
+ from urllib.request import Request, urlcleanup, urlopen, urlretrieve
17
18
 
18
19
  from setuptools import Extension, setup
19
20
  from setuptools.command.build_ext import build_ext as build_ext_orig
@@ -31,31 +32,60 @@ class HrefCollector(html.parser.HTMLParser):
31
32
  self.hrefs.append(value)
32
33
 
33
34
 
34
- def latest_release_from_html(url, matcher):
35
- with contextlib.closing(urlopen(url)) as r:
35
+ def make_request(url, github_token=None, json_response=False):
36
+ headers = {'User-Agent': 'https://github.com/xmlsec/python-xmlsec'}
37
+ if github_token:
38
+ headers['authorization'] = "Bearer " + github_token
39
+ request = Request(url, headers=headers)
40
+ with contextlib.closing(urlopen(request)) as r:
36
41
  charset = r.headers.get_content_charset() or 'utf-8'
37
42
  content = r.read().decode(charset)
38
- collector = HrefCollector()
39
- collector.feed(content)
40
- hrefs = collector.hrefs
43
+ if json_response:
44
+ return json.loads(content)
45
+ else:
46
+ return content
41
47
 
42
- def comp(text):
43
- try:
44
- return Version(matcher.match(text).groupdict()['version'])
45
- except (AttributeError, ValueError):
46
- return Version('0.0')
47
48
 
48
- latest = max(hrefs, key=comp)
49
- return '{}/{}'.format(url, latest)
49
+ def latest_release_from_html(url, matcher):
50
+ content = make_request(url)
51
+ collector = HrefCollector()
52
+ collector.feed(content)
53
+ hrefs = collector.hrefs
54
+
55
+ def comp(text):
56
+ try:
57
+ return Version(matcher.match(text).groupdict()['version'])
58
+ except (AttributeError, ValueError):
59
+ return Version('0.0')
60
+
61
+ latest = max(hrefs, key=comp)
62
+ return '{}/{}'.format(url, latest)
50
63
 
51
64
 
52
65
  def latest_release_from_gnome_org_cache(url, lib_name):
53
66
  cache_url = '{}/cache.json'.format(url)
54
- with contextlib.closing(urlopen(cache_url)) as r:
55
- cache = json.load(r)
56
- latest_version = cache[2][lib_name][-1]
57
- latest_source = cache[1][lib_name][latest_version]['tar.xz']
58
- return '{}/{}'.format(url, latest_source)
67
+ cache = make_request(cache_url, json_response=True)
68
+ latest_version = cache[2][lib_name][-1]
69
+ latest_source = cache[1][lib_name][latest_version]['tar.xz']
70
+ return '{}/{}'.format(url, latest_source)
71
+
72
+
73
+ def latest_release_from_github_api(repo):
74
+ api_url = 'https://api.github.com/repos/{}/releases'.format(repo)
75
+
76
+ # if we are running in CI, pass along the GH_TOKEN, so we don't get rate limited
77
+ token = os.environ.get("GH_TOKEN")
78
+ if token:
79
+ log.info("Using GitHub token to avoid rate limiting")
80
+ api_releases = make_request(api_url, token, json_response=True)
81
+ releases = [r['tarball_url'] for r in api_releases if r['prerelease'] is False and r['draft'] is False]
82
+ if not releases:
83
+ raise DistutilsError('No release found for {}'.format(repo))
84
+ return releases[0]
85
+
86
+
87
+ def latest_openssl_release():
88
+ return latest_release_from_github_api('openssl/openssl')
59
89
 
60
90
 
61
91
  def latest_zlib_release():
@@ -78,6 +108,17 @@ def latest_xmlsec_release():
78
108
  return latest_release_from_html('https://www.aleksey.com/xmlsec/download/', re.compile('xmlsec1-(?P<version>.*).tar.gz'))
79
109
 
80
110
 
111
+ class CrossCompileInfo:
112
+ def __init__(self, host, arch, compiler):
113
+ self.host = host
114
+ self.arch = arch
115
+ self.compiler = compiler
116
+
117
+ @property
118
+ def triplet(self):
119
+ return "{}-{}-{}".format(self.host, self.arch, self.compiler)
120
+
121
+
81
122
  class build_ext(build_ext_orig):
82
123
  def info(self, message):
83
124
  self.announce(message, level=log.INFO)
@@ -86,6 +127,7 @@ class build_ext(build_ext_orig):
86
127
  ext = self.ext_map['xmlsec']
87
128
  self.debug = os.environ.get('PYXMLSEC_ENABLE_DEBUG', False)
88
129
  self.static = os.environ.get('PYXMLSEC_STATIC_DEPS', False)
130
+ self.size_opt = os.environ.get('PYXMLSEC_OPTIMIZE_SIZE', True)
89
131
 
90
132
  if self.static or sys.platform == 'win32':
91
133
  self.info('starting static build on {}'.format(sys.platform))
@@ -105,7 +147,9 @@ class build_ext(build_ext_orig):
105
147
  if sys.platform == 'win32':
106
148
  self.prepare_static_build_win()
107
149
  elif 'linux' in sys.platform:
108
- self.prepare_static_build_linux()
150
+ self.prepare_static_build(sys.platform)
151
+ elif 'darwin' in sys.platform:
152
+ self.prepare_static_build(sys.platform)
109
153
  else:
110
154
  import pkgconfig
111
155
 
@@ -132,7 +176,7 @@ class build_ext(build_ext_orig):
132
176
  [('MODULE_NAME', self.distribution.metadata.name), ('MODULE_VERSION', self.distribution.metadata.version)]
133
177
  )
134
178
  # escape the XMLSEC_CRYPTO macro value, see mehcode/python-xmlsec#141
135
- for (key, value) in ext.define_macros:
179
+ for key, value in ext.define_macros:
136
180
  if key == 'XMLSEC_CRYPTO' and not (value.startswith('"') and value.endswith('"')):
137
181
  ext.define_macros.remove((key, value))
138
182
  ext.define_macros.append((key, '"{0}"'.format(value)))
@@ -153,28 +197,35 @@ class build_ext(build_ext_orig):
153
197
  )
154
198
 
155
199
  if self.debug:
156
- ext.extra_compile_args.append('-Wall')
157
- ext.extra_compile_args.append('-O0')
158
200
  ext.define_macros.append(('PYXMLSEC_ENABLE_DEBUG', '1'))
201
+ if sys.platform == 'win32':
202
+ ext.extra_compile_args.append('/Od')
203
+ else:
204
+ ext.extra_compile_args.append('-Wall')
205
+ ext.extra_compile_args.append('-O0')
159
206
  else:
160
- ext.extra_compile_args.append('-Os')
207
+ if self.size_opt:
208
+ if sys.platform == 'win32':
209
+ ext.extra_compile_args.append('/Os')
210
+ else:
211
+ ext.extra_compile_args.append('-Os')
161
212
 
162
213
  super(build_ext, self).run()
163
214
 
164
215
  def prepare_static_build_win(self):
165
- release_url = 'https://github.com/bgaifullin/libxml2-win-binaries/releases/download/v2018.08/'
166
- if sys.maxsize > 2147483647:
216
+ release_url = 'https://github.com/mxamin/python-xmlsec-win-binaries/releases/download/2024.04.17/'
217
+ if sys.maxsize > 2147483647: # 2.0 GiB
167
218
  suffix = 'win64'
168
219
  else:
169
220
  suffix = 'win32'
170
221
 
171
222
  libs = [
172
- 'libxml2-2.9.4.{}.zip'.format(suffix),
173
- 'libxslt-1.1.29.{}.zip'.format(suffix),
174
- 'zlib-1.2.8.{}.zip'.format(suffix),
175
- 'iconv-1.14.{}.zip'.format(suffix),
176
- 'openssl-1.0.1.{}.zip'.format(suffix),
177
- 'xmlsec-1.2.24.{}.zip'.format(suffix),
223
+ 'libxml2-2.11.7.{}.zip'.format(suffix),
224
+ 'libxslt-1.1.37.{}.zip'.format(suffix),
225
+ 'zlib-1.2.12.{}.zip'.format(suffix),
226
+ 'iconv-1.16-1.{}.zip'.format(suffix),
227
+ 'openssl-3.0.8.{}.zip'.format(suffix),
228
+ 'xmlsec-1.3.4.{}.zip'.format(suffix),
178
229
  ]
179
230
 
180
231
  for libfile in libs:
@@ -211,7 +262,7 @@ class build_ext(build_ext_orig):
211
262
  ext.libraries = [
212
263
  'libxmlsec_a',
213
264
  'libxmlsec-openssl_a',
214
- 'libeay32',
265
+ 'libcrypto',
215
266
  'iconv_a',
216
267
  'libxslt_a',
217
268
  'libexslt_a',
@@ -229,8 +280,8 @@ class build_ext(build_ext_orig):
229
280
  includes.append(next(p / 'xmlsec' for p in includes if (p / 'xmlsec').is_dir()))
230
281
  ext.include_dirs = [str(p.absolute()) for p in includes]
231
282
 
232
- def prepare_static_build_linux(self):
233
- self.openssl_version = os.environ.get('PYXMLSEC_OPENSSL_VERSION', '1.1.1q')
283
+ def prepare_static_build(self, build_platform):
284
+ self.openssl_version = os.environ.get('PYXMLSEC_OPENSSL_VERSION')
234
285
  self.libiconv_version = os.environ.get('PYXMLSEC_LIBICONV_VERSION')
235
286
  self.libxml2_version = os.environ.get('PYXMLSEC_LIBXML2_VERSION')
236
287
  self.libxslt_version = os.environ.get('PYXMLSEC_LIBXSLT_VERSION')
@@ -242,8 +293,13 @@ class build_ext(build_ext_orig):
242
293
  if openssl_tar is None:
243
294
  self.info('{:10}: {}'.format('OpenSSL', 'source tar not found, downloading ...'))
244
295
  openssl_tar = self.libs_dir / 'openssl.tar.gz'
245
- self.info('{:10}: {} {}'.format('OpenSSL', 'version', self.openssl_version))
246
- urlretrieve('https://www.openssl.org/source/openssl-{}.tar.gz'.format(self.openssl_version), str(openssl_tar))
296
+ if self.openssl_version is None:
297
+ url = latest_openssl_release()
298
+ self.info('{:10}: {}'.format('OpenSSL', 'PYXMLSEC_OPENSSL_VERSION unset, downloading latest from {}'.format(url)))
299
+ else:
300
+ url = 'https://api.github.com/repos/openssl/openssl/tarball/openssl-{}'.format(self.openssl_version)
301
+ self.info('{:10}: {} {}'.format('OpenSSL', 'version', self.openssl_version))
302
+ urlretrieve(url, str(openssl_tar))
247
303
 
248
304
  # fetch zlib
249
305
  zlib_tar = next(self.libs_dir.glob('zlib*.tar.gz'), None)
@@ -344,16 +400,42 @@ class build_ext(build_ext_orig):
344
400
 
345
401
  prefix_arg = '--prefix={}'.format(self.prefix_dir)
346
402
 
347
- cflags = ['-fPIC']
348
403
  env = os.environ.copy()
349
- if 'CFLAGS' in env:
350
- env['CFLAGS'].append(' '.join(cflags))
351
- else:
352
- env['CFLAGS'] = ' '.join(cflags)
404
+ cflags = []
405
+ if env.get('CFLAGS'):
406
+ cflags.append(env['CFLAGS'])
407
+ cflags.append('-fPIC')
408
+ ldflags = []
409
+ if env.get('LDFLAGS'):
410
+ ldflags.append(env['LDFLAGS'])
411
+
412
+ cross_compiling = False
413
+ if build_platform == 'darwin':
414
+ import platform
415
+
416
+ arch = self.plat_name.rsplit('-', 1)[1]
417
+ if arch != platform.machine() and arch in ('x86_64', 'arm64'):
418
+ self.info('Cross-compiling for {}'.format(arch))
419
+ cflags.append('-arch {}'.format(arch))
420
+ ldflags.append('-arch {}'.format(arch))
421
+ cross_compiling = CrossCompileInfo('darwin64', arch, 'cc')
422
+ major_version, minor_version = tuple(map(int, platform.mac_ver()[0].split('.')[:2]))
423
+ if major_version >= 11:
424
+ if 'MACOSX_DEPLOYMENT_TARGET' not in env:
425
+ env['MACOSX_DEPLOYMENT_TARGET'] = "11.0"
426
+
427
+ env['CFLAGS'] = ' '.join(cflags)
428
+ env['LDFLAGS'] = ' '.join(ldflags)
353
429
 
354
430
  self.info('Building OpenSSL')
355
431
  openssl_dir = next(self.build_libs_dir.glob('openssl-*'))
356
- subprocess.check_output(['./config', prefix_arg, 'no-shared', '-fPIC'], cwd=str(openssl_dir), env=env)
432
+ openssl_config_cmd = [prefix_arg, 'no-shared', '-fPIC', '--libdir=lib']
433
+ if cross_compiling:
434
+ openssl_config_cmd.insert(0, './Configure')
435
+ openssl_config_cmd.append(cross_compiling.triplet)
436
+ else:
437
+ openssl_config_cmd.insert(0, './config')
438
+ subprocess.check_output(openssl_config_cmd, cwd=str(openssl_dir), env=env)
357
439
  subprocess.check_output(['make', '-j{}'.format(multiprocessing.cpu_count() + 1)], cwd=str(openssl_dir), env=env)
358
440
  subprocess.check_output(
359
441
  ['make', '-j{}'.format(multiprocessing.cpu_count() + 1), 'install_sw'], cwd=str(openssl_dir), env=env
@@ -365,10 +447,22 @@ class build_ext(build_ext_orig):
365
447
  subprocess.check_output(['make', '-j{}'.format(multiprocessing.cpu_count() + 1)], cwd=str(zlib_dir), env=env)
366
448
  subprocess.check_output(['make', '-j{}'.format(multiprocessing.cpu_count() + 1), 'install'], cwd=str(zlib_dir), env=env)
367
449
 
450
+ host_arg = ""
451
+ if cross_compiling:
452
+ host_arg = '--host={}'.format(cross_compiling.arch)
453
+
368
454
  self.info('Building libiconv')
369
455
  libiconv_dir = next(self.build_libs_dir.glob('libiconv-*'))
370
456
  subprocess.check_output(
371
- ['./configure', prefix_arg, '--disable-dependency-tracking', '--disable-shared'], cwd=str(libiconv_dir), env=env
457
+ [
458
+ './configure',
459
+ prefix_arg,
460
+ '--disable-dependency-tracking',
461
+ '--disable-shared',
462
+ host_arg,
463
+ ],
464
+ cwd=str(libiconv_dir),
465
+ env=env,
372
466
  )
373
467
  subprocess.check_output(['make', '-j{}'.format(multiprocessing.cpu_count() + 1)], cwd=str(libiconv_dir), env=env)
374
468
  subprocess.check_output(
@@ -383,11 +477,11 @@ class build_ext(build_ext_orig):
383
477
  prefix_arg,
384
478
  '--disable-dependency-tracking',
385
479
  '--disable-shared',
386
- '--enable-rebuild-docs=no',
387
480
  '--without-lzma',
388
481
  '--without-python',
389
482
  '--with-iconv={}'.format(self.prefix_dir),
390
483
  '--with-zlib={}'.format(self.prefix_dir),
484
+ host_arg,
391
485
  ],
392
486
  cwd=str(libxml2_dir),
393
487
  env=env,
@@ -408,6 +502,7 @@ class build_ext(build_ext_orig):
408
502
  '--without-python',
409
503
  '--without-crypto',
410
504
  '--with-libxml-prefix={}'.format(self.prefix_dir),
505
+ host_arg,
411
506
  ],
412
507
  cwd=str(libxslt_dir),
413
508
  env=env,
@@ -418,10 +513,8 @@ class build_ext(build_ext_orig):
418
513
  )
419
514
 
420
515
  self.info('Building xmlsec1')
421
- if 'LDFLAGS' in env:
422
- env['LDFLAGS'].append(' -lpthread')
423
- else:
424
- env['LDFLAGS'] = '-lpthread'
516
+ ldflags.append('-lpthread')
517
+ env['LDFLAGS'] = ' '.join(ldflags)
425
518
  xmlsec1_dir = next(self.build_libs_dir.glob('xmlsec1-*'))
426
519
  subprocess.check_output(
427
520
  [
@@ -429,6 +522,7 @@ class build_ext(build_ext_orig):
429
522
  prefix_arg,
430
523
  '--disable-shared',
431
524
  '--disable-gost',
525
+ '--enable-md5',
432
526
  '--disable-crypto-dl',
433
527
  '--enable-static=yes',
434
528
  '--enable-shared=no',
@@ -437,6 +531,7 @@ class build_ext(build_ext_orig):
437
531
  '--with-openssl={}'.format(self.prefix_dir),
438
532
  '--with-libxml={}'.format(self.prefix_dir),
439
533
  '--with-libxslt={}'.format(self.prefix_dir),
534
+ host_arg,
440
535
  ],
441
536
  cwd=str(xmlsec1_dir),
442
537
  env=env,
@@ -474,7 +569,8 @@ class build_ext(build_ext_orig):
474
569
  ext.include_dirs.extend([str(p.absolute()) for p in (self.prefix_dir / 'include').iterdir() if p.is_dir()])
475
570
 
476
571
  ext.library_dirs = []
477
- ext.libraries = ['m', 'rt']
572
+ if build_platform == 'linux':
573
+ ext.libraries = ['m', 'rt']
478
574
  extra_objects = [
479
575
  'libxmlsec1.a',
480
576
  'libxslt.a',
@@ -503,6 +599,7 @@ setup(
503
599
  use_scm_version=True,
504
600
  description='Python bindings for the XML Security Library',
505
601
  long_description=long_desc,
602
+ long_description_content_type='text/markdown',
506
603
  ext_modules=[pyxmlsec],
507
604
  cmdclass={'build_ext': build_ext},
508
605
  python_requires='>=3.5',
@@ -533,6 +630,7 @@ setup(
533
630
  'Programming Language :: Python :: 3.7',
534
631
  'Programming Language :: Python :: 3.8',
535
632
  'Programming Language :: Python :: 3.9',
633
+ 'Programming Language :: Python :: 3.11',
536
634
  'Topic :: Text Processing :: Markup :: XML',
537
635
  'Typing :: Typed',
538
636
  ],
@@ -13,7 +13,7 @@
13
13
  #include "debug.h"
14
14
 
15
15
  #ifndef MODULE_NAME
16
- #define MODULE_NAME "xmlsec"
16
+ #define MODULE_NAME xmlsec
17
17
  #endif
18
18
 
19
19
  #define JOIN(X,Y) DO_JOIN1(X,Y)
@@ -316,8 +316,6 @@ int PyXmlSec_ConstantsModule_Init(PyObject* package) {
316
316
  PYXMLSEC_ADD_NS_CONSTANT(XPathNs, "XPATH");
317
317
  PYXMLSEC_ADD_NS_CONSTANT(XPath2Ns, "XPATH2");
318
318
  PYXMLSEC_ADD_NS_CONSTANT(XPointerNs, "XPOINTER");
319
- PYXMLSEC_ADD_NS_CONSTANT(Soap11Ns, "SOAP11");
320
- PYXMLSEC_ADD_NS_CONSTANT(Soap12Ns, "SOAP12");
321
319
  PYXMLSEC_ADD_NS_CONSTANT(NsExcC14N, "EXC_C14N");
322
320
  PYXMLSEC_ADD_NS_CONSTANT(NsExcC14NWithComments, "EXC_C14N_WITH_COMMENT");
323
321
 
@@ -441,13 +439,18 @@ int PyXmlSec_ConstantsModule_Init(PyObject* package) {
441
439
  PYXMLSEC_ADD_KEYDATA_CONSTANT(KeyDataRetrievalMethod, "RETRIEVALMETHOD")
442
440
  PYXMLSEC_ADD_KEYDATA_CONSTANT(KeyDataEncryptedKey, "ENCRYPTEDKEY")
443
441
  PYXMLSEC_ADD_KEYDATA_CONSTANT(KeyDataAes, "AES")
442
+ #ifndef XMLSEC_NO_DES
444
443
  PYXMLSEC_ADD_KEYDATA_CONSTANT(KeyDataDes, "DES")
444
+ #endif
445
445
  #ifndef XMLSEC_NO_DSA
446
446
  PYXMLSEC_ADD_KEYDATA_CONSTANT(KeyDataDsa, "DSA")
447
447
  #endif
448
- #if XMLSEC_VERSION_HEX > 0x10212
449
- // from version 1.2.19
448
+ #if XMLSEC_VERSION_HEX > 0x10212 && XMLSEC_VERSION_HEX < 0x10303
449
+ // from version 1.2.19 to version 1.3.2 (inclusive)
450
450
  PYXMLSEC_ADD_KEYDATA_CONSTANT(KeyDataEcdsa, "ECDSA")
451
+ #elif XMLSEC_VERSION_HEX >= 0x10303
452
+ // from version 1.3.3 (inclusive)
453
+ PYXMLSEC_ADD_KEYDATA_CONSTANT(KeyDataEc, "ECDSA")
451
454
  #endif
452
455
  PYXMLSEC_ADD_KEYDATA_CONSTANT(KeyDataHmac, "HMAC")
453
456
  PYXMLSEC_ADD_KEYDATA_CONSTANT(KeyDataRsa, "RSA")
@@ -489,8 +492,10 @@ int PyXmlSec_ConstantsModule_Init(PyObject* package) {
489
492
  PYXMLSEC_ADD_TRANSFORM_CONSTANT(TransformKWAes192, "KW_AES192");
490
493
  PYXMLSEC_ADD_TRANSFORM_CONSTANT(TransformKWAes256, "KW_AES256");
491
494
 
495
+ #ifndef XMLSEC_NO_DES
492
496
  PYXMLSEC_ADD_TRANSFORM_CONSTANT(TransformDes3Cbc, "DES3");
493
497
  PYXMLSEC_ADD_TRANSFORM_CONSTANT(TransformKWDes3, "KW_DES3");
498
+ #endif
494
499
  #ifndef XMLSEC_NO_DSA
495
500
  PYXMLSEC_ADD_TRANSFORM_CONSTANT(TransformDsaSha1, "DSA_SHA1");
496
501
  #endif