Skip to content

Commit

Permalink
Switch out aiohttp-isal for aiohttp-fast-zlib to make isal optional (h…
Browse files Browse the repository at this point in the history
…ome-assistant#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 home-assistant#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
  • Loading branch information
bdraco authored May 5, 2024
1 parent 092a2de commit 673bbc1
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions homeassistant/components/http/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
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
Expand Down Expand Up @@ -54,6 +53,7 @@
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
Expand Down Expand Up @@ -201,7 +201,9 @@ def __init__(

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)

Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/http/manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
20 changes: 20 additions & 0 deletions homeassistant/components/isal/__init__.py
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions homeassistant/components/isal/manifest.json
Original file line number Diff line number Diff line change
@@ -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"]
}
2 changes: 1 addition & 1 deletion homeassistant/package_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions tests/components/isal/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Tests for the Intelligent Storage Acceleration integration."""
10 changes: 10 additions & 0 deletions tests/components/isal/test_init.py
Original file line number Diff line number Diff line change
@@ -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, {})
9 changes: 5 additions & 4 deletions tests/test_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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(
Expand All @@ -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


Expand Down

0 comments on commit 673bbc1

Please sign in to comment.