From 1ed8ef23a8f7b9dcae75721eeab8d5f79013b851 Mon Sep 17 00:00:00 2001 From: Zhong Jianxin Date: Mon, 13 May 2024 22:57:08 +0800 Subject: [PATCH] Replace distutils.version.StrictVersion with packaging.version.Version distutils was removed from Python 3.12 https://docs.python.org/3/whatsnew/3.12.html --- custom_components/smartir/__init__.py | 6 +++--- custom_components/smartir/manifest.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/custom_components/smartir/__init__.py b/custom_components/smartir/__init__.py index 278b202b..ee0afa12 100644 --- a/custom_components/smartir/__init__.py +++ b/custom_components/smartir/__init__.py @@ -2,7 +2,7 @@ import aiohttp import asyncio import binascii -from distutils.version import StrictVersion +from packaging.version import Version import json import logging import os.path @@ -77,14 +77,14 @@ async def _update(hass, branch, do_update=False, notify_if_latest=True): last_version = data['updater']['version'] release_notes = data['updater']['releaseNotes'] - if StrictVersion(last_version) <= StrictVersion(VERSION): + if Version(last_version) <= Version(VERSION): if notify_if_latest: hass.components.persistent_notification.async_create( "You're already using the latest version!", title='SmartIR') return - if StrictVersion(current_ha_version) < StrictVersion(min_ha_version): + if Version(current_ha_version) < Version(min_ha_version): hass.components.persistent_notification.async_create( "There is a new version of SmartIR integration, but it is **incompatible** " "with your system. Please first update Home Assistant.", title='SmartIR') diff --git a/custom_components/smartir/manifest.json b/custom_components/smartir/manifest.json index 23c31f58..d8e47d2a 100644 --- a/custom_components/smartir/manifest.json +++ b/custom_components/smartir/manifest.json @@ -4,7 +4,7 @@ "documentation": "https://github.com/smartHomeHub/SmartIR", "dependencies": [], "codeowners": ["@smartHomeHub"], - "requirements": ["aiofiles>=0.6.0"], + "requirements": ["aiofiles>=0.6.0", "packaging>=20.3"], "homeassistant": "2023.12.0", "version": "1.17.9", "updater": {