Skip to content

Add hooks for openstacksdk, keystoneauth1 and os_service_types - #1063

Open
mabunemeh wants to merge 1 commit into
pyinstaller:masterfrom
mabunemeh:openstacksdk-hooks
Open

mabunemeh wants to merge 1 commit into
pyinstaller:masterfrom
mabunemeh:openstacksdk-hooks

Conversation

@mabunemeh

Copy link
Copy Markdown
Contributor

openstacksdk-based applications currently cannot be frozen: the resulting
binary either fails on import or misbehaves at run-time. Three mechanisms
defeat static analysis:

  • Metadata read at import time. openstack/version.py calls
    pbr.version.VersionInfo('openstacksdk') and
    os_service_types/__init__.py calls
    pbr.version.VersionInfo('os-service-types'), both of which read the
    installed distribution metadata, so importing the package raises without it.
  • Data files inside the packages. openstack.config loads
    config/defaults.json and its schemas from the package directory, and
    openstack.config.vendors globs the vendor profiles (*.json and *.yaml)
    from config/vendors/. A missing vendor profile is silently ignored, so a
    clouds.yaml with profile: ovh quietly loses its defaults. The hook
    therefore collects the whole config directory. os_service_types loads the
    service-type authority from data/service-types.json.
  • Modules resolved by name. Service proxies are selected by service type
    and microversion at run-time, and keystoneauth1 loads its auth plugins
    through stevedore from the keystoneauth1.plugin entry-point namespace
    (26 entry points in 5.19.0).

The test suites are excluded from the collected submodules, as is
keystoneauth1.fixture, which imports the optional fixtures library and
otherwise emits a build warning.

The tests cover the pbr version lookups, defaults.json, a JSON and a YAML
vendor profile, a service proxy, two stevedore-loaded auth plugins and the
service-type authority. All three packages now require Python >= 3.11, so the
pins carry that marker.

Validation:

  • With each hook removed in turn, its test fails in both onedir and onefile:
    openstack raises PackageNotFoundError for openstacksdk (pbr version
    lookup), keystoneauth1 raises
    ModuleNotFoundError: No module named 'keystoneauth1.loading._plugins',
    and os_service_types raises FileNotFoundError for
    os_service_types/data/service-types.json.
  • Without the config/vendors collection, the test_openstacksdk onedir and
    onefile builds fail at vendors.get_profile('ovh').
  • With the hooks, all six builds (3 tests x onedir/onefile) pass on
    Windows/Python 3.14 with PyInstaller 6.22.3, openstacksdk 4.24.0,
    keystoneauth1 5.19.0 and os-service-types 1.9.0.
  • Full-repository flake8 and news-fragment validation pass.
  • Focused GitHub Actions CI passes on Windows, Linux and macOS with Python
    3.14 and PyInstaller 6.22.3, 6 passed and none skipped on each platform.

Cross-platform CI: https://github.com/mabunemeh/pyinstaller-hooks-contrib/actions/runs/45048555080

@rokm

rokm commented Nov 22, 2026

Copy link
Copy Markdown
Member

collect_submodules does not recurse into subpackages that do not pass the filter test (since PyInstaller 5.1), so the .startswith() part of the filter lambdas is not needed.

openstacksdk-based applications cannot be frozen without these:

* openstack/version.py and os_service_types/__init__.py read their
  distribution metadata through pbr at import time, so freezing
  without the metadata raises on import.
* openstack.config loads defaults.json and its schemas from the
  package directory, openstack.config.vendors globs the vendor
  profiles (JSON and YAML) from config/vendors/, and os_service_types
  loads its service-type authority from a JSON data file. A missing
  vendor profile is silently ignored, so the whole config directory
  is collected.
* Service proxies are resolved by service type and microversion, and
  keystoneauth1 loads auth plugins through stevedore from the
  keystoneauth1.plugin entry-point namespace, so neither is reachable
  by static analysis.

The test suites and keystoneauth1.fixture (which needs the optional
fixtures library) are excluded from the collected submodules.
@mabunemeh

Copy link
Copy Markdown
Contributor Author

Thanks, you're right — since a rejected subpackage is never queued, nothing under it can reach the filter. I've reduced both filters to plain name checks (name != 'openstack.tests' and name not in _EXCLUDED); the collected module lists are identical (488 for openstack, 78 for keystoneauth1), and excluding keystoneauth1.fixture still avoids the missing-fixtures warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants