Skip to content

Use __version__ for syslog identification#22

Merged
SteveEasley merged 1 commit intoSteveEasley:mainfrom
robotdan:fix/syslog-version-lookup
Apr 15, 2026
Merged

Use __version__ for syslog identification#22
SteveEasley merged 1 commit intoSteveEasley:mainfrom
robotdan:fix/syslog-version-lookup

Conversation

@robotdan
Copy link
Copy Markdown
Contributor

@robotdan robotdan commented Apr 6, 2026

Summary

Fixes PackageNotFoundError in _send_syslog_identification when running in PyInstaller-bundled deployments.

PR #21 used importlib.metadata.version("pykaleidescape") to look up the package version at runtime. This was a reasonable approach but doesn't work in environments where package dist-info metadata isn't available — notably PyInstaller, which strips it by default.

kaleidescape.__version__ is already the single source of truth for the version (pyproject.toml reads from it via [tool.setuptools.dynamic]), so using it directly is both simpler and universally compatible.

PR SteveEasley#21 used importlib.metadata.version() to look up the package version at runtime for the syslog identification message. This fails with PackageNotFoundError in PyInstaller deployments because PyInstaller strips dist-info metadata by default.

kaleidescape.__version__ is the actual source of truth for the version (pyproject.toml reads from it via setuptools.dynamic), and works in all environments — pip installs, git URL installs, and PyInstaller bundles.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@SteveEasley
Copy link
Copy Markdown
Owner

Just a heads up I will be out of town till Tuesday of next week. Will look when I get back.

@SteveEasley SteveEasley merged commit 0b42090 into SteveEasley:main Apr 15, 2026
0 of 4 checks passed
robotdan added a commit to robotdan/pykaleidescape that referenced this pull request May 6, 2026
test_send_syslog_identification_uses_dunder_version (PR SteveEasley#22) patched
`kaleidescape.device.__version__`, which doesn't exist as a module
attribute — `device.py` does `from . import __version__` inside
`_send_syslog_identification`, making it a function-local. mock.patch
requires the attribute to exist on the target, so the test failed with
AttributeError.

Patch `kaleidescape.__version__` (the real location) instead. The
function's `from . import __version__` re-reads it on each call, so
the patched sentinel propagates through.

This test never executed in CI before merge because PR SteveEasley#22's runs were
cancelled at the 6h job timeout (the same hang fixed in this PR).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
SteveEasley pushed a commit that referenced this pull request May 6, 2026
PR #18 (Refresh device state after auto-reconnect) added two tests that
wait on `connect_signal` (STATE_CONNECTED) after the initial connect.
PR #19 (Dispatch STATE_CONNECTED only on auto-reconnect) then moved the
STATE_CONNECTED dispatch out of `_connect()` and into `_reconnect()`.
PR #19 updated other tests with the same pattern, but #19 was opened
before #18 merged, so the two tests added by #18 weren't updated.

Result: `await connect_signal.wait()` after initial connect waits
forever, hanging CI for the full 6h job timeout. Every CI run on main
since #18 has been cancelled this way (#19, #20, #21, v1.1.6, #22).

Match the pattern used by other tests updated in #19: assert
`state == STATE_CONNECTED` directly after the initial connect, and
keep `connect_signal.wait()` only for the post-reconnect signal where
STATE_CONNECTED is actually dispatched.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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