Upgrade protobuf dependency to allow v7.x — resolves pkg_resources deprecation
Context
The Home Assistant custom integration home-assistant-comfoconnect depends on aiocomfoconnect, which depends on protobuf. The current dependency chain is:
home-assistant-comfoconnect
→ aiocomfoconnect 0.1.15
→ protobuf >=6.31,<7.0
→ google/__init__.py (uses pkg_resources namespace declaration)
This issue was originally reported as michaelarnauts/home-assistant-comfoconnect#122, but the fix needs to happen here in aiocomfoconnect since this library owns the protobuf dependency pin.
Problem
Protobuf up to and including version 6.x ships a google/__init__.py that uses the legacy pkg_resources-style namespace declaration:
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
The pkg_resources API has been deprecated by the Python Packaging Authority and is slated for removal from setuptools. This causes a UserWarning on every Home Assistant startup:
UserWarning: pkg_resources is deprecated as an API.
See https://setuptools.pypa.io/en/latest/pkg_resources.html.
The pkg_resources package is slated for removal as early as 2025-11-30.
Refrain from using this package or pin to Setuptools<81.
While currently a warning, this will become a hard failure once setuptools removes pkg_resources entirely.
Verified solution
Protobuf 7.x eliminates the problem
Tested in a clean virtual environment:
python3 -m venv /tmp/protobuf-check
source /tmp/protobuf-check/bin/activate
pip install protobuf==7.34.1
python -c "import google; print(google.__file__)"
# Output: None
google.__file__ returning None confirms that protobuf 7.x has switched to PEP 420 native namespace packages — there is no google/__init__.py at all. No pkg_resources call, no deprecation warning.
Existing gencode is forward-compatible with protobuf 7.x
The critical question was whether the current zehnder_pb2.py (generated with protobuf 6.31 gencode) works on a protobuf 7.x runtime without regeneration. Tested against the current master branch:
git clone https://github.com/michaelarnauts/aiocomfoconnect.git /tmp/aiocomfoconnect-test
cd /tmp/aiocomfoconnect-test
pip install -e . # installs with protobuf 6.x
pip install --force-reinstall protobuf==7.34.1 # override to 7.x
python -c "from aiocomfoconnect.protobuf.zehnder_pb2 import GatewayOperation; print('OK')"
# Output: OK
The existing 6.31 gencode loads and works on protobuf 7.34.1 runtime without any errors or warnings. This is consistent with protobuf's compatibility policy (runtime accepts gencode from one major version back).
grpcio-tools does not yet support protobuf 7.x
For reference, grpcio-tools 1.80.0 (the latest version) currently pins protobuf<7.0.0,>=6.31.1. This means regenerating the proto files with protobuf 7.x gencode is not yet possible through the standard grpcio-tools toolchain. However, since the existing gencode is forward-compatible, regeneration is not required for this fix.
Proposed fix
A single dependency pin change in pyproject.toml:
- protobuf>=6.31,<7.0
+ protobuf>=6.31,<8
No regeneration of zehnder_pb2.py or nanopb_pb2.py is needed.
Optional follow-up (not blocking)
Once grpcio-tools adds support for protobuf 7.x, the proto files can be regenerated to align the gencode version with the runtime version. This would eliminate the one-major-version gap between gencode (6.31) and runtime (7.x), but is not functionally required since the current gencode is compatible.
After this is released
Once a new aiocomfoconnect version is published with this change, home-assistant-comfoconnect can bump its dependency to the new version, resolving michaelarnauts/home-assistant-comfoconnect#122.
Upgrade protobuf dependency to allow v7.x — resolves pkg_resources deprecation
Context
The Home Assistant custom integration home-assistant-comfoconnect depends on
aiocomfoconnect, which depends onprotobuf. The current dependency chain is:This issue was originally reported as michaelarnauts/home-assistant-comfoconnect#122, but the fix needs to happen here in
aiocomfoconnectsince this library owns the protobuf dependency pin.Problem
Protobuf up to and including version 6.x ships a
google/__init__.pythat uses the legacypkg_resources-style namespace declaration:The
pkg_resourcesAPI has been deprecated by the Python Packaging Authority and is slated for removal fromsetuptools. This causes aUserWarningon every Home Assistant startup:While currently a warning, this will become a hard failure once
setuptoolsremovespkg_resourcesentirely.Verified solution
Protobuf 7.x eliminates the problem
Tested in a clean virtual environment:
google.__file__returningNoneconfirms that protobuf 7.x has switched to PEP 420 native namespace packages — there is nogoogle/__init__.pyat all. Nopkg_resourcescall, no deprecation warning.Existing gencode is forward-compatible with protobuf 7.x
The critical question was whether the current
zehnder_pb2.py(generated with protobuf 6.31 gencode) works on a protobuf 7.x runtime without regeneration. Tested against the currentmasterbranch:The existing 6.31 gencode loads and works on protobuf 7.34.1 runtime without any errors or warnings. This is consistent with protobuf's compatibility policy (runtime accepts gencode from one major version back).
grpcio-tools does not yet support protobuf 7.x
For reference,
grpcio-tools1.80.0 (the latest version) currently pinsprotobuf<7.0.0,>=6.31.1. This means regenerating the proto files with protobuf 7.x gencode is not yet possible through the standardgrpcio-toolstoolchain. However, since the existing gencode is forward-compatible, regeneration is not required for this fix.Proposed fix
A single dependency pin change in
pyproject.toml:No regeneration of
zehnder_pb2.pyornanopb_pb2.pyis needed.Optional follow-up (not blocking)
Once
grpcio-toolsadds support for protobuf 7.x, the proto files can be regenerated to align the gencode version with the runtime version. This would eliminate the one-major-version gap between gencode (6.31) and runtime (7.x), but is not functionally required since the current gencode is compatible.After this is released
Once a new
aiocomfoconnectversion is published with this change,home-assistant-comfoconnectcan bump its dependency to the new version, resolving michaelarnauts/home-assistant-comfoconnect#122.