Switch out aiohttp-isal for aiohttp-fast-zlib to make isal optional (#116814)

* Switch out aiohttp-isal for aiohttp-fast-zlib to make isal optional

aiohttp-isal does not work on core installs where the system has 32bit userland and a 64bit kernel because we have no way to detect this configuration or handle it.

fixes #116681

* Update homeassistant/components/isal/manifest.json

* Update homeassistant/components/isal/manifest.json

* hassfest

* isal

* fixes

* Apply suggestions from code review

* make sure isal is updated before http

* fix tests

* late import
This commit is contained in:
J. Nick Koston
2024-05-05 16:06:12 -05:00
committed by GitHub
parent 092a2de340
commit 673bbc1372
13 changed files with 62 additions and 9 deletions

View File

@ -692,6 +692,8 @@ build.json @home-assistant/supervisor
/homeassistant/components/iqvia/ @bachya
/tests/components/iqvia/ @bachya
/homeassistant/components/irish_rail_transport/ @ttroy50
/homeassistant/components/isal/ @bdraco
/tests/components/isal/ @bdraco
/homeassistant/components/islamic_prayer_times/ @engrbm87 @cpfair
/tests/components/islamic_prayer_times/ @engrbm87 @cpfair
/homeassistant/components/iss/ @DurgNomis-drol

View File

@ -21,7 +21,6 @@ from aiohttp.typedefs import JSONDecoder, StrOrURL
from aiohttp.web_exceptions import HTTPMovedPermanently, HTTPRedirection
from aiohttp.web_protocol import RequestHandler
from aiohttp_fast_url_dispatcher import FastUrlDispatcher, attach_fast_url_dispatcher
from aiohttp_isal import enable_isal
from cryptography import x509
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import rsa
@ -54,6 +53,7 @@ from homeassistant.helpers.http import (
HomeAssistantView,
current_request,
)
from homeassistant.helpers.importlib import async_import_module
from homeassistant.helpers.network import NoURLAvailableError, get_url
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
@ -201,7 +201,9 @@ class ApiConfig:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the HTTP API and debug interface."""
enable_isal()
# Late import to ensure isal is updated before
# we import aiohttp_fast_zlib
(await async_import_module(hass, "aiohttp_fast_zlib")).enable()
conf: ConfData | None = config.get(DOMAIN)

View File

@ -1,6 +1,7 @@
{
"domain": "http",
"name": "HTTP",
"after_dependencies": ["isal"],
"codeowners": ["@home-assistant/core"],
"documentation": "https://www.home-assistant.io/integrations/http",
"integration_type": "system",

View File

@ -0,0 +1,20 @@
"""The isal integration."""
from __future__ import annotations
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.typing import ConfigType
DOMAIN = "isal"
CONFIG_SCHEMA = cv.empty_config_schema(DOMAIN)
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up up isal.
This integration is only used so that isal can be an optional
dep for aiohttp-fast-zlib.
"""
return True

View File

@ -0,0 +1,10 @@
{
"domain": "isal",
"name": "Intelligent Storage Acceleration",
"codeowners": ["@bdraco"],
"documentation": "https://www.home-assistant.io/integrations/isal",
"integration_type": "system",
"iot_class": "local_polling",
"quality_scale": "internal",
"requirements": ["isal==1.6.1"]
}

View File

@ -4,7 +4,7 @@ aiodhcpwatcher==1.0.0
aiodiscover==2.1.0
aiodns==3.2.0
aiohttp-fast-url-dispatcher==0.3.0
aiohttp-isal==0.3.1
aiohttp-fast-zlib==0.1.0
aiohttp==3.9.5
aiohttp_cors==0.7.0
aiohttp_session==2.12.0

View File

@ -28,7 +28,7 @@ dependencies = [
"aiohttp_cors==0.7.0",
"aiohttp_session==2.12.0",
"aiohttp-fast-url-dispatcher==0.3.0",
"aiohttp-isal==0.3.1",
"aiohttp-fast-zlib==0.1.0",
"astral==2.2",
"async-interrupt==1.1.1",
"attrs==23.2.0",

View File

@ -8,7 +8,7 @@ aiohttp==3.9.5
aiohttp_cors==0.7.0
aiohttp_session==2.12.0
aiohttp-fast-url-dispatcher==0.3.0
aiohttp-isal==0.3.1
aiohttp-fast-zlib==0.1.0
astral==2.2
async-interrupt==1.1.1
attrs==23.2.0

View File

@ -1160,6 +1160,9 @@ intellifire4py==2.2.2
# homeassistant.components.iperf3
iperf3==0.1.11
# homeassistant.components.isal
isal==1.6.1
# homeassistant.components.gogogate2
ismartgate==5.0.1

View File

@ -941,6 +941,9 @@ insteon-frontend-home-assistant==0.5.0
# homeassistant.components.intellifire
intellifire4py==2.2.2
# homeassistant.components.isal
isal==1.6.1
# homeassistant.components.gogogate2
ismartgate==5.0.1

View File

@ -0,0 +1 @@
"""Tests for the Intelligent Storage Acceleration integration."""

View File

@ -0,0 +1,10 @@
"""Test the Intelligent Storage Acceleration setup."""
from homeassistant.components.isal import DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
async def test_setup(hass: HomeAssistant) -> None:
"""Ensure we can setup."""
assert await async_setup_component(hass, DOMAIN, {})

View File

@ -591,7 +591,7 @@ async def test_discovery_requirements_mqtt(hass: HomeAssistant) -> None:
) as mock_process:
await async_get_integration_with_requirements(hass, "mqtt_comp")
assert len(mock_process.mock_calls) == 1
assert len(mock_process.mock_calls) == 2
assert mock_process.mock_calls[0][1][1] == mqtt.requirements
@ -608,12 +608,13 @@ async def test_discovery_requirements_ssdp(hass: HomeAssistant) -> None:
) as mock_process:
await async_get_integration_with_requirements(hass, "ssdp_comp")
assert len(mock_process.mock_calls) == 3
assert len(mock_process.mock_calls) == 4
assert mock_process.mock_calls[0][1][1] == ssdp.requirements
assert {
mock_process.mock_calls[1][1][0],
mock_process.mock_calls[2][1][0],
} == {"network", "recorder"}
mock_process.mock_calls[3][1][0],
} == {"network", "recorder", "isal"}
@pytest.mark.parametrize(
@ -637,7 +638,7 @@ async def test_discovery_requirements_zeroconf(
) as mock_process:
await async_get_integration_with_requirements(hass, "comp")
assert len(mock_process.mock_calls) == 3
assert len(mock_process.mock_calls) == 4
assert mock_process.mock_calls[0][1][1] == zeroconf.requirements