diff --git a/0001-Remove-utility-from-packaging.patch b/0001-Remove-utility-from-packaging.patch new file mode 100644 index 0000000..fea3b6d --- /dev/null +++ b/0001-Remove-utility-from-packaging.patch @@ -0,0 +1,30 @@ +From 1deee97cb9121272cbdbcea491721875269e4fbf Mon Sep 17 00:00:00 2001 +From: Joel Capitao +Date: Sat, 8 Jul 2023 08:00:08 +0200 +Subject: [PATCH] Remove utility from packaging + +This fixes #899. +When packaging saml2 downstream with pyproject RPM macros, +the utility module is installed. This might clash with other +modules. + +(cherry picked from commit f20b6735053fd331aca3faba2bf1521c050bdf63) +--- + pyproject.toml | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/pyproject.toml b/pyproject.toml +index 1a76df7b..1c2715e1 100644 +--- a/pyproject.toml ++++ b/pyproject.toml +@@ -24,7 +24,6 @@ classifiers = [ + packages = [ + { include = "saml2", from = "src" }, + { include = "saml2test", from = "src" }, +- { include = "utility", from = "src" }, + ] + + [tool.poetry.urls] +-- +2.40.1 + diff --git a/0001-Use-importlib.resources-in-python-3.7.patch b/0001-Use-importlib.resources-in-python-3.7.patch deleted file mode 100644 index 43ed86e..0000000 --- a/0001-Use-importlib.resources-in-python-3.7.patch +++ /dev/null @@ -1,83 +0,0 @@ -From e1392feda59ed0fdcf10934d57f833c64e99c19a Mon Sep 17 00:00:00 2001 -From: Alfredo Moralejo -Date: Thu, 30 Sep 2021 09:39:36 +0200 -Subject: [PATCH] Use importlib.resources in python >= 3.7 - -importlib.resources was added to python standard library since python 3.7 -[1]. This patch is implementing conditional to use it instead of the -importlib_resources backport when using python 3.7 or newer. - -[1] https://docs.python.org/3/whatsnew/3.7.html ---- - setup.cfg | 2 +- - src/saml2/sigver.py | 7 ++++++- - src/saml2/xml/schema/__init__.py | 7 ++++++- - 3 files changed, 13 insertions(+), 3 deletions(-) - -diff --git a/setup.cfg b/setup.cfg -index e04c5520..41ccdd7f 100644 ---- a/setup.cfg -+++ b/setup.cfg -@@ -53,7 +53,7 @@ install_requires = - pytz - requests >= 1.0.0 - six -- importlib_resources -+ importlib_resources;python_version<'3.7' - xmlschema >= 1.2.1 - - -diff --git a/src/saml2/sigver.py b/src/saml2/sigver.py -index 973d6245..c9c66b13 100644 ---- a/src/saml2/sigver.py -+++ b/src/saml2/sigver.py -@@ -9,12 +9,12 @@ import logging - import os - import re - import six -+import sys - from uuid import uuid4 as gen_random_key - from time import mktime - from tempfile import NamedTemporaryFile - from subprocess import Popen - from subprocess import PIPE --from importlib_resources import path as _resource_path - - from OpenSSL import crypto - -@@ -59,6 +59,11 @@ from saml2.xmlenc import EncryptedData - from saml2.xml.schema import node_to_schema - from saml2.xml.schema import XMLSchemaError - -+# importlib.resources was introduced in python 3.7 -+if sys.version_info[:2] >= (3, 7): -+ from importlib.resources import path as _resource_path -+else: -+ from importlib_resources import path as _resource_path - - logger = logging.getLogger(__name__) - -diff --git a/src/saml2/xml/schema/__init__.py b/src/saml2/xml/schema/__init__.py -index 56e08b1c..ce38b807 100644 ---- a/src/saml2/xml/schema/__init__.py -+++ b/src/saml2/xml/schema/__init__.py -@@ -1,10 +1,15 @@ --from importlib_resources import path as _resource_path -+import sys - - from xmlschema import XMLSchema as _XMLSchema - from xmlschema.exceptions import XMLSchemaException as XMLSchemaError - - import saml2.data.schemas as _data_schemas - -+# importlib.resources was introduced in python 3.7 -+if sys.version_info[:2] >= (3, 7): -+ from importlib.resources import path as _resource_path -+else: -+ from importlib_resources import path as _resource_path - - def _create_xml_schema_validator(source, **kwargs): - kwargs = { --- -2.26.3 - diff --git a/python-pysaml2.spec b/python-pysaml2.spec index ad20a21..944f634 100644 --- a/python-pysaml2.spec +++ b/python-pysaml2.spec @@ -1,75 +1,47 @@ %global srcname pysaml2 +%global gittag v%{version} +%global _description \ +PySAML2 is a pure python implementation of SAML2. It contains all \ +necessary pieces for building a SAML2 service provider or an identity \ +provider. The distribution contains examples of both. Originally \ +written to work in a WSGI environment there are extensions that allow \ +you to use it with other frameworks. + Name: python-%{srcname} -Version: 7.1.2 -Release: 3%{?dist} +Version: 7.3.1 +Release: 1%{?dist} Summary: Python implementation of SAML Version 2 -License: ASL 2.0 +License: Apache-2.0 URL: https://github.com/IdentityPython/%{srcname} -%global gittag v%{version} - - - Source0: https://github.com/IdentityPython/%{srcname}/archive/%{gittag}/%{srcname}-%{version}.tar.gz +#TODO: remove the line below once the patch upstream is merged and contained +# in a release https://github.com/IdentityPython/pysaml2/pull/916 +Patch0001: 0001-Remove-utility-from-packaging.patch BuildArch: noarch - -%description -PySAML2 is a pure python implementation of SAML2. It contains all -necessary pieces for building a SAML2 service provider or an identity -provider. The distribution contains examples of both. Originally -written to work in a WSGI environment there are extensions that allow -you to use it with other frameworks. - - - -%package -n python3-%{srcname} -Summary: Python implementation of SAML Version 2 -Conflicts: python2-%{srcname} < 4.5.0-6 -%{?python_provide:%python_provide python3-%{srcname}} - -Requires: python3-requests >= 1.0.0 -Requires: python3-future -Requires: python3-cryptography >= 3.1 -Requires: python3-pytz -Requires: python3-pyOpenSSL -Requires: python3-dateutil -Requires: python3-defusedxml -Requires: python3-six -Requires: python3-xmlschema >= 1.2.1 -Requires: xmlsec1 -Requires: xmlsec1-openssl - -BuildRequires: git-core BuildRequires: python3-devel -BuildRequires: python3-setuptools +BuildRequires: pyproject-rpm-macros +BuildRequires: git-core BuildRequires: python3-sphinx -BuildRequires: python3-defusedxml -# To run unit tests +# For tests BuildRequires: python3-pytest -BuildRequires: python3-mock -BuildRequires: python3-requests >= 1.0.0 -BuildRequires: python3-future -BuildRequires: python3-cryptography >= 3.1 -BuildRequires: python3-pytz -BuildRequires: python3-pyOpenSSL -BuildRequires: python3-dateutil -BuildRequires: python3-defusedxml -BuildRequires: python3-six -BuildRequires: python3-xmlschema >= 1.2.1 BuildRequires: python3-pymongo BuildRequires: python3-responses BuildRequires: xmlsec1 BuildRequires: xmlsec1-openssl -%description -n python3-%{srcname} -PySAML2 is a pure python implementation of SAML2. It contains all -necessary pieces for building a SAML2 service provider or an identity -provider. The distribution contains examples of both. Originally -written to work in a WSGI environment there are extensions that allow -you to use it with other frameworks. +%description %{_description} + +%package -n python%{python3_pkgversion}-%{srcname} +Summary: Python implementation of SAML Version 2 + +Requires: xmlsec1 +Requires: xmlsec1-openssl + +%description -n python%{python3_pkgversion}-%{srcname} %{_description} %package doc @@ -78,9 +50,17 @@ Summary: Documentation for Python implementation of SAML Version 2 %description doc Documentation for Python implementation of SAML Version 2. + +%generate_buildrequires +%pyproject_buildrequires -t + %prep %autosetup -n %{srcname}-%{version} -S git -sed -i '/argparse/d' setup.py + +# We need to remove the shebang manually otherwise automation removes +# the whole line leading to have a Syntax error: unterminated triple-quoted +# string. +sed -i 's|f"""#!/usr/bin/env python|f"""|' src/saml2/tools/parse_xsd2.py # Avoid non-executable-script rpmlint while maintaining timestamps find src -name \*.py | @@ -92,6 +72,7 @@ while read source; do rm "$source".ts fi done + # special case for parse_xsd generated file which have lines like: #!!!! 'NoneType' object has no attribute 'py_class' source="src/saml2/schema/wsdl.py" @@ -101,39 +82,49 @@ touch --ref="$source".ts "$source" rm "$source".ts %build +%pyproject_wheel -%py3_build +%install +%pyproject_install +%pyproject_save_files saml2 saml2test + +# compat symlinks +for bin in parse_xsd2 make_metadata mdexport merge_metadata; do + ln -s $bin %{buildroot}/%{_bindir}/${bin}.py +done # drop alabaster Sphinx theme, not packaged in Fedora yet -#sed -i '/alabaster/d' docs/conf.py +sed -i '/alabaster/d' docs/conf.py # generate html docs -export PYTHONPATH=./src +export PYTHONPATH="%{buildroot}/%{python3_sitelib}" sphinx-build-3 docs html # remove the sphinx-build leftovers rm -rf html/.{doctrees,buildinfo} -%install - -%py3_install - %check %pytest -%files -n python3-%{srcname} -%doc README.rst -%license LICENSE +%files -n python%{python3_pkgversion}-%{srcname} -f %{pyproject_files} +%{_bindir}/parse_xsd2 %{_bindir}/parse_xsd2.py +%{_bindir}/make_metadata %{_bindir}/make_metadata.py +%{_bindir}/mdexport %{_bindir}/mdexport.py +%{_bindir}/merge_metadata %{_bindir}/merge_metadata.py -%{python3_sitelib}/saml2 -%{python3_sitelib}/*.egg-info +%license LICENSE %files doc %license LICENSE %doc html %changelog +* Fri Jul 07 2023 Joel Capitao - 7.3.1-1 +- Update to 7.3.1 +- Switch to pyproject-rpm-macros +- Move to SPDX + * Thu Jun 29 2023 Python Maint - 7.1.2-3 - Rebuilt for Python 3.12