Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hook for saml2 #798

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions _pyinstaller_hooks_contrib/stdhooks/hook-saml2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# ------------------------------------------------------------------
# Copyright (c) 2024 PyInstaller Development Team.
#
# This file is distributed under the terms of the GNU General Public
# License (version 2.0 or later).
#
# The full license is available in LICENSE, distributed with
# this software.
#
# SPDX-License-Identifier: GPL-2.0-or-later
# ------------------------------------------------------------------

# Hook for https://github.com/IdentityPython/pysaml2
from PyInstaller.utils.hooks import collect_data_files, copy_metadata, collect_submodules

datas = copy_metadata("pysaml2")

# The library contains a bunch of XSD schemas that are loaded by the code:
# https://github.com/IdentityPython/pysaml2/blob/7cb4f09dce87a7e8098b9c7552ebab8bc77bc896/src/saml2/xml/schema/__init__.py#L23
# On the other hand, runtime tools are not needed.
datas += collect_data_files("saml2", excludes=["**/tools"])

# Submodules are loaded dynamically by:
# https://github.com/IdentityPython/pysaml2/blob/7cb4f09dce87a7e8098b9c7552ebab8bc77bc896/src/saml2/attribute_converter.py#L52
hiddenimports = collect_submodules("saml2.attributemaps")
1 change: 1 addition & 0 deletions news/798.new.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add hook for ``saml2`` package which has XSD files and hidden imports.
2 changes: 2 additions & 0 deletions requirements-test-libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ schwifty==2024.9.0 # pyup: != '2024.8.1'
patool==2.4.0; python_version >= '3.10'
yapf==0.40.2
xmlschema==2.5.1
pysaml2==7.5.0; python_version >= '3.9'
pysaml2==7.3.0; python_version < '3.9'

# ------------------- Platform (OS) specifics

Expand Down
12 changes: 12 additions & 0 deletions tests/test_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -2187,3 +2187,15 @@ def test_xmlschema(pyi_builder):
pyi_builder.test_source("""
import xmlschema
""")


@importorskip('saml2')
def test_saml2(pyi_builder):
pyi_builder.test_source("""
# this loads XSD files
import saml2.xml.schema

# this loads submodules from saml2.attributemap
from saml2.attribute_converter import ac_factory
ac_factory()
""")
Loading