Skip to content
Open
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
33 changes: 33 additions & 0 deletions _pyinstaller_hooks_contrib/stdhooks/hook-keystoneauth1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# ------------------------------------------------------------------
# Copyright (c) 2026 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
# ------------------------------------------------------------------
"""
keystoneauth1 is the authentication library used by openstacksdk and the
OpenStack client tools.

Auth plugins are discovered through stevedore, using the
``keystoneauth1.plugin`` entry-point namespace, so the distribution metadata is
required and the plugin modules are not reachable by static analysis.

The test suite and the ``keystoneauth1.fixture`` test-support package are
skipped: they are not used at run-time, and ``keystoneauth1.fixture`` requires
the optional ``fixtures`` library.

This hook was tested with keystoneauth1 5.19.0.
"""

from PyInstaller.utils.hooks import collect_submodules, copy_metadata

_EXCLUDED = ('keystoneauth1.tests', 'keystoneauth1.fixture')

datas = copy_metadata('keystoneauth1')

hiddenimports = collect_submodules('keystoneauth1', filter=lambda name: name not in _EXCLUDED)
36 changes: 36 additions & 0 deletions _pyinstaller_hooks_contrib/stdhooks/hook-openstack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# ------------------------------------------------------------------
# Copyright (c) 2026 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
# ------------------------------------------------------------------
"""
openstacksdk is imported as ``openstack``.

``openstack/version.py`` calls ``pbr.version.VersionInfo('openstacksdk')`` at
import time, which reads the installed distribution metadata, so the metadata
must be collected or importing the package raises.

``openstack.config`` loads ``config/defaults.json`` and its JSON schemas from
the package directory at run-time, and ``openstack.config.vendors`` globs the
vendor profiles (JSON and YAML) from ``config/vendors/``; a missing vendor
profile is silently ignored, so the whole ``config`` directory is collected.

Service proxies and resource classes live in per-service sub-packages that are
resolved by service type and microversion at run-time, so they are collected as
hidden imports.

This hook was tested with openstacksdk 4.24.0.
"""

from PyInstaller.utils.hooks import collect_data_files, collect_submodules, copy_metadata

datas = copy_metadata('openstacksdk')
datas += collect_data_files('openstack', subdir='config')

hiddenimports = collect_submodules('openstack', filter=lambda name: name != 'openstack.tests')
24 changes: 24 additions & 0 deletions _pyinstaller_hooks_contrib/stdhooks/hook-os_service_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# ------------------------------------------------------------------
# Copyright (c) 2026 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
# ------------------------------------------------------------------
"""
os_service_types ships the OpenStack service-type authority as a JSON data
file, and ``os_service_types/__init__.py`` calls
``pbr.version.VersionInfo('os-service-types')`` at import time, which reads the
installed distribution metadata.

This hook was tested with os-service-types 1.9.0.
"""

from PyInstaller.utils.hooks import collect_data_files, copy_metadata

datas = copy_metadata('os-service-types')
datas += collect_data_files('os_service_types')
6 changes: 6 additions & 0 deletions news/1063.new.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Add hooks for ``openstacksdk`` (imported as ``openstack``), ``keystoneauth1`` and
``os_service_types``. These collect the distribution metadata that ``pbr`` reads
at import time, the data files that ``openstack.config`` (including its vendor
profiles) and ``os_service_types`` load at run-time, and the service proxies and
stevedore auth plugins that are resolved by name and are therefore invisible to
static analysis.
3 changes: 3 additions & 0 deletions requirements-test-libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ imageio==2.38.2; python_version >= "3.11"
iminuit==2.33.0; python_version >= "3.9"
iso639-lang==2.6.3; python_version >= "3.9"
kaleido==1.5.1; python_version >= "3.9"
keystoneauth1==5.19.0; python_version >= "3.11"
langdetect==1.0.9
mariadb==1.1.15; sys_platform != "darwin" and python_version >= "3.11"
markdown==3.11.3; python_version >= "3.11"
Expand All @@ -80,6 +81,8 @@ numba==0.68.1; python_version >= "3.10" and (sys_platform != "darwin" or platfor
numcodecs==0.17.1; python_version >= "3.12"
Office365-REST-Python-Client==3.3.1; python_version >= "3.9"
openpyxl==3.1.5
openstacksdk==4.24.0; python_version >= "3.11"
os-service-types==1.9.0; python_version >= "3.11"
pandas==3.1.1; python_version >= "3.11" # pyup: != 3.0.4 # yanked
panel==1.10.0; python_version >= "3.12"
pandera==0.36.0; python_version >= "3.10"
Expand Down
50 changes: 50 additions & 0 deletions tests/test_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -3661,3 +3661,53 @@ def test_pymupdf(pyi_builder, tmp_path):

text = txt_filename.read_text(encoding='utf-8').strip()
assert text == 'The quick brown fox jumped over the lazy dog'


@importorskip("openstack")
def test_openstacksdk(pyi_builder):
pyi_builder.test_source("""
# openstack/version.py reads the openstacksdk distribution metadata via pbr
# when it is imported.
from openstack import version
assert version.__version__

# openstack/config reads its defaults.json from the package directory.
from openstack.config import defaults
assert 'auth_type' in defaults.get_defaults()

# Vendor profiles are JSON and YAML files in config/vendors/, globbed
# at run-time; a missing profile is silently ignored.
from openstack.config import vendors
assert vendors.get_profile('ovh')
assert vendors.get_profile('limestonenetworks')

# Service proxies live in per-service sub-packages that are resolved by
# service type and microversion at run-time.
from openstack.block_storage.v3 import _proxy
assert _proxy.Proxy
""")


@importorskip("keystoneauth1")
def test_keystoneauth1(pyi_builder):
pyi_builder.test_source("""
# Auth plugins are loaded through stevedore, from the keystoneauth1.plugin
# entry-point namespace, so the distribution metadata is required.
from keystoneauth1 import loading
assert loading.get_plugin_loader('password')
assert loading.get_plugin_loader('v3token')
""")


@importorskip("os_service_types")
def test_os_service_types(pyi_builder):
pyi_builder.test_source("""
import os_service_types

# os_service_types/__init__.py reads the distribution metadata via pbr.
assert os_service_types.__version__

# The service-type authority is shipped as a JSON data file.
service_types = os_service_types.ServiceTypes()
assert service_types.get_service_type('compute') == 'compute'
""")
Loading